on master help sign in
style: stop using many line definition
564cf4eEvan Czaplicki
compiler/Generate/Cases.hs+21−10
@@ -65,16 +65,27 @@ isVar :: ([P.Pattern var], expr) -> Bool
65isVar p = not (isCon p)
65isVar p = not (isCon p)
66
66
67match :: [String] -> [([P.CanonicalPattern], Canonical.Expr)] -> Match -> State.State Int Match
67match :: [String] -> [([P.CanonicalPattern], Canonical.Expr)] -> Match -> State.State Int Match
68+match variables cases match =
69+ case (variables, cases, match) of
70+ ([], [], _) ->
68−match [] [] def = return def
71+ return match
72+
73+ ([], [([], expr)], Fail) ->
69−match [] [([],e)] Fail = return $ Other e
74+ return $ Other expr
75+
76+ ([], [([], expr)], Break) ->
70−match [] [([],e)] Break = return $ Other e
77+ return $ Other expr
78+
79+ ([], _, _) ->
71−match [] cs def = return $ Seq (map (Other . snd) cs ++ [def])
80+ return $ Seq (map (Other . snd) cases ++ [match])
72−match vs@(v:_) cs def
81+
82+ (var:_, _, _)
73− | all isVar cs' = matchVar vs cs' def
83+ | all isVar cases' -> matchVar variables cases' match
74− | all isCon cs' = matchCon vs cs' def
84+ | all isCon cases' -> matchCon variables cases' match
75− | otherwise = matchMix vs cs' def
85+ | otherwise -> matchMix variables cases' match
76− where
86+ where
77− cs' = map (dealias v) cs
87+ cases' = map (dealias var) cases
88+
78
89
79dealias :: String -> ([P.CanonicalPattern], Canonical.Expr) -> ([P.CanonicalPattern], Canonical.Expr)
90dealias :: String -> ([P.CanonicalPattern], Canonical.Expr) -> ([P.CanonicalPattern], Canonical.Expr)
80dealias _ ([], _) = noMatch "dealias"
91dealias _ ([], _) = noMatch "dealias"