Skip to content

Instantly share code, notes, and snippets.

@david-christiansen
Created April 15, 2015 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save david-christiansen/5fab089b2ccb41afd7dc to your computer and use it in GitHub Desktop.
Save david-christiansen/5fab089b2ccb41afd7dc to your computer and use it in GitHub Desktop.
module VeryFun
class VeryFun (f : Type -> Type) (dict : Functor f) | f where
funIdentity : {a : Type} -> (x : f a) ->
map @{dict} id x = id x
funComposition : {a : Type} -> {b : Type} ->
(x : f a) -> (g1 : a -> b) -> (g2 : b -> c) ->
map @{dict} (g2 . g1) x = (map @{dict} g2 . map @{dict} g1) x
instance VeryFun List %instance where
funIdentity [] = Refl
funIdentity (x :: xs) = cong $ funIdentity xs
funComposition [] g1 g2 = Refl
funComposition (x :: xs) g1 g2 = cong $ funComposition xs g1 g2
test : (xs : List Nat) -> map ((+1) . (+2)) xs = map (+1) (map (+2) xs)
test xs = funComposition xs (+2) (+1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment