Created
March 4, 2012 21:54
-
-
Save ion1/1974979 to your computer and use it in GitHub Desktop.
A toy category instance for monoids
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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