6-- Represents any data that can take two different types.
8-- This can also be used for error handling `(Either String a)` where error
9-- messages are stored on the left, and the correct values (“right”
10-- values) are stored on the right.
11data Either a b = Left a | Right b
13-- Apply the first function to a `Left` and the second function to a `Right`.
14-- This allows the extraction of a value from an `Either`.
15either : (a -> c) -> (b -> c) -> Either a b -> c
16either f g e = case e of { Left x -> f x ; Right y -> g y }
18-- True if the value is a `Left`.
19isLeft : Either a b -> Bool
20isLeft e = case e of { Left _ -> True ; _ -> False }
22-- True if the value is a `Right`.
23isRight : Either a b -> Bool
24isRight e = case e of { Right _ -> True ; _ -> False }
26-- Keep only the values held in `Left` values.
27lefts : [Either a b] -> [a]
28lefts es = List.foldr consLeft [] es
30-- Keep only the values held in `Right` values.
31rights : [Either a b] -> [b]
32rights es = List.foldr consRight [] es
34-- Split into two lists, lefts on the left and rights on the right. So we
35-- have the equivalence: `(partition es == (lefts es, rights es))`
36partition : [Either a b] -> ([a],[b])
37partition es = List.foldr consEither ([],[]) es
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list