Skip to content

Instantly share code, notes, and snippets.

@Akii
Created June 12, 2017 17:36
Show Gist options
  • Select an option

  • Save Akii/3393909ed3b0e3c5b3a36b0fd5ac3845 to your computer and use it in GitHub Desktop.

Select an option

Save Akii/3393909ed3b0e3c5b3a36b0fd5ac3845 to your computer and use it in GitHub Desktop.
data Const k a = Const k
deriving (Eq, Show)
instance Functor (Const k) where
fmap _ (Const k) = Const k
instance Monoid k => Applicative (Const k) where
pure = const (Const mempty)
_ <*> Const k = Const k
instance Monoid k => Monad (Const k) where
return = pure
Const k >>= _ = Const k
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment