Last active
November 3, 2015 19:58
-
-
Save j0sh/de6f84ed6ed42a6bc6cf to your computer and use it in GitHub Desktop.
gadt in 'guard' like pattern branch
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
| File "test.ml", line 17, characters 13-32: | |
| Error: This pattern matches values of type int prim expr | |
| but a pattern was expected which matches values of type a#0 expr | |
| Type int prim is not compatible with type a#0 |
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
| type _ prim = | |
| | TS : string -> int64 prim | |
| | Str : string -> string prim | |
| | Int : string -> int prim | |
| type _ expr = | |
| | Val : 'a prim -> 'a prim expr | |
| | Expr : string * 'a expr * 'b expr -> 'c expr | |
| let rec all : type x . x prim -> string = function | |
| | TS s -> s | |
| | Str s -> s | |
| | Int s -> s | |
| let rec expr : type x . x expr -> string = function | |
| | Val x -> all x | |
| | Expr (s, (y : int prim expr), z) -> "guarded" | |
| | Expr (s, y, z) -> Printf.sprintf "%s -- %s -- %s" s (expr y) (expr z) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment