Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
digger
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
2xs
digger
Commits
31eaafce
Commit
31eaafce
authored
6 years ago
by
Samuel Hym
Browse files
Options
Downloads
Patches
Plain Diff
Eta-expand bind applications
parent
6276239f
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/digger.hs
+1
-0
1 addition, 0 deletions
app/digger.hs
src/Language/Coq/Deep.hs
+14
-2
14 additions, 2 deletions
src/Language/Coq/Deep.hs
with
15 additions
and
2 deletions
app/digger.hs
+
1
−
0
View file @
31eaafce
...
@@ -158,6 +158,7 @@ optsCP = CP <$> optMonad
...
@@ -158,6 +158,7 @@ optsCP = CP <$> optMonad
<*>
optPrefixVTyp
<*>
optPrefixVTyp
<*>
optRecBound
<*>
optRecBound
<*>
pure
(
prefixTmp
def
)
<*>
pure
(
unaryOps
def
)
<*>
pure
(
unaryOps
def
)
<*>
pure
(
binaryOps
def
)
<*>
pure
(
binaryOps
def
)
...
...
This diff is collapsed.
Click to expand it.
src/Language/Coq/Deep.hs
+
14
−
2
View file @
31eaafce
...
@@ -60,6 +60,7 @@ module Language.Coq.Deep (
...
@@ -60,6 +60,7 @@ module Language.Coq.Deep (
import
Control.Arrow
(
second
,
(
&&&
))
import
Control.Arrow
(
second
,
(
&&&
))
import
Control.Monad.Except
import
Control.Monad.Except
import
Control.Monad.State
import
Data.Default
import
Data.Default
import
Data.Either
(
partitionEithers
)
import
Data.Either
(
partitionEithers
)
import
qualified
Data.Map
as
Map
import
qualified
Data.Map
as
Map
...
@@ -200,6 +201,8 @@ data ConversionParams = CP
...
@@ -200,6 +201,8 @@ data ConversionParams = CP
,
prefixVTyp
::
Text
-- ^ Prefix for value types
,
prefixVTyp
::
Text
-- ^ Prefix for value types
,
recBoundName
::
Name
-- ^ Name of the recursive-bound variable in generated C
,
recBoundName
::
Name
-- ^ Name of the recursive-bound variable in generated C
,
prefixTmp
::
Name
-- ^ Prefix for the names of parameters and local variables
-- that need to be reintroduced by eta-expansion
,
unaryOps
::
Map
.
Map
FId
CUnaryOp
-- ^ Map from Coq functions to C unary operators
,
unaryOps
::
Map
.
Map
FId
CUnaryOp
-- ^ Map from Coq functions to C unary operators
,
binaryOps
::
Map
.
Map
FId
CBinaryOp
-- ^ Map from Coq functions to C binary operators
,
binaryOps
::
Map
.
Map
FId
CBinaryOp
-- ^ Map from Coq functions to C binary operators
}
}
...
@@ -224,6 +227,7 @@ instance Default ConversionParams where
...
@@ -224,6 +227,7 @@ instance Default ConversionParams where
,
prefixVTyp
=
"deepVTyp_"
,
prefixVTyp
=
"deepVTyp_"
,
recBoundName
=
"rec_bound"
,
recBoundName
=
"rec_bound"
,
prefixTmp
=
"digger_tmp_"
,
unaryOps
=
Map
.
fromList
[(
"negb"
,
CNegOp
)]
,
unaryOps
=
Map
.
fromList
[(
"negb"
,
CNegOp
)]
,
binaryOps
=
Map
.
fromList
[(
"andb"
,
CLndOp
)
,
binaryOps
=
Map
.
fromList
[(
"andb"
,
CLndOp
)
,(
"orb"
,
CLorOp
)]
,(
"orb"
,
CLorOp
)]
...
@@ -329,13 +333,17 @@ convertFunType cp = go
...
@@ -329,13 +333,17 @@ convertFunType cp = go
-- - constructors for inline booleans
-- - constructors for inline booleans
convertFunBody
::
ConversionParams
->
Expr
->
Either
ErrorMsg
Exp
convertFunBody
::
ConversionParams
->
Expr
->
Either
ErrorMsg
Exp
convertFunBody
cp
=
runExcept
.
go
True
convertFunBody
cp
=
runExcept
.
flip
evalStateT
0
.
go
True
where
-- | Translate an expression
where
-- | Translate an expression
-- Take as first argument whether the expression is monadic
-- Take as first argument whether the expression is monadic
-- or not
-- or not
go
::
Bool
->
Expr
->
Except
ErrorMsg
Exp
go
::
Bool
->
Expr
->
StateT
Int
(
Except
ErrorMsg
)
Exp
go
True
(
Apply
(
Global
b
)
[
e1
,
Lambda
[
"_"
]
e2
])
|
b
==
bind
cp
=
BindN
<$>
go
True
e1
<*>
go
True
e2
go
True
(
Apply
(
Global
b
)
[
e1
,
Lambda
[
"_"
]
e2
])
|
b
==
bind
cp
=
BindN
<$>
go
True
e1
<*>
go
True
e2
go
True
(
Apply
(
Global
b
)
[
e1
,
Lambda
[
v
]
e2
])
|
b
==
bind
cp
=
Bind
v
Nothing
<$>
go
True
e1
<*>
go
True
e2
go
True
(
Apply
(
Global
b
)
[
e1
,
Lambda
[
v
]
e2
])
|
b
==
bind
cp
=
Bind
v
Nothing
<$>
go
True
e1
<*>
go
True
e2
go
True
(
Apply
(
Global
b
)
[
e1
,
Global
n
])
|
b
==
bind
cp
=
do
v
<-
freshVar
Bind
v
Nothing
<$>
go
True
e1
<*>
go
True
(
Apply
(
Global
n
)
[
Rel
v
])
go
True
(
Apply
(
Global
r
)
[
e
])
|
r
==
ret
cp
=
Return
<$>
go
False
e
go
True
(
Apply
(
Global
r
)
[
e
])
|
r
==
ret
cp
=
Return
<$>
go
False
e
go
_
(
Apply
(
Global
f
)
as
)
=
Call
f
<$>
traverse
(
go
False
)
as
go
_
(
Apply
(
Global
f
)
as
)
=
Call
f
<$>
traverse
(
go
False
)
as
go
True
(
Global
v
)
=
pure
(
Call
v
[]
)
go
True
(
Global
v
)
=
pure
(
Call
v
[]
)
...
@@ -352,6 +360,10 @@ convertFunBody cp = runExcept . go True
...
@@ -352,6 +360,10 @@ convertFunBody cp = runExcept . go True
go
monadic
e
=
throwError
$
impossibleExpr
monadic
e
go
monadic
e
=
throwError
$
impossibleExpr
monadic
e
freshVar
=
do
c
<-
get
put
(
c
+
1
)
pure
(
prefixTmp
cp
++
show
c
)
impossibleExpr
m
ex
=
"Impossible to convert expression
\"
"
++
show
ex
++
"
\"
"
++
impossibleExpr
m
ex
=
"Impossible to convert expression
\"
"
++
show
ex
++
"
\"
"
++
"in "
++
prefix
m
++
"monadic context"
"in "
++
prefix
m
++
"monadic context"
prefix
True
=
""
prefix
True
=
""
...
...
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