Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $> cat print.sml
- fun printList ls =
- print ("[" ^ String.concatWith ", " ls ^ "]\n");
- $> cat stack.sml
- signature Stack =
- sig
- type α Stack
- val empty : α Stack
- val isEmpty : α Stack → bool
- val cons : α × α Stack → α Stack
- val head : α Stack → α
- val tail : α Stack → α Stack
- end
- structure List : Stack =
- stack
- type α Stack = α list
- val empty = []
- fun isEmpty s = null s
- fun cons (x,s) = x ∷ s
- fun head s = hd s
- fun tail s = tl s
- end
- $> cat stack-example.sml
- use "stack.sml";
- use "print.sml";
- printList (tail [1,2,3]);
- ----------------------------------------
- $> mlton stack-example.sml
- Error: stack-example.sml 1.1.
- Undefined variable use.
- Warning: <bogus>.
- Unable to locally determine type of variable: it.
- type: ???
- in: val it = use "stack.sml"
- Error: stack-example.sml 2.1.
- Undefined variable use.
- Warning: <bogus>.
- Unable to locally determine type of variable: it.
- type: ???
- in: val it = use "print.sml"
- Error: stack-example.sml 3.1.
- Undefined variable printList.
- Error: stack-example.sml 3.12.
- Undefined variable tail.
- Warning: <bogus>.
- Unable to locally determine type of variable: it.
- type: ???
- in: val it = printList (tail [1, 2, 3])
- compilation aborted: parseAndElaborate reported errors
Advertisement
Add Comment
Please, Sign In to add comment