Created
June 22, 2015 16:36
-
-
Save david-christiansen/46d9b8dddb41ef98ef6d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
data HList : List Type -> Type where | |
Nil : HList [] | |
(::) : t -> HList ts -> HList (t :: ts) | |
%name HList xs,ys | |
append : HList ts -> HList ts' -> HList (ts ++ ts') | |
append [] ys = ys | |
append (x :: xs) ys = x :: append xs ys | |
-------------------------------- | |
data Column = TEXT | REAL | INTEGER | |
Table : Type | |
Table = List (String, Column) | |
interpCol : Column -> Type | |
interpCol TEXT = String | |
interpCol REAL = Double | |
interpCol INTEGER = Integer | |
interp : Table -> Type | |
interp schema = HList (map (interpCol . snd) schema) | |
PeopleSchema : Table | |
PeopleSchema = [("Name", TEXT), ("Hamsters", INTEGER)] | |
People : List (interp PeopleSchema) | |
People = [["David", 1], ["Edwin", 0]] | |
total | |
countHamsters : List (interp PeopleSchema) -> Integer | |
countHamsters [] = 0 | |
countHamsters ([_, h] :: xs) = h + countHamsters xs | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment