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