File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 2323
2424 instance eqMaybe :: (Eq a) => Eq (Maybe a)
2525
26+ instance extendMaybe :: Extend Maybe
27+
2628 instance functorMaybe :: Functor Maybe
2729
2830 instance monadMaybe :: Monad Maybe
3335
3436 instance plusMaybe :: Plus Maybe
3537
38+ instance semigroupMaybe :: (Semigroup a) => Semigroup (Maybe a)
39+
3640 instance showMaybe :: (Show a) => Show (Maybe a)
3741
3842
Original file line number Diff line number Diff line change 11module Data.Maybe where
22
33import Control.Alt
4- import Control.Plus
54import Control.Alternative
5+ import Control.Extend
66import Control.MonadPlus
7+ import Control.Plus
78
89data Maybe a = Nothing | Just a
910
@@ -48,6 +49,15 @@ instance monadMaybe :: Monad Maybe
4849
4950instance monadPlusMaybe :: MonadPlus Maybe
5051
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+
5161instance showMaybe :: (Show a ) => Show (Maybe a ) where
5262 show (Just x) = " Just (" ++ show x ++ " )"
5363 show Nothing = " Nothing"
You can’t perform that action at this time.
0 commit comments