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
bc96cafb
Commit
bc96cafb
authored
Oct 05, 2007
by
Pietro Abate
Browse files
[r2004-12-23 00:33:43 by afrisch] comments
Original author: afrisch Date: 2004-12-23 00:33:43+00:00
parent
41949d9f
Changes
1
Hide whitespace changes
Inline
Side-by-side
types/patterns.ml
View file @
bc96cafb
...
...
@@ -1658,6 +1658,28 @@ x=(1,2)
|
TConj
of
Types
.
t
*
fv
*
(
'
a
,
'
b
)
t
*
(
'
a
,
'
b
)
t
|
TOther
of
descr
*
Types
.
t
*
fv
*
'
b
let
capt
pr
p
=
if
IdMap
.
is_empty
pr
then
p
else
match
p
with
|
TCapt
(
pr2
,
p
)
->
TCapt
(
TargExpr
.
merge
pr
pr2
,
p
)
|
TFail
->
TFail
|
p
->
TCapt
(
pr
,
p
)
let
rec
conj
a1
fv1
r1
r2
=
match
(
r1
,
r2
)
with
|
TSucceed
,
r
|
r
,
TSucceed
->
r
|
TFail
,
r
|
r
,
TFail
->
TFail
|
TCapt
(
f
,
r1
)
,
r2
|
r2
,
TCapt
(
f
,
r1
)
->
capt
f
(
conj
a1
fv1
r1
r2
)
|
r1
,
r2
->
TConj
(
a1
,
fv1
,
r1
,
r2
)
let
alt
p
a1
r1
r2
=
match
(
r1
,
r2
)
with
|
TFail
,
r
|
r
,
TFail
->
r
|
TSucceed
,
_
->
assert
false
(* Note: this cannot happen because if the lhs succeeds,
then the rhs must fail (it is evaluated under
the assumption that the lhs fails, so the static
assumption is empty in this case). *)
|
r1
,
r2
->
TAlt
(
p
,
a1
,
r1
,
r2
)
let
get_result
=
function
|
TCapt
(
r
,
TSucceed
)
->
Some
r
|
TFail
->
None
...
...
@@ -1692,23 +1714,6 @@ x=(1,2)
|
Record
(
l
,
q
)
->
oth
(
`Record
(
l
,
q
))
|
Dummy
->
assert
false
let
capt
pr
p
=
if
IdMap
.
is_empty
pr
then
p
else
match
p
with
|
TCapt
(
pr2
,
p
)
->
TCapt
(
TargExpr
.
merge
pr
pr2
,
p
)
|
TFail
->
TFail
|
p
->
TCapt
(
pr
,
p
)
let
rec
conj
a1
fv1
r1
r2
=
match
(
r1
,
r2
)
with
|
TSucceed
,
r
|
r
,
TSucceed
->
r
|
TFail
,
r
|
r
,
TFail
->
TFail
|
TCapt
(
f
,
r1
)
,
r2
|
r2
,
TCapt
(
f
,
r1
)
->
capt
f
(
conj
a1
fv1
r1
r2
)
|
r1
,
r2
->
TConj
(
a1
,
fv1
,
r1
,
r2
)
let
alt
p
a1
r1
r2
=
match
(
r1
,
r2
)
with
|
TFail
,
r
|
r
,
TFail
->
r
|
r1
,
r2
->
TAlt
(
p
,
a1
,
r1
,
r2
)
let
factorize
((
a
,_,_
)
as
p
)
t
xs
f
=
if
Types
.
disjoint
a
t
then
TFail
else
...
...
@@ -1730,6 +1735,10 @@ x=(1,2)
(
fun
xs
->
alt
p
a1
(
optimize
t
xs
p1
)
(
optimize
(
Types
.
diff
t
a1
)
xs
p2
))
|
TConj
(
a1
,
fv1
,
p1
,
p2
)
->
(* We don't factorize above a & pattern eagerly, because
if factorization would occur, it would also
occur below and be lifted by the conj function, which
produces the same effect. *)
conj
a1
fv1
(
optimize
t
(
IdSet
.
cap
xs
fv1
)
p1
)
(
optimize
(
Types
.
cap
t
a1
)
(
IdSet
.
diff
xs
fv1
)
p2
)
...
...
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