git.iko.soy/rowtype-yoga/purescript-backend-optimizer
on main help sign in
30 lines 537 B history raw
1module Snapshot.EffectBind03 where
3import Prelude
5import Effect (Effect)
7newtype MyEffect a = MyEffect (Effect a)
9instance Functor MyEffect where
10 map f (MyEffect a) = MyEffect (map f a)
12instance Apply MyEffect where
13 apply = ap
15instance Applicative MyEffect where
16 pure = MyEffect <<< pure
18instance Bind MyEffect where
19 bind (MyEffect a) k = MyEffect do
20 a' <- a
21 let (MyEffect k') = k a'
22 k'
24instance Monad MyEffect
26test :: MyEffect Int -> MyEffect Int
27test random = do
28 a <- random
29 b <- random
30 pure $ a + b