Created
June 6, 2014 23:54
-
-
Save jroesch/31c311bcb28711d3ee2a to your computer and use it in GitHub Desktop.
HList in Idris
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
using (x : Type, P : x -> Type) | |
data HList : (P : x -> Type) -> List x -> Type where | |
Nil : HList P [] | |
(::) : {head : x} -> {tail : List x} -> P head -> HList P tail -> HList P (head :: tail) | |
head : {h : ty} -> {t : List ty} -> {P : ty -> Type} -> HList P (h :: t) -> P h | |
head (h :: _) = h | |
tail : {h : ty} -> {t : List ty} -> {P : ty -> Type} -> HList P (h :: t) -> HList P t | |
tail (_ :: t) = t | |
tupleHList : HList (\x : Type => (x, x)) [Nat] | |
tupleHList = (1,1) :: Nil | |
example : (Nat, Nat) | |
example = head tupleHList |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment