{-# LANGUAGE NoImplicitPrelude, KindSignatures #-} import Data.Kind (Type) k :: a -> b -> a k x _ = x s :: (a -> b -> c) -> (a -> b) -> a -> c s f g x = f x (g x) b :: (b -> c) -> (a -> b) -> a -> c b f g x = f (g x) w :: (a -> a -> c) -> a -> c w x y = x y y c :: (a -> b -> c) -> b -> a -> c c f x y = f y x class Functor (f :: Type -> Type) where fmap :: (a -> b) -> f a -> f b class (Functor f) => Applicative f where pure :: a -> f a (<*>) :: f (a -> b) -> f a -> f b instance Functor ((->) a) where fmap = b instance Applicative ((->) a) where pure = k (<*>) = s class (Applicative f) => Monad f where join :: f (f a) -> f a instance Monad ((->) a) where join = w (.:) :: (b -> c) -> (a1 -> a2 -> b) -> a1 -> a2 -> c (.:) = b b b (>>=) :: (Monad f) => f a -> (a -> f b) -> f b (>>=) = join .: c fmap -- f >>= g = join (fmap g f)