git.iko.soy/rowtype-yoga/purescript-native
on ebbc4e4 help sign in
41 lines 944 B history raw
1module Main where
3import Prelude
4import Control.Monad.Eff.Console
5import Control.Monad.Eff
7class (Monad m) <= MonadWriter w m where
8 tell :: w -> m Unit
10testFunctor :: forall m. (Monad m) => m Number -> m Number
11testFunctor n = (+) 1.0 <$> n
13test :: forall w m. (Monad m, MonadWriter w m) => w -> m Unit
14test w = do
15 tell w
16 tell w
17 tell w
19data MTrace a = MTrace (Eff (console :: CONSOLE) a)
21runMTrace :: forall a. MTrace a -> Eff (console :: CONSOLE) a
22runMTrace (MTrace a) = a
24instance functorMTrace :: Functor MTrace where
25 map = liftM1
27instance applyMTrace :: Apply MTrace where
28 apply = ap
30instance applicativeMTrace :: Applicative MTrace where
31 pure = MTrace <<< return
33instance bindMTrace :: Bind MTrace where
34 bind m f = MTrace (runMTrace m >>= (runMTrace <<< f))
36instance monadMTrace :: Monad MTrace
38instance writerMTrace :: MonadWriter String MTrace where
39 tell s = MTrace (log s)
41main = runMTrace $ test "Done"