bkerby

Untitled

Sep 8th, 2012
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 1.34 KB | None | 0 0
  1. $> cat print.sml
  2. fun printList ls =
  3.   print ("[" ^ String.concatWith ", " ls ^ "]\n");
  4.  
  5. $> cat stack.sml
  6. signature Stack =
  7. sig
  8.     type α Stack
  9.  
  10.     val empty   : α Stack
  11.     val isEmpty : α Stackbool
  12.  
  13.     val cons    : α × α Stack → α Stack
  14.     val head    : α Stack → α
  15.     val tail    : α Stack → α Stack
  16. end
  17.  
  18. structure List : Stack =
  19. stack
  20.   type α Stack = α list
  21.  
  22.   val empty = []
  23.   fun isEmpty s = null s
  24.  
  25.   fun cons (x,s) = x ∷ s
  26.   fun head s = hd s
  27.   fun tail s = tl s
  28. end
  29.  
  30. $> cat stack-example.sml
  31. use "stack.sml";
  32. use "print.sml";
  33. printList (tail [1,2,3]);
  34.  
  35. ----------------------------------------
  36. $> mlton stack-example.sml
  37. Error: stack-example.sml 1.1.
  38.   Undefined variable use.
  39. Warning: <bogus>.
  40.   Unable to locally determine type of variable: it.
  41.     type: ???
  42.     in: val it = use "stack.sml"
  43. Error: stack-example.sml 2.1.
  44.   Undefined variable use.
  45. Warning: <bogus>.
  46.   Unable to locally determine type of variable: it.
  47.     type: ???
  48.     in: val it = use "print.sml"
  49. Error: stack-example.sml 3.1.
  50.   Undefined variable printList.
  51. Error: stack-example.sml 3.12.
  52.   Undefined variable tail.
  53. Warning: <bogus>.
  54.   Unable to locally determine type of variable: it.
  55.     type: ???
  56.     in: val it = printList (tail [1, 2, 3])
  57. compilation aborted: parseAndElaborate reported errors
Advertisement
Add Comment
Please, Sign In to add comment