File tree 2 files changed +15
-1
lines changed 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 23
23
24
24
instance eqMaybe :: (Eq a) => Eq (Maybe a)
25
25
26
+ instance extendMaybe :: Extend Maybe
27
+
26
28
instance functorMaybe :: Functor Maybe
27
29
28
30
instance monadMaybe :: Monad Maybe
33
35
34
36
instance plusMaybe :: Plus Maybe
35
37
38
+ instance semigroupMaybe :: (Semigroup a) => Semigroup (Maybe a)
39
+
36
40
instance showMaybe :: (Show a) => Show (Maybe a)
37
41
38
42
Original file line number Diff line number Diff line change 1
1
module Data.Maybe where
2
2
3
3
import Control.Alt
4
- import Control.Plus
5
4
import Control.Alternative
5
+ import Control.Extend
6
6
import Control.MonadPlus
7
+ import Control.Plus
7
8
8
9
data Maybe a = Nothing | Just a
9
10
@@ -48,6 +49,15 @@ instance monadMaybe :: Monad Maybe
48
49
49
50
instance monadPlusMaybe :: MonadPlus Maybe
50
51
52
+ instance extendMaybe :: Extend Maybe where
53
+ (<<=) _ Nothing = Nothing
54
+ (<<=) f x = Just $ f x
55
+
56
+ instance semigroupMaybe :: (Semigroup a ) => Semigroup (Maybe a ) where
57
+ (<>) Nothing x = x
58
+ (<>) x Nothing = x
59
+ (<>) (Just x) (Just y) = Just (x <> y)
60
+
51
61
instance showMaybe :: (Show a ) => Show (Maybe a ) where
52
62
show (Just x) = " Just (" ++ show x ++ " )"
53
63
show Nothing = " Nothing"
You can’t perform that action at this time.
0 commit comments