Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
curry
curry-frontend
Commits
07c59ac1
Commit
07c59ac1
authored
Oct 10, 2012
by
Björn Peemöller
Browse files
Corrected translation of fcase expressions
parent
3f37eb0d
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/Transformations/Desugar.lhs
View file @
07c59ac1
...
...
@@ -536,9 +536,11 @@ are compatible with the matched pattern when the guards fail.
>
expandAlt
::
Ident
->
CaseType
->
[
Alt
]
->
DsM
Alt
>
expandAlt
_
_
[]
=
error
"Desugar.expandAlt: empty list"
>
expandAlt
v
ct
(
Alt
p
t
rhs
:
alts
)
=
caseAlt
p
t
`
liftM
`
expandRhs
e0
[]
rhs
>
where
e0
=
Case
(
srcRefOf
p
)
ct
(
mkVar
v
)
>
(
filter
(
isCompatible
t
.
altPattern
)
alts
)
>
altPattern
(
Alt
_
t1
_
)
=
t1
>
where
>
e0
|
ct
==
Flex
=
prelFailed
>
|
otherwise
=
Case
(
srcRefOf
p
)
ct
(
mkVar
v
)
>
(
filter
(
isCompatible
t
.
altPattern
)
alts
)
>
altPattern
(
Alt
_
t1
_
)
=
t1
>
isCompatible
::
Pattern
->
Pattern
->
Bool
>
isCompatible
(
VariablePattern
_
)
_
=
True
...
...
test/Case2.curry
0 → 100644
View file @
07c59ac1
-- f using flex case
ff zs = fcase zs of
(x:_) -> x
(_:y:_) -> y
-- f using rigid case
fr zs = case zs of
(x:_) -> x
(_:y:_) -> y
-- f using patterns (should equal flex case)
fp (x:_) = x
fp (_:y:_) = y
-- g using flex case
gf zs = fcase zs of
(x:_) | x > 0 -> x
(_:y:_) | y > 0 -> y
-- g using rigid case
gr zs = case zs of
(x:_) | x > 0 -> x
(_:y:_) | y > 0 -> y
-- g using patterns (should equal flex case)
gp (x:_) | x > 0 = x
gp (_:y:_) | y > 0 = y
Write
Preview
Supports
Markdown
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