Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rtree
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
chrg
rtree
Commits
d0ff68c4
Commit
d0ff68c4
authored
1 year ago
by
chrg
Browse files
Options
Downloads
Patches
Plain Diff
Add labels
parent
d5e2e68d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
22
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
rtree/test/src/Data/Expr.hs
+22
-12
22 additions, 12 deletions
rtree/test/src/Data/Expr.hs
rtree/test/src/Test/Hspec/GitGolden.hs
+1
-1
1 addition, 1 deletion
rtree/test/src/Test/Hspec/GitGolden.hs
with
23 additions
and
13 deletions
rtree/test/src/Data/Expr.hs
+
22
−
12
View file @
d0ff68c4
...
...
@@ -7,10 +7,10 @@
module
Data.Expr
where
import
Control.Applicative
import
Control.Monad.Reader
import
Control.Monad.Reduce
import
Control.Monad.State
import
Data.Data
import
Data.Functor
import
qualified
Data.Map.Strict
as
Map
import
Test.Hspec
...
...
@@ -39,26 +39,36 @@ contains fn e =
Nothing
->
False
rExpr
::
(
MonadReduce
Plus
m
,
Monad
State
(
Map
.
Map
String
(
Either
String
Expr
))
m
)
::
(
MonadReduce
String
m
,
Monad
Reader
(
Map
.
Map
String
(
Either
String
Expr
))
m
)
=>
Expr
->
m
Expr
rExpr
e
=
case
e
of
Cnt
i
->
do
given
$
>
Cnt
i
pure
$
Cnt
i
Var
k
->
do
v
<-
liftMaybe
=<<
get
s
(
Map
.
lookup
k
)
v
<-
ask
s
(
Map
.
lookup
k
)
case
v
of
Left
k'
->
given
$>
Var
k'
Right
x
->
rExpr
x
Opr
e1
e2
->
onBoth
(
rExpr
e1
)
(
rExpr
e2
)
$
\
e1'
e2'
->
Just
(
Left
k'
)
->
pure
$
Var
k'
Just
(
Right
x
)
->
rExpr
x
Nothing
->
pure
(
Cnt
0
)
Opr
e1
e2
->
do
split
"choose left"
(
rExpr
e1
)
.
split
"choose right"
(
rExpr
e2
)
$
do
e1'
<-
rExpr
e1
e2'
<-
rExpr
e2
case
(
e1'
,
e2'
)
of
(
Cnt
a
,
Cnt
b
)
->
pure
(
Cnt
(
a
+
b
))
<|
pure
(
Opr
e1'
e2'
)
(
Cnt
n1
,
Cnt
n2
)
->
do
let
opr
=
Opr
e1'
e2'
split
(
"compute "
<>
prettyExprS
0
opr
""
)
(
pure
(
Cnt
(
n1
+
n2
)))
(
pure
(
Opr
e1'
e2'
))
_ow
->
pure
$
Opr
e1'
e2'
Let
k
e1
e2
->
do
e1'
<-
rExpr
e1
split
(
modifyIn
(
Map
.
insert
k
(
Right
e1'
))
$
rExpr
e2
)
(
Let
k
e1'
<$>
modifyIn
(
Map
.
insert
k
(
Left
k
))
(
rExpr
e2
))
(
"inline "
<>
show
k
)
(
local
(
Map
.
insert
k
(
Right
e1'
))
$
rExpr
e2
)
(
Let
k
e1'
<$>
local
(
Map
.
insert
k
(
Left
k
))
(
rExpr
e2
))
modifyIn
::
(
Alternative
m
,
MonadState
s
m
)
=>
(
s
->
s
)
->
m
b
->
m
b
modifyIn
fn
mx
=
do
...
...
This diff is collapsed.
Click to expand it.
rtree/test/src/Test/Hspec/GitGolden.hs
+
1
−
1
View file @
d0ff68c4
...
...
@@ -59,7 +59,7 @@ instance Example GitGolden where
(
Failure
location
(
Reason
(
unlines
.
drop
4
.
lines
$
df
)
(
unlines
.
drop
3
.
lines
$
df
)
)
)
...
...
This diff is collapsed.
Click to expand it.
Prev
1
2
Next
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