Skip to content

Instantly share code, notes, and snippets.

@emilypi
Created January 14, 2021 07:34
Show Gist options
  • Save emilypi/505e4c1a5b630e57eb668faf702683c9 to your computer and use it in GitHub Desktop.
Save emilypi/505e4c1a5b630e57eb668faf702683c9 to your computer and use it in GitHub Desktop.
-- monoids
type Unit = ()
type a × b = (a,b)
type a → b = (->)
class Monoid a where
mempty :: Unit → a
mappend :: a × a → a
-- Applicatives
data Day f g where
Day :: (x -> y -> a) -> f x -> g y -> Day f g a
type Unit = Identity
type f × g = Day f g
type f → g = forall a. f a -> g a
class Applicative f where
mempty :: Unit → f
mappend :: f × f → f
-- Monoids
data Compose f g a = Compose (f (g a))
type Unit = Identity
type f × g = Compose f g
type f → g = forall a. f a -> g a
class Monad f where
mempty :: Unit → f
mappend :: f × f → f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment