Commit ecaaec9c by Zachary Snow

minor codegen cleanup

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