6-- The Maybe datatype. Useful when a computation may or may not
7-- result in a value (e.g. logarithm is defined only for positive numbers).
8data Maybe a = Just a | Nothing
10-- Apply a function to the contents of a `Maybe`.
11-- Return default when given `Nothing`.
12maybe : b -> (a -> b) -> Maybe a -> b
13maybe b f m = case m of
17-- Check if constructed with `Just`.
18isJust : Maybe a -> Bool
19isJust = maybe False (\_ -> True)
21-- Check if constructed with `Nothing`.
22isNothing : Maybe a -> Bool
23isNothing = not . isJust
26-- If `Just`, adds the value to the front of the list.
27-- If `Nothing`, list is unchanged.
28cons : Maybe a -> [a] -> [a]
29cons mx xs = maybe xs (\x -> x :: xs) mx
31-- Filters out Nothings and extracts the remaining values.
32justs : [Maybe a] -> [a]
33justs = List.foldr cons []
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