Skip to content

Commit ae3aa4d

Browse files
authored
Merge pull request purescript#2583 from michaelficarra/purescriptGH-2581
generate JS static member accesses whenever possible
2 parents fdc7bc8 + 5b3b759 commit ae3aa4d

File tree

1 file changed

+4
-4
lines changed
  • src/Language/PureScript/Pretty

1 file changed

+4
-4
lines changed

src/Language/PureScript/Pretty/JS.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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)
163163
accessor = 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 <>

0 commit comments

Comments
 (0)