git.iko.soy/rowtype-yoga/purescript-native
on cd4c708 help sign in
43 lines 850 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
15applySecond :: forall f a b. (Apply f) => f a -> f b -> f b
16applySecond fa fb = const id <$> fa <*> fb
18infixl 4 applySecond as *>
20newtype Const a b = Const a
22runConst :: forall a b. Const a b -> a
23runConst (Const a) = a
25instance functorConst :: Functor (Const a) where
26 map _ (Const a) = Const a
28instance applyConst :: (Semigroup a) => Apply (Const a) where
29 apply (Const a1) (Const a2) = Const (a1 <> a2)
31example2 :: Const String Unit
32example2 = do
33 Const "Do"
34 Const " notation"
35 Const " for"
36 Const " Apply"
37 where
38 bind x f = x *> f unit
40main = do
41 log example1
42 log $ runConst example2
43 log "Done"