@@ -1,4 +1,4 @@
1−module Generate.Cases (caseToMatch, Match (..), Clause (..), matchSubst) where
1+module Generate.Cases (caseToMatch, Match (..), Clause (..), matchSubst, deprime) where
22
33import Control.Arrow (first)
44import Control.Monad (liftM,foldM)
@@ -12,6 +12,9 @@ import SourceSyntax.Pattern
1212import SourceSyntax.Expression
1313import Transform.Substitute
1414
15+deprime :: String -> String
16+deprime = map (\c -> if c == '\'' then '$' else c)
17+
1518caseToMatch patterns = do
1619 v <- newVar
1720 (,) v `liftM` match [v] (map (first (:[])) patterns) Fail
@@ -65,7 +68,7 @@ match vs@(v:_) cs def
6568
6669dealias v c@(p:ps, L s e) =
6770 case p of
68− PAlias x pattern -> (pattern:ps, L s $ subst x (Var v) e)
71+ PAlias x pattern -> (pattern:ps, L s $ subst (deprime x) (Var v) e)
6972 _ -> c
7073
7174matchVar :: [String] -> [([Pattern],LExpr t v)] -> Match t v
@@ -76,7 +79,7 @@ matchVar (v:vs) cs def = match vs (map subVar cs) def
7679 where
7780 subOnePattern pattern e =
7881 case pattern of
79− PVar x -> subst x (Var v) e
82+ PVar x -> subst (deprime x) (Var v) e
8083 PAnything -> e
8184 PRecord fs ->
8285 foldr (\x -> subst x (Access (L s (Var v)) x)) e fs