git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
More tests, plus fixing a bug in JS generation
3403d5fPhil Freeman
examples/passing/Operators.ps+16
@@ -19,3 +19,19 @@ test6 = ((\x -> x) `k` 2) 3
19(<>) = \s1 -> \s2 -> s1 ++ s2
19(<>) = \s1 -> \s2 -> s1 ++ s2
20
20
21test7 = "Hello" <> "World!"
21test7 = "Hello" <> "World!"
22+
23+module Ops where
24+
25+ (@@) :: forall a b. (a -> b) -> a -> b
26+ (@@) = \f x -> f x
27+
28+ foo :: String -> String
29+ foo = \s -> s
30+
31+ test8 = foo @@ "Hello World"
32+
33+ bar = \s1 s2 -> s1 ++ s2
34+
35+test9 = Ops:foo Ops:@@ "Hello World"
36+
37+test10 = "Hello" `Ops:bar` "World"
src/Language/PureScript/CodeGen/JS.hs+2−2
@@ -36,10 +36,10 @@ import Language.PureScript.CodeGen.JS.AST as AST
36declToJs :: Maybe Ident -> ModulePath -> Declaration -> Maybe [JS]
36declToJs :: Maybe Ident -> ModulePath -> Declaration -> Maybe [JS]
37declToJs mod mp (ValueDeclaration ident (Abs args ret)) =
37declToJs mod mp (ValueDeclaration ident (Abs args ret)) =
38 Just $ JSFunction (Just ident) args (JSBlock [JSReturn (valueToJs mp ret)]) :
38 Just $ JSFunction (Just ident) args (JSBlock [JSReturn (valueToJs mp ret)]) :
39− maybe [] (return . setProperty (show ident) (JSVar ident)) mod
39+ maybe [] (return . setProperty (identToJs ident) (JSVar ident)) mod
40declToJs mod mp (ValueDeclaration ident val) =
40declToJs mod mp (ValueDeclaration ident val) =
41 Just $ JSVariableIntroduction ident (Just (valueToJs mp val)) :
41 Just $ JSVariableIntroduction ident (Just (valueToJs mp val)) :
42− maybe [] (return . setProperty (show ident) (JSVar ident)) mod
42+ maybe [] (return . setProperty (identToJs ident) (JSVar ident)) mod
43declToJs mod _ (ExternMemberDeclaration member ident _) =
43declToJs mod _ (ExternMemberDeclaration member ident _) =
44 Just $ JSFunction (Just ident) [Ident "value"] (JSBlock [JSReturn (JSAccessor member (JSVar (Ident "value")))]) :
44 Just $ JSFunction (Just ident) [Ident "value"] (JSBlock [JSReturn (JSAccessor member (JSVar (Ident "value")))]) :
45 maybe [] (return . setProperty (show ident) (JSVar ident)) mod
45 maybe [] (return . setProperty (show ident) (JSVar ident)) mod