Guest User

Untitled

a guest
Feb 23rd, 2015
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.92 KB | None | 0 0
  1. let getTypeOf argument = match argument with
  2.   | (Variable(_) | Anonymous) -> Any
  3.   | Set(_) -> Set
  4.   | Integer(_) -> Int
  5.   | String(_) -> String
  6.   | Identifier(_) -> Identifier;;
  7.  
  8.  
  9. (* just need to verify the parameters, really. *)
  10. let rec verifyPredArgs args =
  11.   let verifyPredArg arg = match arg with Argument(ty, var) ->
  12.     (let varType = getTypeOf var in
  13.       (match ty with
  14.         | "Set" -> (match varType with
  15.           | (Any | Set) -> true
  16.           | _ as errType -> false)
  17.         | "Int" -> (match varType with
  18.           | (Any | Int) -> true
  19.           | _ as errType -> false)
  20.         | "String" -> (match varType with
  21.           | (Any | String) -> true
  22.           | _ as errType -> false)
  23.         | _ as errType -> (* error! *) false
  24.       )
  25.     )
  26.   in
  27.     match args with
  28.       | SingleArgument(ar) -> verifyPredArg ar
  29.       | AnotherArgument(ar, more) -> verifyPredArg ar ; verifyPredArgs more;;
Advertisement
Add Comment
Please, Sign In to add comment