Commit 07c59ac1 authored by Björn Peemöller 's avatar Björn Peemöller
Browse files

Corrected translation of fcase expressions

parent 3f37eb0d
......@@ -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
......
-- 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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment