Last active
December 26, 2015 12:49
-
-
Save Eckankar/7154312 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
| signature LIST = | |
| sig | |
| type t | |
| val toList : t list | |
| val head : t option | |
| (* structure Tail : LIST *) | |
| val empty : bool | |
| end | |
| functor Nil(E : sig type e end) = | |
| struct | |
| type t = E.e | |
| val toList = [] | |
| val head = NONE | |
| structure Tail = struct type e = E.e end | |
| val empty = true | |
| end | |
| functor Cons(E : sig structure Tail : LIST | |
| val x : Tail.t end) = | |
| struct | |
| type t = E.Tail.t | |
| val toList = E.x :: E.Tail.toList | |
| val head = SOME E.x | |
| structure Tail = E.Tail | |
| val empty = false | |
| end | |
| structure Xs = Cons(struct val x = 5 | |
| structure Tail = | |
| Cons(struct val x = 19 | |
| structure Tail = | |
| Cons(struct val x = 27 | |
| structure Tail = | |
| Nil(struct | |
| type e = int | |
| end) | |
| end) | |
| end) | |
| end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment