Commit ecaaec9c by Zachary Snow

minor codegen cleanup

parent d2a18e01
...@@ -126,7 +126,7 @@ data Args ...@@ -126,7 +126,7 @@ data Args
deriving (Eq, Ord) deriving (Eq, Ord)
instance Show Args where instance Show Args where
show (Args pnArgs kwArgs) = "(" ++ (commas strs) ++ ")" show (Args pnArgs kwArgs) = '(' : commas strs ++ ")"
where where
strs = (map show pnArgs) ++ (map showKwArg kwArgs) strs = (map show pnArgs) ++ (map showKwArg kwArgs)
showKwArg (x, e) = printf ".%s(%s)" x (show e) showKwArg (x, e) = printf ".%s(%s)" x (show e)
...@@ -177,10 +177,10 @@ showAssignment val = " = " ++ show val ...@@ -177,10 +177,10 @@ showAssignment val = " = " ++ show val
showRanges :: [Range] -> String showRanges :: [Range] -> String
showRanges [] = "" showRanges [] = ""
showRanges l = " " ++ (concatMap showRange l) showRanges l = ' ' : concatMap showRange l
showRange :: Range -> String showRange :: Range -> String
showRange (h, l) = printf "[%s:%s]" (show h) (show l) showRange (h, l) = '[' : show h ++ ':' : show l ++ "]"
showUniOpPrec :: Expr -> ShowS showUniOpPrec :: Expr -> ShowS
showUniOpPrec (e @ UniOp{}) = (showParen True . shows) e showUniOpPrec (e @ UniOp{}) = (showParen True . shows) e
...@@ -198,6 +198,5 @@ showParams params = indentedParenList $ map showParam params ...@@ -198,6 +198,5 @@ showParams params = indentedParenList $ map showParam params
showParam :: ParamBinding -> String showParam :: ParamBinding -> String
showParam ("*", Right Nil) = ".*" showParam ("*", Right Nil) = ".*"
showParam (i, arg) = showParam ("", arg) = showEither arg
printf fmt i (either show show arg) showParam (i, arg) = printf ".%s(%s)" i (showEither arg)
where fmt = if i == "" then "%s%s" else ".%s(%s)"
...@@ -57,4 +57,4 @@ showEither (Right v) = show v ...@@ -57,4 +57,4 @@ showEither (Right v) = show v
showBlock :: (Show a, Show b) => [a] -> [b] -> String showBlock :: (Show a, Show b) => [a] -> [b] -> String
showBlock a [] = indent $ show a showBlock a [] = indent $ show a
showBlock [] b = indent $ show b showBlock [] b = indent $ show b
showBlock a b = indent $ show a ++ "\n" ++ show b showBlock a b = indent $ show a ++ '\n' : show b
Markdown is supported
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