Advertisement
Guest User

Untitled

a guest
Aug 9th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.74 KB | None | 0 0
  1. open Sexplib
  2. open Sexplib.Std
  3.  
  4. module type Tish = sig
  5.         type a
  6. end
  7.  
  8. module MakeAst (T : Tish) = struct
  9.         type a = T.a
  10.  
  11.         type t =
  12.                 | Int of (a * int)
  13.                 | Add of (a * t * t)
  14. end
  15.  
  16.  
  17. module Pass = struct
  18.         type t
  19.  
  20.         type a =
  21.                 | Unknown
  22.                 | Variable of t
  23. end
  24.  
  25. module AstPass = MakeAst(Pass)
  26.  
  27. let x = AstPass.Int (Unknown, 20)
  28.  
  29. let y = AstPass.Int (Variable (Pass.Int (Unknown, 24)), 24)
  30. (* 29 | let y = AstPass.Int (Variable (AstPass.Int (Unknown, 24)), 24)
  31.  *                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  32.  * Error: This expression has type AstPass.t
  33.  *      but an expression was expected of type Pass.t
  34.  *)
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement