-
-
Save Gbury/0a2f8d88f58d5424ea4b4b1aca35c287 to your computer and use it in GitHub Desktop.
This file contains 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 _ t = | |
| Bar : 'a -> 'a t | |
| Foo : 'a list t -> 'a t | |
let rec f : type a. a t -> a = function | |
| Bar y -> y | |
| Foo y -> | |
begin match f y with | |
| [] -> assert false | |
| h :: r -> h | |
end | |
let rec f (type a) (x: a t) : a = | |
match x with | |
| Bar y -> y | |
| Foo y -> | |
begin match f y with | |
| [] -> assert false | |
| h :: r -> h | |
end | |
(* | |
File "gadt.ml", line 17, characters 18-19: | |
10 | begin match f y with | |
^ | |
Error: This expression has type a list t | |
but an expression was expected of type 'a | |
The type constructor a would escape its scope | |
*) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment