Skip to content

Instantly share code, notes, and snippets.

@EduardoRFS
Created December 26, 2021 00:00
Show Gist options
  • Save EduardoRFS/8694a5cf5e737355e4ed76efe873fed9 to your computer and use it in GitHub Desktop.
Save EduardoRFS/8694a5cf5e737355e4ed76efe873fed9 to your computer and use it in GitHub Desktop.
type _ bool =
| T : ('a -> 'b -> 'a) bool
| F : ('a -> 'b -> 'b) bool
type ('a, 'b) eq = Eq : ('a, 'a) eq
let not_ (type a b c x) (x : (a -> b -> c) bool) : (b -> a -> c) bool =
match x with
| T -> F
| F -> T
let not_t () = not_ T
let not_f () = not_ F
let and_ (type t y a b x) (x : (y -> (a -> b -> b) -> t) bool) (y : y bool) :
t bool =
match x with
| T -> y
| F -> F
let and_t_t () = and_ T T
let and_t_f () = and_ T F
let and_f_t () = and_ F T
let and_f_f () = and_ F F
let or_ (type t y a b c) (x : ((a -> b -> a) -> y -> t) bool) (y : y bool) :
t bool =
match x with
| T -> T
| F -> y
let or_t_t () = or_ T T
let or_t_f () = or_ T F
let or_f_t () = or_ F T
let or_f_f () = or_ F F
let xor_ (type t y a b c) (x : ((b -> a -> c) -> (a -> b -> c) -> t) bool)
(y : (a -> b -> c) bool) : t bool =
match x with
| T -> not_ y
| F -> y
let xor_t_t () = xor_ T T
let xor_t_f () = xor_ T F
let xor_f_t () = xor_ F T
let xor_f_f () = xor_ F F
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment