Skip to content

Instantly share code, notes, and snippets.

@tonymorris
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save tonymorris/8817298 to your computer and use it in GitHub Desktop.

Select an option

Save tonymorris/8817298 to your computer and use it in GitHub Desktop.
The composition law of Apply
{-# LANGUAGE NoImplicitPrelude #-}
import Prelude(Eq(..), Bool, (.))
class Functor f where
(<$>) ::
(a -> b)
-> f a
-> f b
class Functor f => Apply f where
(<*>) ::
f (a -> b)
-> f a
-> f b
composition ::
(Eq (f c), Apply f) =>
f (b -> c)
-> f (a -> b)
-> f a
-> Bool
composition fbc fab fa =
(fbc <*> (fab <*> fa)) ==
((((.) <$> fbc) <*> fab) <*> fa)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment