Created
September 1, 2017 17:08
-
-
Save Gozala/84c779974362889ab6e192279f4c6711 to your computer and use it in GitHub Desktop.
HList in Elm
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
module HList exposing (HList, cons, nil first rest) | |
type HList x xs | |
= Nil | |
| Cons x xs | |
nil = Nil | |
cons : x1 -> HList x2 xs -> HList x1 (HList x2 xs) | |
cons head tail = | |
Cons head tail | |
first : HList head tail -> Maybe head | |
first hlist = | |
case hlist of | |
Nil -> | |
Nothing | |
Cons head tail -> | |
Just head | |
rest : HList head tail -> Maybe tail | |
rest hlist = | |
case hlist of | |
Nil -> | |
Nothing | |
Cons head tail -> | |
Just tail | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment