Skip to content

Instantly share code, notes, and snippets.

@ion1
Created March 4, 2012 21:54
Show Gist options
  • Save ion1/1974979 to your computer and use it in GitHub Desktop.
Save ion1/1974979 to your computer and use it in GitHub Desktop.
A toy category instance for monoids
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
import Overture
import Prelude ()
data Foo m a b where
Foo :: m -> Foo m a a
instance Show m => Show (Foo m a a) where
showsPrec p (Foo a) = showParen (p > appP)
$ showString "Foo " . showsPrec (appP+1) a
where appP = 10
instance Monoid m => Category (Foo m) where
id = Foo mempty
Foo a . Foo b = Foo (a `mappend` b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment