Document new features

This commit is contained in:
Kiana Sheibani 2023-04-24 10:02:32 -04:00
parent 32b6962be7
commit bf3ef35b63
Signed by: toki
GPG key ID: 6CB106C25E86A9F7
4 changed files with 80 additions and 10 deletions

View file

@ -9,28 +9,40 @@ import Control.Lens.Optional
%default total
||| An interface that provides a way to detach and inspect elements from the
||| left side of a sequence.
public export
interface Cons s t a b | s where
||| This is a prism that can attach or detach a value from the left side of a
||| sequence.
cons_ : Prism s t (a, s) (b, t)
||| Access the head (left-most element) of a sequence, if it is non-empty.
public export
head_ : Cons s s a a => Optional' s a
head_ @{_} @{MkIsOptional _} = cons_ . first
||| Access the tail (all but the left-most element) of a sequence, if it is
||| non-empty.
public export
tail_ : Cons s s a a => Optional' s s
tail_ @{_} @{MkIsOptional _} = cons_ . second
||| An interface that provides a way to detach and inspect elements from the
||| right side of a sequence.
public export
interface Snoc s t a b | s where
||| This is a prism that can attach or detach a value from the right side of a
||| sequence.
snoc_ : Prism s t (s, a) (t, b)
||| Access all but the right-most element of a sequence, if it is non-empty.
public export
init_ : Snoc s s a a => Optional' s s
init_ @{_} @{MkIsOptional _} = snoc_ . first
||| Access the last (right-most) element of a sequence, if it is non-empty.
public export
last_ : Snoc s s a a => Optional' s a
last_ @{_} @{MkIsOptional _} = snoc_ . second