Skip to content

Instantly share code, notes, and snippets.

@canonic-epicure
Created May 10, 2018 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save canonic-epicure/f42dd2204fe87054b831cabee810b3c3 to your computer and use it in GitHub Desktop.
Save canonic-epicure/f42dd2204fe87054b831cabee810b3c3 to your computer and use it in GitHub Desktop.
module Algebra
data ExprF : (carrier : Type) -> Type where
Const : Int -> ExprF carrier
Add : (a : carrier) -> (b : carrier) -> ExprF carrier
Mul : (a : carrier) -> (b : carrier) -> ExprF carrier
data Fix : (f : Type -> Type) -> Type where
In : f (Fix f) -> Fix f
implementation Functor ExprF where
map func (Const int) = Const int
map func (Add x y) = Add (func x) (func y)
map func (Mul x y) = Mul (func x) (func y)
Expr : Type
Expr = Fix ExprF
Algebra : Functor f => (f : Type -> Type) -> (carrier : Type) -> Type
Algebra f carrier = f carrier -> carrier
my : Type
my = Algebra ExprF Int
{-
Errors (1)
/home/nickolay/workspace/Idris/horn/src/Test4.idr:24:6
When checking right hand side of my with expected type
Type
Can't find implementation for Functor f
-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment