git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Inserted Bind into hierarchy.
7783302joneshf
examples/passing/Do.purs+4−2
@@ -15,11 +15,13 @@ instance applyMaybe :: Apply Maybe where
15instance applicativeMaybe :: Applicative Maybe where
15instance applicativeMaybe :: Applicative Maybe where
16 pure = Just
16 pure = Just
17
17
18−instance monadMaybe :: Prelude.Monad Maybe where
18+instance bindMaybe :: Bind Maybe where
19− return = Just
20 (>>=) Nothing _ = Nothing
19 (>>=) Nothing _ = Nothing
21 (>>=) (Just a) f = f a
20 (>>=) (Just a) f = f a
22
21
22+instance monadMaybe :: Prelude.Monad Maybe where
23+ return = Just
24+
23test1 = \_ -> do
25test1 = \_ -> do
24 Just "abc"
26 Just "abc"
25
27
examples/passing/MonadState.purs+4−2
@@ -21,11 +21,13 @@ instance applyState :: Apply (State s) where
21instance applicativeState :: Applicative (State s) where
21instance applicativeState :: Applicative (State s) where
22 pure = return
22 pure = return
23
23
24−instance monadState :: Prelude.Monad (State s) where
24+instance bindState :: Bind (State s) where
25− return a = State $ \s -> Tuple s a
26 (>>=) f g = State $ \s -> case runState s f of
25 (>>=) f g = State $ \s -> case runState s f of
27 Tuple s1 a -> runState s1 (g a)
26 Tuple s1 a -> runState s1 (g a)
28
27
28+instance monadState :: Monad (State s) where
29+ return a = State $ \s -> Tuple s a
30+
29instance monadStateState :: MonadState s (State s) where
31instance monadStateState :: MonadState s (State s) where
30 get = State (\s -> Tuple s s)
32 get = State (\s -> Tuple s s)
31 put s = State (\_ -> Tuple s {})
33 put s = State (\_ -> Tuple s {})
examples/passing/Superclasses3.purs+3−1
@@ -30,9 +30,11 @@ instance applyMTrace :: Apply MTrace where
30instance applicativeMTrace :: Applicative MTrace where
30instance applicativeMTrace :: Applicative MTrace where
31 pure = return
31 pure = return
32
32
33+instance bindMTrace :: Bind MTrace where
34+ (>>=) m f = MTrace (runMTrace m >>= (runMTrace <<< f))
35+
33instance monadMTrace :: Monad MTrace where
36instance monadMTrace :: Monad MTrace where
34 return = MTrace <<< return
37 return = MTrace <<< return
35− (>>=) m f = MTrace (runMTrace m >>= (runMTrace <<< f))
36
38
37instance writerMTrace :: MonadWriter String MTrace where
39instance writerMTrace :: MonadWriter String MTrace where
38 tell s = MTrace (trace s)
40 tell s = MTrace (trace s)
examples/passing/TypeClasses.purs+12−6
@@ -30,10 +30,12 @@ instance applyData :: Apply Data where
30instance applicativeData :: Applicative Data where
30instance applicativeData :: Applicative Data where
31 pure = return
31 pure = return
32
32
33−instance monadData :: Prelude.Monad Data where
33+instance bindData :: Bind Data where
34− return = Data
35 (>>=) (Data a) f = f a
34 (>>=) (Data a) f = f a
36
35
36+instance monadData :: Monad Data where
37+ return = Data
38+
37data Maybe a = Nothing | Just a
39data Maybe a = Nothing | Just a
38
40
39instance functorMaybe :: Functor Maybe where
41instance functorMaybe :: Functor Maybe where
@@ -45,11 +47,13 @@ instance applyMaybe :: Apply Maybe where
45instance applicativeMaybe :: Applicative Maybe where
47instance applicativeMaybe :: Applicative Maybe where
46 pure = return
48 pure = return
47
49
48−instance monadMaybe :: Prelude.Monad Maybe where
50+instance bindMaybe :: Bind Maybe where
49− return = Just
50 (>>=) Nothing _ = Nothing
51 (>>=) Nothing _ = Nothing
51 (>>=) (Just a) f = f a
52 (>>=) (Just a) f = f a
52
53
54+instance monadMaybe :: Monad Maybe where
55+ return = Just
56+
53test4 :: forall a m. (Monad m) => a -> m Number
57test4 :: forall a m. (Monad m) => a -> m Number
54test4 = \_ -> return 1
58test4 = \_ -> return 1
55
59
@@ -70,10 +74,12 @@ instance applyFunction :: Apply ((->) r) where
70instance applicativeFunction :: Applicative ((->) r) where
74instance applicativeFunction :: Applicative ((->) r) where
71 pure = return
75 pure = return
72
76
73−instance monadFunction :: Prelude.Monad ((->) r) where
77+instance bindFunction :: Bind ((->) r) where
74− return a r = a
75 (>>=) f g r = g (f r) r
78 (>>=) f g r = g (f r) r
76
79
80+instance monadFunction :: Monad ((->) r) where
81+ return a r = a
82+
77ask r = r
83ask r = r
78
84
79runReader r f = f r
85runReader r f = f r
prelude/prelude.purs+7−3
@@ -76,10 +76,12 @@ module Prelude where
76
76
77 infixl 1 >>=
77 infixl 1 >>=
78
78
79− class (Applicative m) <= Monad m where
79+ class (Apply m) <= Bind m where
80− return :: forall a. a -> m a
81 (>>=) :: forall a b. m a -> (a -> m b) -> m b
80 (>>=) :: forall a b. m a -> (a -> m b) -> m b
82
81
82+ class (Applicative m, Bind m) <= Monad m where
83+ return :: forall a. a -> m a
84+
83 liftM1 :: forall m a b. (Monad m) => (a -> b) -> m a -> m b
85 liftM1 :: forall m a b. (Monad m) => (a -> b) -> m a -> m b
84 liftM1 f a = do
86 liftM1 f a = do
85 a' <- a
87 a' <- a
@@ -398,9 +400,11 @@ module Control.Monad.Eff where
398 instance applicativeEff :: Applicative (Eff e) where
400 instance applicativeEff :: Applicative (Eff e) where
399 pure = return
401 pure = return
400
402
403+ instance bindEffInstance :: Bind (Eff e) where
404+ (>>=) = bindEff
405+
401 instance monadEff :: Monad (Eff e) where
406 instance monadEff :: Monad (Eff e) where
402 return = retEff
407 return = retEff
403− (>>=) = bindEff
404
408
405 foreign import untilE "function untilE(f) {\
409 foreign import untilE "function untilE(f) {\
406 \ return function() {\
410 \ return function() {\