Skip to content

Instantly share code, notes, and snippets.

@Octachron
Created March 19, 2021 07:52
Show Gist options
  • Save Octachron/916d307c4a4ea031e3b795b0cc0a361e to your computer and use it in GitHub Desktop.
Save Octachron/916d307c4a4ea031e3b795b0cc0a361e to your computer and use it in GitHub Desktop.
How to temporarily hide a type
type _ foo = F1: int foo | F2: boo foo
type 'b any = Any: 'a foo * ('a,'b) eq -> 'b any
let split x = Any(x,Refl)
let g (type tmp) (): int =
let Any (type t) (foo,secret: t foo * (t,_) eq ) = split F1 in
let tmp: t = match foo with F1 -> 0 | F2 -> true in
match secret with Refl -> tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment