git.iko.soy/rowtype-yoga/purescript-native
on c193571 help sign in
39 lines 765 B history raw
1module Main where
3import Prelude
5example1 :: String
6example1 = do
7 "Do"
8 " notation"
9 " for"
10 " Semigroup"
11 where
12 bind x f = x <> f unit
14(*>) :: forall f a b. (Apply f) => f a -> f b -> f b
15(*>) fa fb = const id <$> fa <*> fb
17newtype Const a b = Const a
19runConst :: forall a b. Const a b -> a
20runConst (Const a) = a
22instance functorConst :: Functor (Const a) where
23 map _ (Const a) = Const a
25instance applyConst :: (Semigroup a) => Apply (Const a) where
26 apply (Const a1) (Const a2) = Const (a1 <> a2)
28example2 :: Const String Unit
29example2 = do
30 Const "Do"
31 Const " notation"
32 Const " for"
33 Const " Apply"
34 where
35 bind x f = x *> f unit
37main = do
38 Control.Monad.Eff.Console.log example1
39 Control.Monad.Eff.Console.log $ runConst example2