Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sgdt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
gradual-typing
sgdt
Commits
f0a4061b
Commit
f0a4061b
authored
6 years ago
by
Max New
Browse files
Options
Downloads
Patches
Plain Diff
[code] add impl of elim complex values using delimited continuations
parent
3878b2c5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
code/elim-complex-values.rkt
+70
-0
70 additions, 0 deletions
code/elim-complex-values.rkt
with
70 additions
and
0 deletions
code/elim-complex-values.rkt
0 → 100644
+
70
−
0
View file @
f0a4061b
#
lang
racket
(
require
racket/control
)
;; Eliminating complex values using delimited control
(
define
(
celim-val
v
)
(
match
v
[(
?
symbol?
x
)
x
]
[(
list
'cons
car
cdr
)
(
list
'cons
(
celim-val
car
)
(
celim-val
cdr
))]
[(
list
'split
discrim
(
list
'cons
x1
x2
)
kv
)
(
control
k
(
list
'split
(
celim-val
discrim
)
(
list
'cons
x1
x2
)
(
%
(
k
(
celim-val
kv
)))))]
[(
list
'nil
)
(
list
'nil
)]
[(
list
'split
discrim
(
list
'nil
)
kv
)
(
control
k
(
list
'split
(
celim-val
discrim
)
(
list
'nil
)
(
%
(
k
(
celim-val
kv
)))))]
[(
list
(
?
injection?
in
)
v
)
(
list
in
(
celim-val
v
))]
[
`
(
case
,
discrim
[(
inl
,
xl
)
,
kvl
]
[(
inr
,
xr
)
,
kvr
])
(
control
k
`
(
case
,
(
celim-val
discrim
)
[(
inl
,
xl
)
,
(
%
(
k
(
celim-val
kvl
)))]
[(
inr
,
xr
)
,
(
%
(
k
(
celim-val
kvr
)))]))]
[
`
(
case
,
discrim
)
(
control
k
`
(
case
,
(
celim-val
discrim
)))]
[(
list
'thunk
t
)
(
list
'thunk
(
celim-term
))]
[(
list
'let
(
?
symbol?
x
)
v1
v2
)
(
control
k
(
list
'let
x
(
list
'ret
(
celim-val
v1
))
(
%
(
k
(
celim-val
v2
)))))]))
(
define
(
celim-term
t
)
(
match
t
[(
list
'ret
v
)
(
list
'ret
(
celim-val
v
))]
[(
list
'let
x
t1
t2
)
(
list
'let
x
(
celim-term
t1
)
(
%
(
celim-term
t2
)))]
[(
list
'split
discrim
(
list
'cons
x1
x2
)
kt
)
(
list
'split
(
celim-val
discrim
)
(
list
'cons
x1
x2
)
(
%
(
celim-term
kt
)))]
[(
list
'split
discrim
(
list
'nil
)
kt
)
(
list
'split
(
celim-val
discrim
)
(
list
'nil
)
(
%
(
celim-term
kt
)))]
[
`
(
case
,
discrim
[(
inl
,
xl
)
,
ktl
]
[(
inr
,
xr
)
,
ktr
])
`
(
case
,
(
celim-val
discrim
)
[(
inl
,
xl
)
,
(
%
(
celim-term
ktl
))]
[(
inr
,
xr
)
,
(
%
(
celim-term
ktr
))])]
[
`
(
case
,
discrim
)
`
(
case
,
(
celim-val
discrim
))]
[
`
(
force
,
v
)
`
(
force
,
(
celim-val
v
))]
[
`
(
λ
,
x
,
t
)
`
(
λ
,
x
,
(
%
(
celim-term
t
)))]
[
`
(
app
,
t
,
v
)
`
(
app
,
(
celim-term
t
)
,
(
celim-val
v
))]
[
`
(
copat
[
fst
,
t1
]
[
snd
,
t2
])
`
(
copat
[
fst
,
(
celim-term
t1
)]
[
snd
,
(
celim-term
t2
)])]
[(
list
(
?
projection?
p
)
t
)
(
list
p
(
celim-term
t
))]
[
`
(
copat
)
`
(
copat
)]))
(
define
(
injection?
x
)
(
or
(
symbol=?
x
'inl
)
(
symbol=?
x
'inr
)))
(
define
(
projection?
x
)
(
or
(
symbol=?
x
'fst
)
(
symbol=?
x
'snd
)))
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment