git.iko.soy/rowtype-yoga/purescript-native
on e65645e help sign in
37 lines 729 B history raw
1module Main where
3example1 :: String
4example1 = do
5 "Do"
6 " notation"
7 " for"
8 " Semigroup"
9 where
10 (>>=) x f = x <> f unit
12(*>) :: forall f a b. (Apply f) => f a -> f b -> f b
13(*>) fa fb = const id <$> fa <*> fb
15newtype Const a b = Const a
17runConst :: forall a b. Const a b -> a
18runConst (Const a) = a
20instance functorConst :: Functor (Const a) where
21 (<$>) _ (Const a) = Const a
23instance applyConst :: (Semigroup a) => Apply (Const a) where
24 (<*>) (Const a1) (Const a2) = Const (a1 <> a2)
26example2 :: Const String Unit
27example2 = do
28 Const "Do"
29 Const " notation"
30 Const " for"
31 Const " Apply"
32 where
33 (>>=) x f = x *> f unit
35main = do
36 Debug.Trace.trace example1
37 Debug.Trace.trace $ runConst example2