Skip to content

Instantly share code, notes, and snippets.

@puffnfresh
Last active December 30, 2015 10:29
Show Gist options
  • Save puffnfresh/7815838 to your computer and use it in GitHub Desktop.
Save puffnfresh/7815838 to your computer and use it in GitHub Desktop.
Default superclass instances in Idris.
module DefaultSuperclass
data Identity' i = Id' i
class Functor' (f : Type -> Type) where
map' : (a -> b) -> f a -> f b
class Functor' f => Applicative' (f : Type -> Type) where
instance Functor' f where
map' = ap' . pure'
pure' : a -> f a
ap' : f (a -> b) -> f a -> f b
instance Applicative' Identity' where
pure' = Id'
ap' (Id' f) (Id' a) = Id' (f a)
inc : Int -> Int
inc a = a + 1
x : Identity' Int
x = map' inc (Id' 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment