Created
April 25, 2021 01:44
-
-
Save ytomino/097b4ded22783dcda9be8682d4cb7c67 to your computer and use it in GitHub Desktop.
GADTの型パラメータをObj.magicで一致させることで無関係な後続の式の型チェックを回避できる
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
module type T1 = sig | |
type t (* any abstract type *) | |
val one: t | |
end;; | |
module M1: T1 = Int;; | |
type 'a repr = C1: M1.t repr (* GADT is needed *) | |
let one: string = | |
let C1 = (Obj.magic C1: string repr) in (* force M1.t = string *) | |
M1.one;; (* !!! *) | |
print_string one;; (* segmentation fault *) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment