@@ -243,14 +243,17 @@ match :: (Show a) => a -> Case.Match () () -> State Int [Statement ()]
243243match span mtch =
244244 case mtch of
245245 Case.Match name clauses mtch' ->
246− do clauses' <- mapM (clause span name) clauses
246+ do (isChars, clauses') <- unzip <$> mapM (clause span name) clauses
247247 mtch'' <- match span mtch'
248− return (SwitchStmt () (access name) clauses' : mtch'')
248+ return (SwitchStmt () (format isChars (access name)) clauses' : mtch'')
249249 where
250250 isLiteral p = case p of
251251 Case.Clause (Right _) _ _ -> True
252252 _ -> False
253253 access name = if any isLiteral clauses then ref name else dotSep [name,"ctor"]
254+ format isChars e
255+ | or isChars = InfixExpr () OpAdd e (string "")
256+ | otherwise = e
254257
255258 Case.Fail ->
256259 return [ ExprStmt () (obj "_E.Case" `call` [ref "$moduleName", string (show span)]) ]
@@ -268,15 +271,18 @@ match span mtch =
268271 _ -> dropEnd (acc ++ [m]) ms
269272
270273clause span variable (Case.Clause value vars mtch) =
271− CaseClause () pattern <$> match span (Case.matchSubst (zip vars vars') mtch)
274+ (,) isChar . CaseClause () pattern <$> match span (Case.matchSubst (zip vars vars') mtch)
272275 where
273276 vars' = map (\n -> variable ++ "._" ++ show n) [0..]
274− pattern = case value of
275− Right (Boolean b) -> BoolLit () b
276− Right lit -> literal lit
277− Left name -> string $ case List.elemIndices '.' name of
278− [] -> name
279− is -> drop (last is + 1) name
277+ (isChar, pattern) =
278+ case value of
279+ Right (Chr c) -> (True, string [c])
280+ _ -> (,) False $ case value of
281+ Right (Boolean b) -> BoolLit () b
282+ Right lit -> literal lit
283+ Left name -> string $ case List.elemIndices '.' name of
284+ [] -> name
285+ is -> drop (last is + 1) name
280286
281287
282288jsModule :: MetadataModule () () -> String