on master help sign in
Add a couple type annotations
commitd1cee239d32b08dbc95762a704bc4e2b85aa94ab authorEvan Czaplicki <info@elm-lang.org> dateFri 1 Nov 2013, 13:58 (13 years ago) parent5eaa5b1
2 files changed+8−1
compiler/Generate/Cases.hs+5−1 compiler/Generate/JavaScript.hs+3
compiler/Generate/Cases.hs+5−1
@@ -104,7 +104,11 @@ matchCon (v:vs) cs def = (flip (Match v) def) <$> mapM toClause css
104104 (PData name _ : _, _) -> matchClause (Left name) (v:vs) cs Break
105105 (PLiteral lit : _, _) -> matchClause (Right lit) (v:vs) cs Break
106106
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)
108112matchClause c (v:vs) cs def =
109113 do vs' <- getVars
110114 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
2424 False -> x
2525 True -> "$" ++ x
2626
27+split :: String -> [String]
2728split = go []
2829 where
2930 go vars str =
@@ -44,6 +45,7 @@ string = StringLit ()
4445dotSep (x:xs) = foldl (DotRef ()) (ref x) (map var xs)
4546obj = dotSep . split
4647
48+varDecl :: String -> Expression () -> VarDecl ()
4749varDecl x expr =
4850 VarDecl () (var x) (Just expr)
4951
@@ -60,6 +62,7 @@ internalImports name =
6062 , varDecl "$moduleName" (string name)
6163 ]
6264
65+literal :: Literal -> Expression ()
6366literal lit =
6467 case lit of
6568 Chr c -> obj "_N.chr" <| string [c]