Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
POTTIER Francois
menhir
Commits
7cd31e1d
Commit
7cd31e1d
authored
Dec 01, 2017
by
POTTIER Francois
Browse files
Introduce the type [ground_sort] and the functions [ground] and [unground].
parent
ade16d61
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/SortUnification.ml
View file @
7cd31e1d
...
...
@@ -44,6 +44,9 @@ type sort = term =
|
TVar
of
int
|
TNode
of
sort
structure
type
ground_sort
=
|
GArrow
of
ground_sort
list
(* -------------------------------------------------------------------------- *)
(* Sort constructors. *)
...
...
@@ -68,6 +71,21 @@ let domain (x : variable) : variable list option =
(* -------------------------------------------------------------------------- *)
(* Converting between sorts and ground sorts. *)
let
rec
ground
(
s
:
sort
)
:
ground_sort
=
match
s
with
|
TVar
_
->
(* All variables are replaced with [*]. *)
GArrow
[]
|
TNode
(
Arrow
ss
)
->
GArrow
(
List
.
map
ground
ss
)
let
rec
unground
(
GArrow
ss
:
ground_sort
)
:
sort
=
TNode
(
Arrow
(
List
.
map
unground
ss
))
(* -------------------------------------------------------------------------- *)
(* A name generator for unification variables. *)
let
make_gensym
()
:
unit
->
string
=
...
...
src/SortUnification.mli
View file @
7cd31e1d
...
...
@@ -16,6 +16,9 @@ type sort =
|
TVar
of
int
|
TNode
of
sort
structure
type
ground_sort
=
|
GArrow
of
ground_sort
list
(* -------------------------------------------------------------------------- *)
(* Sort unification. *)
...
...
@@ -39,6 +42,11 @@ val unify: variable -> variable -> unit
val
decode
:
variable
->
sort
(* Grounding a sort replaces all sort variables with the sort [*]. *)
val
ground
:
sort
->
ground_sort
val
unground
:
ground_sort
->
sort
(* -------------------------------------------------------------------------- *)
(* A sort can be printed. *)
...
...
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