concept reverse in category idris

appears as: reverse
Type-Driven Development with Idris

This is an excerpt from Manning's book Type-Driven Development with Idris.

You can also manipulate Strings. The ++ operator concatenates Strings, and the reverse function reverses a String:

  • Define alternative ways of traversing data structures, such as traversing a list in reverse, or by repeatedly splitting the list into halves
  • Type— Call the function myReverse because there’s already a reverse function in the Prelude:
    myReverse : List a -> List a
    myReverse input = ?myReverse_rhs
  • The good news is that once you’ve defined snocList, you can reuse it for any function that needs to traverse a list in reverse. Furthermore, as you’ll see shortly, a SnocList view is also defined in the Idris library, along with several others.