on master help sign in
Add a couple type annotations
d1cee23Evan Czaplicki
compiler/Generate/Cases.hs+5−1
@@ -104,7 +104,11 @@ matchCon (v:vs) cs def = (flip (Match v) def) <$> mapM toClause css
104 (PData name _ : _, _) -> matchClause (Left name) (v:vs) cs Break
104 (PData name _ : _, _) -> matchClause (Left name) (v:vs) cs Break
105 (PLiteral lit : _, _) -> matchClause (Right lit) (v:vs) cs Break
105 (PLiteral lit : _, _) -> matchClause (Right lit) (v:vs) cs Break
106
106
107−--matchClause :: Either String Literal -> [String] -> [([Pattern],LExpr t v)] -> Match t v -> State Int (Clause a)
107+matchClause :: Either String Literal
108+ -> [String]
109+ -> [([Pattern],LExpr t v)]
110+ -> Match t v
111+ -> State Int (Clause t v)
108matchClause c (v:vs) cs def =
112matchClause c (v:vs) cs def =
109 do vs' <- getVars
113 do vs' <- getVars
110 Clause c vs' <$> match (vs' ++ vs) (map flatten cs) def
114 Clause c vs' <$> match (vs' ++ vs) (map flatten cs) def
compiler/Generate/JavaScript.hs+3
@@ -24,6 +24,7 @@ makeSafe = List.intercalate "." . map dereserve . split . deprime
24 False -> x
24 False -> x
25 True -> "$" ++ x
25 True -> "$" ++ x
26
26
27+split :: String -> [String]
27split = go []
28split = go []
28 where
29 where
29 go vars str =
30 go vars str =
@@ -44,6 +45,7 @@ string = StringLit ()
44dotSep (x:xs) = foldl (DotRef ()) (ref x) (map var xs)
45dotSep (x:xs) = foldl (DotRef ()) (ref x) (map var xs)
45obj = dotSep . split
46obj = dotSep . split
46
47
48+varDecl :: String -> Expression () -> VarDecl ()
47varDecl x expr =
49varDecl x expr =
48 VarDecl () (var x) (Just expr)
50 VarDecl () (var x) (Just expr)
49
51
@@ -60,6 +62,7 @@ internalImports name =
60 , varDecl "$moduleName" (string name)
62 , varDecl "$moduleName" (string name)
61 ]
63 ]
62
64
65+literal :: Literal -> Expression ()
63literal lit =
66literal lit =
64 case lit of
67 case lit of
65 Chr c -> obj "_N.chr" <| string [c]
68 Chr c -> obj "_N.chr" <| string [c]