@@ -1,12 +1,10 @@
11module prelude.maybe
22
33import builtins
4−import prelude.list
5−import prelude.monad
64
75data Maybe a
8− = Nothing
9− | Just a
6+ = Nothing
7+ | Just a
108
119--------------------------------------------------------------------------------
1210-- Syntactic tests
@@ -20,18 +18,6 @@ isJust : Maybe a -> Bool
2018isJust Nothing = False
2119isJust (Just j) = True
2220
23−--------------------------------------------------------------------------------
24−-- Conversions
25−--------------------------------------------------------------------------------
26−
27−maybeToList : Maybe a -> List a
28−maybeToList Nothing = []
29−maybeToList (Just j) = [j]
30−
31−listToMaybe : List a -> Maybe a
32−listToMaybe [] = Nothing
33−listToMaybe (x::xs) = Just x
34−
3521--------------------------------------------------------------------------------
3622-- Misc
3723--------------------------------------------------------------------------------
@@ -48,20 +34,6 @@ toMaybe : Bool -> a -> Maybe a
4834toMaybe True j = Just j
4935toMaybe False j = Nothing
5036
51−catMaybes : List (Maybe a) -> List a
52−catMaybes [] = []
53−catMaybes (x::xs) =
54− case x of
55− Nothing => catMaybes xs
56− Just j => j :: catMaybes xs
57−
58−mapMaybe : (a -> Maybe b) -> List a -> List b
59−mapMaybe f [] = []
60−mapMaybe f (x::xs) =
61− case f x of
62− Nothing => mapMaybe f xs
63− Just j => j :: mapMaybe f xs
64−
6537--------------------------------------------------------------------------------
6638-- Class instances
6739--------------------------------------------------------------------------------