Commit 962d1c80 authored by Pietro Abate's avatar Pietro Abate

Add new ternary trees to store variables.

parent cbc5ac98
......@@ -135,11 +135,7 @@ module List(X : T) = struct
| _ -> 1
end
module Pair(X : T)(Y : T) = struct
module Fst = X
module Snd = Y
type t = X.t * Y.t
let dump ppf (x,y) = Format.fprintf ppf "(%a,%a)" X.dump x Y.dump y
let check (x,y) = X.check x; Y.check y
......@@ -174,3 +170,21 @@ module Sum(X : T)(Y : T) = struct
| Right t -> Format.fprintf ppf "R%a" Y.dump t
end
type 'a pairvar = Atm of 'a | Var of String.t
module Var (X : T) = struct
type t = X.t pairvar
let hash = function Atm t -> X.hash t | Var s -> String.hash s
let check = function Atm t -> X.check t | Var _ -> ()
let compare t1 t2 =
match t1,t2 with
|Atm x, Atm y -> X.compare x y
|Var x, Var y -> String.compare x y
|Var _, Atm _ -> -1
|Atm _, Var _ -> 1
let equal t1 t2 = (compare t1 t2) = 0
let dump ppf = function
|Atm x -> X.dump ppf x
|Var x -> String.dump ppf x
end
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment