diff options
author | Camil Staps | 2016-02-02 19:24:50 +0100 |
---|---|---|
committer | Camil Staps | 2016-02-02 19:24:50 +0100 |
commit | a7d7542dc646a5fd124ef71e71ce260889f1701b (patch) | |
tree | 04ed89503bbb3cc9933273a1326a53ca724c3492 /fp2/week1/camil/StdMaybe.dcl | |
parent | week6 camil: working positioning of lines by putting empties at left and righ... (diff) |
Diffstat (limited to 'fp2/week1/camil/StdMaybe.dcl')
-rw-r--r-- | fp2/week1/camil/StdMaybe.dcl | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/fp2/week1/camil/StdMaybe.dcl b/fp2/week1/camil/StdMaybe.dcl deleted file mode 100644 index 2403683..0000000 --- a/fp2/week1/camil/StdMaybe.dcl +++ /dev/null @@ -1,41 +0,0 @@ -definition module StdMaybe - -// ******************************************************************************** -// Clean StdLib library module, version 1.0 -// ******************************************************************************** - -from StdFunc import :: St; -from StdOverloaded import class ==(..); - -:: Maybe x - = Just x - | Nothing - -isJust :: !(Maybe .x) -> Bool // case @1 of (Just _) -> True; _ -> False -isNothing :: !(Maybe .x) -> Bool // not o isJust -fromJust :: !(Maybe .x) -> .x // \(Just x) -> x - -// for possibly unique elements: -u_isJust :: !u:(Maybe .x) -> (!Bool, !u:Maybe .x) -u_isNothing :: !u:(Maybe .x) -> (!Bool, !u:Maybe .x) - -accMaybe :: .(St .x .a) !u:(Maybe .x) -> (!Maybe .a,!u:Maybe .x) -// accMaybe f (Just x) = (Just (fst (f x)),Just (snd (f x))) -// accMaybe f Nothing = (Nothing,Nothing) - -mapMaybe :: .(.x -> .y) !(Maybe .x) -> Maybe .y -// mapMaybe f (Just x) = Just (f x) -// mapMaybe f Nothing = Nothing - -instance == (Maybe x) | == x -// Nothing==Nothing -// Just a ==Just b <= a==b - -maybeToList :: !(Maybe .a) -> [.a]; -// returns list with no or one element - -listToMaybe :: ![.a] -> .Maybe .a; -// returns Just head of list if possible - -catMaybes :: ![Maybe .a] -> .[.a]; -// catMaybes ms = [ m \\ Just m <- ms ] |