Skip to content

Instantly share code, notes, and snippets.

@jonsterling
Last active December 27, 2015 21:59
Show Gist options
  • Save jonsterling/7395544 to your computer and use it in GitHub Desktop.
Save jonsterling/7395544 to your computer and use it in GitHub Desktop.
I think this suffices for the empty type in OCaml, but I'm not certain.
module type TYPE = sig
type t
end
module type EMPTY = functor (T : TYPE) -> sig
val apply : T.t
end
type empty = (module EMPTY)
(* Absurdity *)
let rec (!) (e : empty) : 'a = ! e
@paurkedal
Copy link

I was going to use type abstraction along with assert false to achieve the same, but though I'd do a quick search first, and found your Gist.

I think it holds as far as OCaml goes, but a logical purist might point out that "let rec" is itself unsound. I propose the alternative:

type t = {elim_empty : 'a. 'a}
let (!) {elim_empty} = elim_empty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment