Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Hector Suzanne
autobill
Commits
fc3d45b3
Commit
fc3d45b3
authored
Sep 05, 2022
by
Hector Suzanne
Browse files
Eta-réduction des binds
parent
169ffb5a
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/Reduction/normalForm.ml
View file @
fc3d45b3
...
...
@@ -13,7 +13,7 @@ let rec val_nf prog v = match v with
|
CoTop
->
CoTop
|
Bindcc
{
bind
;
pol
;
cmd
}
->
let
prog'
=
cmd_nf
{
prog
with
cont
=
[]
;
curr
=
cmd
}
in
Bindcc
{
bind
;
pol
;
cmd
=
prog'
.
curr
}
eta_reduce_bindcc
(
Bindcc
{
bind
;
pol
;
cmd
=
prog'
.
curr
}
)
|
Box
{
bind
;
kind
;
cmd
}
->
let
prog'
=
cmd_nf
{
prog
with
cont
=
[]
;
curr
=
cmd
}
in
Box
{
bind
;
kind
;
cmd
=
prog'
.
curr
}
...
...
@@ -39,7 +39,7 @@ and stack_nf prog stk = match stk with
cmd_nf
{
prog
with
curr
=
cmd
;
declared
=
Var
.
Env
.
add
(
fst
bind
)
()
prog
.
declared
}
in
CoBind
{
bind
;
pol
;
cmd
=
prog'
.
curr
}
eta_reduce_bind
(
CoBind
{
bind
;
pol
;
cmd
=
prog'
.
curr
}
)
|
CoBox
{
kind
;
stk
}
->
CoBox
{
kind
;
stk
=
metastack_nf
prog
stk
}
|
CoDestr
destr
->
CoDestr
(
destr_nf
prog
destr
)
|
CoCons
patts
->
CoCons
(
List
.
map
(
patt_nf
prog
)
patts
)
...
...
@@ -100,6 +100,24 @@ and cmd_nf prog =
prog
and
eta_reduce_bindcc
valu
=
match
valu
with
|
Bindcc
{
cmd
=
Command
cmd
;
_
}
->
begin
match
cmd
.
stk
with
|
MetaStack
{
node
=
Ret
;
_
}
->
let
MetaVal
v
=
cmd
.
valu
in
v
.
node
|
_
->
valu
end
|
_
->
valu
and
eta_reduce_bind
stk
=
match
stk
with
|
CoBind
{
bind
=
(
x
,_
);
cmd
=
Command
cmd
;
_
}
->
begin
match
cmd
.
valu
with
|
MetaVal
{
node
=
Var
y
;
_
}
->
if
x
=
y
then
let
MetaStack
s
=
cmd
.
stk
in
s
.
node
else
stk
|
_
->
stk
end
|
_
->
stk
and
replace_ret_with_cont
prog
=
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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