git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #2583 from michaelficarra/GH-2581

generate JS static member accesses whenever possible

commitae3aa4d156be23dbb0f1c602ee408af47bb0d141 authorPhil Freeman <paf31@cantab.net> dateThu 19 Jan 2017, 10:00 (10 years ago) parentfdc7bc85b3b759
1 file changed+4−4
src/Language/PureScript/Pretty/JS.hs+4−4
src/Language/PureScript/Pretty/JS.hs+4−4
@@ -159,12 +159,12 @@ conditional = mkPattern match
159159 match (JSConditional ss cond th el) = Just ((ss, th, el), cond)
160160 match _ = Nothing
161161
162−accessor :: (Emit gen) => Pattern PrinterState JS (gen, JS)
162+accessor :: Pattern PrinterState JS (Text, JS)
163163accessor = mkPattern match
164164 where
165165 match (JSIndexer _ (JSStringLiteral _ prop) val) =
166166 case decodeString prop of
167− Just s | not (identNeedsEscaping s) -> Just (emit s, val)
167+ Just s | not (identNeedsEscaping s) -> Just (s, val)
168168 _ -> Nothing
169169 match _ = Nothing
170170
@@ -259,8 +259,8 @@ prettyPrintJS' = A.runKleisli $ runPattern matchValue
259259 matchValue = buildPrettyPrinter operators (literals <+> fmap parensPos matchValue)
260260 operators :: (Emit gen) => OperatorTable PrinterState JS gen
261261 operators =
262− OperatorTable [ [ Wrap accessor $ \prop val -> val <> emit "." <> prop ]
263− , [ Wrap indexer $ \index val -> val <> emit "[" <> index <> emit "]" ]
262+ OperatorTable [ [ Wrap indexer $ \index val -> val <> emit "[" <> index <> emit "]" ]
263+ , [ Wrap accessor $ \prop val -> val <> emit "." <> emit prop ]
264264 , [ Wrap app $ \args val -> val <> emit "(" <> args <> emit ")" ]
265265 , [ unary JSNew "new " ]
266266 , [ Wrap lam $ \(name, args, ss) ret -> addMapping' ss <>