@@ -1,12 +1,37 @@
1module Main where
1module Main where
3−example :: String
3+example1 :: String
4−example = do
4+example1 = do
6 " notation"
6 " notation"
8− " monoids"
8+ " Semigroup"
10 (>>=) x f = x <> f unit
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
15+newtype Const a b = Const a
17+runConst :: forall a b. Const a b -> a
18+runConst (Const a) = a
20+instance functorConst :: Functor (Const a) where
21+ (<$>) _ (Const a) = Const a
23+instance applyConst :: (Semigroup a) => Apply (Const a) where
24+ (<*>) (Const a1) (Const a2) = Const (a1 <> a2)
26+example2 :: Const String Unit
33+ (>>=) x f = x *> f unit
36+ Debug.Trace.trace example1
12−main = Debug.Trace.trace example
37+ Debug.Trace.trace $ runConst example2