Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cduce
cduce
Commits
4696df52
Commit
4696df52
authored
Jun 28, 2014
by
Pietro Abate
Browse files
Use sortedlist for Var.Set to be able to hash properly
parent
eed3f263
Changes
2
Hide whitespace changes
Inline
Side-by-side
types/var.ml
View file @
4696df52
...
...
@@ -16,15 +16,18 @@ module V = struct
end
type
var
=
[
`Var
of
V
.
t
]
type
t
=
var
module
VAR
=
struct
type
t
=
var
let
dump
ppf
(
`Var
x
)
=
Format
.
fprintf
ppf
"%a"
V
.
dump
x
let
compare
(
`Var
x
)
(
`Var
y
)
=
V
.
compare
x
y
let
equal
v1
v2
=
(
compare
v1
v2
)
=
0
let
hash
(
`Var
x
)
=
V
.
hash
x
let
check
_
=
()
end
include
VAR
let
id
(
`Var
x
)
=
x
.
V
.
id
let
dump
ppf
(
`Var
x
)
=
Format
.
fprintf
ppf
"%a"
V
.
dump
x
let
pp
ppf
(
`Var
x
)
=
Format
.
fprintf
ppf
"'%s"
x
.
V
.
repr
let
compare
(
`Var
x
)
(
`Var
y
)
=
V
.
compare
x
y
let
equal
v1
v2
=
(
compare
v1
v2
)
=
0
let
hash
(
`Var
x
)
=
V
.
hash
x
let
check
_
=
()
let
mk
?
repr
id
=
`Var
(
V
.
make_id
?
repr
id
)
let
fresh
:
?
pre
:
string
->
unit
->
[
>
var
]
=
...
...
@@ -37,12 +40,14 @@ let fresh : ?pre: string -> unit -> [> var ] =
;;
module
Set
=
struct
include
S
et
.
Make
(
struct
type
t
=
var
let
compare
=
compare
end
)
let
dump
ppf
s
=
Utils
.
pp_list
~
sep
:
";"
~
delim
:
(
"{"
,
"}"
)
dump
ppf
(
elements
s
)
let
pp
ppf
s
=
Utils
.
pp_list
~
sep
:
";"
~
delim
:
(
"{"
,
"}"
)
pp
ppf
(
elements
s
)
include
S
ortedList
.
Make
(
VAR
)
let
dump
ppf
s
=
Utils
.
pp_list
~
sep
:
";"
~
delim
:
(
"{"
,
"}"
)
VAR
.
dump
ppf
(
get
s
)
let
pp
ppf
s
=
Utils
.
pp_list
~
sep
:
";"
~
delim
:
(
"{"
,
"}"
)
pp
ppf
(
get
s
)
let
printf
=
pp
Format
.
std_formatter
let
is_empty
s
=
equal
s
empty
let
from_list
l
=
List
.
fold_left
(
fun
acc
x
->
add
x
acc
)
empty
l
let
union
=
cup
let
inter
=
cap
let
cardinal
=
length
let
mem
t
v
=
mem
v
t
end
type
'
a
pairvar
=
[
`Atm
of
'
a
|
var
]
...
...
types/var.mli
View file @
4696df52
...
...
@@ -13,12 +13,21 @@ val fresh : ?pre:string -> unit -> var
val
id
:
var
->
string
module
Set
:
sig
include
Set
.
S
with
type
elt
=
var
type
t
val
dump
:
Format
.
formatter
->
t
->
unit
val
pp
:
Format
.
formatter
->
t
->
unit
val
printf
:
t
->
unit
val
is_empty
:
t
->
bool
val
from_list
:
elt
list
->
t
val
empty
:
t
val
singleton
:
var
->
t
val
union
:
t
->
t
->
t
val
diff
:
t
->
t
->
t
val
mem
:
var
->
t
->
bool
val
add
:
var
->
t
->
t
val
inter
:
t
->
t
->
t
val
subset
:
t
->
t
->
bool
val
cardinal
:
t
->
int
val
from_list
:
var
list
->
t
end
type
'
a
pairvar
=
[
`Atm
of
'
a
|
var
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment