A covering function converts a value into a view of that value. The view describes its structure in a form that dependent pattern matching can use. By convention, the function takes the view type’s name with an initial lowercase letter. section 10.1.2 section 10.4
total #1 listLast : (xs : List a) -> ListLast xs listLast [] = Empty listLast (x :: xs) = case listLast xs of #2 Empty => NonEmpty [] x NonEmpty ys y => NonEmpty (x :: ys) y
The listLast implementation recursively builds a ListLast view, exposing a list’s final element. section 10.1.2
Traversing a list from the end
The recursive SnocList view represents a list from its final element backward. Its covering function, snocList, supplies that view to myReverseHelper, which pattern-matches on it to build a reversed list. section 10.2.1
Views can also support data abstraction: a module can hide a store’s representation while exporting a view and its covering function for traversal. section 10.3
