git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
More tests, plus fixing a bug in JS generation
commit3403d5fd2f6027a12ef4ecf741afe887f3dd337c authorPhil Freeman <paf31@cantab.net> dateThu 14 Nov 2013, 15:44 (13 years ago) parente21a483
2 files changed+18−2
examples/passing/Operators.ps+16 src/Language/PureScript/CodeGen/JS.hs+2−2
examples/passing/Operators.ps+16
@@ -19,3 +19,19 @@ test6 = ((\x -> x) `k` 2) 3
1919(<>) = \s1 -> \s2 -> s1 ++ s2
2020
2121test7 = "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
3636declToJs :: Maybe Ident -> ModulePath -> Declaration -> Maybe [JS]
3737declToJs mod mp (ValueDeclaration ident (Abs args ret)) =
3838 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
4040declToJs mod mp (ValueDeclaration ident val) =
4141 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
4343declToJs mod _ (ExternMemberDeclaration member ident _) =
4444 Just $ JSFunction (Just ident) [Ident "value"] (JSBlock [JSReturn (JSAccessor member (JSVar (Ident "value")))]) :
4545 maybe [] (return . setProperty (show ident) (JSVar ident)) mod