git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
remove JSAccessor; replace with JSIndexer (#2554)

* fixes #2513: remove JSAccessor; replace with JSIndexer * generate static member accesses when possible (ref #2513) * remove duplicate function isFn

commit1bb6acd9d0867e944386c2cfd91eb9f0e6ce5576 authorMichael Ficarra <github@michael.ficarra.me> dateSat 14 Jan 2017, 15:31 (10 years ago) parent1326949
7 files changed+222−237
src/Language/PureScript/CodeGen/JS.hs+12−17 src/Language/PureScript/CodeGen/JS/AST.hs−9 src/Language/PureScript/CodeGen/JS/Optimizer/Common.hs+5−12 src/Language/PureScript/CodeGen/JS/Optimizer/Inliner.hs+67−63 src/Language/PureScript/CodeGen/JS/Optimizer/MagicDo.hs+7−7 src/Language/PureScript/Constants.hs+127−127 src/Language/PureScript/Pretty/JS.hs+4−2
src/Language/PureScript/CodeGen/JS.hs+12−17
@@ -35,7 +35,7 @@ import Language.PureScript.Errors (ErrorMessageHint(..), SimpleErrorMessage(..),
3535 errorMessage, rethrowWithPosition, addHint)
3636import Language.PureScript.Names
3737import Language.PureScript.Options
38−import Language.PureScript.PSString (PSString, mkString, decodeString)
38+import Language.PureScript.PSString (PSString, mkString)
3939import Language.PureScript.Traversals (sndM)
4040import qualified Language.PureScript.Constants as C
4141
@@ -69,7 +69,7 @@ moduleToJs (Module coms mn imps exps foreigns decls) foreign_ =
6969 let standardExps = exps \\ foreignExps
7070 let exps' = JSObjectLiteral Nothing $ map (mkString . runIdent &&& JSVar Nothing . identToJs) standardExps
7171 ++ map (mkString . runIdent &&& foreignIdent) foreignExps
72− return $ moduleBody ++ [JSAssignment Nothing (JSAccessor Nothing "exports" (JSVar Nothing "module")) exps']
72+ return $ moduleBody ++ [JSAssignment Nothing (accessorString "exports" (JSVar Nothing "module")) exps']
7373
7474 where
7575
@@ -182,12 +182,7 @@ moduleToJs (Module coms mn imps exps foreigns decls) foreign_ =
182182 accessor (GenIdent _ _) = internalError "GenIdent in accessor"
183183
184184 accessorString :: PSString -> JS -> JS
185− accessorString prop =
186− case decodeString prop of
187− Just s | not (identNeedsEscaping s) ->
188− JSAccessor Nothing s
189− _ ->
190− JSIndexer Nothing (JSStringLiteral Nothing prop)
185+ accessorString prop = JSIndexer Nothing (JSStringLiteral Nothing prop)
191186
192187 -- |
193188 -- Generate code in the simplified Javascript intermediate representation for a value or expression.
@@ -201,9 +196,9 @@ moduleToJs (Module coms mn imps exps foreigns decls) foreign_ =
201196 valueToJs' (Literal (pos, _, _, _) l) =
202197 maybe id rethrowWithPosition pos $ literalToValueJS l
203198 valueToJs' (Var (_, _, _, Just (IsConstructor _ [])) name) =
204− return $ JSAccessor Nothing "value" $ qualifiedToJS id name
199+ return $ accessorString "value" $ qualifiedToJS id name
205200 valueToJs' (Var (_, _, _, Just (IsConstructor _ _)) name) =
206− return $ JSAccessor Nothing "create" $ qualifiedToJS id name
201+ return $ accessorString "create" $ qualifiedToJS id name
207202 valueToJs' (Accessor _ prop val) =
208203 accessorString prop <$> valueToJs val
209204 valueToJs' (ObjectUpdate _ o ps) = do
@@ -258,17 +253,17 @@ moduleToJs (Module coms mn imps exps foreigns decls) foreign_ =
258253 (JSBlock Nothing [JSReturn Nothing $ JSVar Nothing "value"]))])
259254 valueToJs' (Constructor _ _ (ProperName ctor) []) =
260255 return $ iife (properToJs ctor) [ JSFunction Nothing (Just (properToJs ctor)) [] (JSBlock Nothing [])
261− , JSAssignment Nothing (JSAccessor Nothing "value" (JSVar Nothing (properToJs ctor)))
256+ , JSAssignment Nothing (accessorString "value" (JSVar Nothing (properToJs ctor)))
262257 (JSUnary Nothing JSNew $ JSApp Nothing (JSVar Nothing (properToJs ctor)) []) ]
263258 valueToJs' (Constructor _ _ (ProperName ctor) fields) =
264259 let constructor =
265− let body = [ JSAssignment Nothing (JSAccessor Nothing (identToJs f) (JSVar Nothing "this")) (var f) | f <- fields ]
260+ let body = [ JSAssignment Nothing ((accessorString $ mkString $ identToJs f) (JSVar Nothing "this")) (var f) | f <- fields ]
266261 in JSFunction Nothing (Just (properToJs ctor)) (identToJs `map` fields) (JSBlock Nothing body)
267262 createFn =
268263 let body = JSUnary Nothing JSNew $ JSApp Nothing (JSVar Nothing (properToJs ctor)) (var `map` fields)
269264 in foldr (\f inner -> JSFunction Nothing Nothing [identToJs f] (JSBlock Nothing [JSReturn Nothing inner])) body fields
270265 in return $ iife (properToJs ctor) [ constructor
271− , JSAssignment Nothing (JSAccessor Nothing "create" (JSVar Nothing (properToJs ctor))) createFn
266+ , JSAssignment Nothing (accessorString "create" (JSVar Nothing (properToJs ctor))) createFn
272267 ]
273268
274269 iife :: Text -> [JS] -> JS
@@ -299,7 +294,7 @@ moduleToJs (Module coms mn imps exps foreigns decls) foreign_ =
299294 evaluate = JSVariableIntroduction Nothing evaluatedObj (Just obj)
300295 objAssign = JSVariableIntroduction Nothing newObj (Just $ JSObjectLiteral Nothing [])
301296 copy = JSForIn Nothing key jsEvaluatedObj $ JSBlock Nothing [JSIfElse Nothing cond assign Nothing]
302− cond = JSApp Nothing (JSAccessor Nothing "call" (JSAccessor Nothing "hasOwnProperty" (JSObjectLiteral Nothing []))) [jsEvaluatedObj, jsKey]
297+ cond = JSApp Nothing (accessorString "call" (accessorString "hasOwnProperty" (JSObjectLiteral Nothing []))) [jsEvaluatedObj, jsKey]
303298 assign = JSBlock Nothing [JSAssignment Nothing (JSIndexer Nothing jsKey jsNewObj) (JSIndexer Nothing jsKey jsEvaluatedObj)]
304299 stToAssign (s, js) = JSAssignment Nothing (accessorString s jsNewObj) js
305300 extend = map stToAssign sts
@@ -356,7 +351,7 @@ moduleToJs (Module coms mn imps exps foreigns decls) foreign_ =
356351 valueError _ l@(JSNumericLiteral _ _) = l
357352 valueError _ l@(JSStringLiteral _ _) = l
358353 valueError _ l@(JSBooleanLiteral _ _) = l
359− valueError s _ = JSAccessor Nothing "name" . JSAccessor Nothing "constructor" $ JSVar Nothing s
354+ valueError s _ = accessorString "name" . accessorString "constructor" $ JSVar Nothing s
360355
361356 guardsToJs :: Either [(Guard Ann, Expr Ann)] (Expr Ann) -> m [JS]
362357 guardsToJs (Left gs) = forM gs $ \(cond, val) -> do
@@ -397,7 +392,7 @@ moduleToJs (Module coms mn imps exps foreigns decls) foreign_ =
397392 argVar <- freshName
398393 done'' <- go remain done'
399394 js <- binderToJs argVar done'' binder
400− return (JSVariableIntroduction Nothing argVar (Just (JSAccessor Nothing (identToJs field) (JSVar Nothing varName))) : js)
395+ return (JSVariableIntroduction Nothing argVar (Just $ accessorString (mkString $ identToJs field) $ JSVar Nothing varName) : js)
401396 binderToJs' _ _ ConstructorBinder{} =
402397 internalError "binderToJs: Invalid ConstructorBinder in binderToJs"
403398 binderToJs' varName done (NamedBinder _ ident binder) = do
@@ -426,7 +421,7 @@ moduleToJs (Module coms mn imps exps foreigns decls) foreign_ =
426421 return (JSVariableIntroduction Nothing propVar (Just (accessorString prop (JSVar Nothing varName))) : js)
427422 literalToBinderJS varName done (ArrayLiteral bs) = do
428423 js <- go done 0 bs
429− return [JSIfElse Nothing (JSBinary Nothing EqualTo (JSAccessor Nothing "length" (JSVar Nothing varName)) (JSNumericLiteral Nothing (Left (fromIntegral $ length bs)))) (JSBlock Nothing js) Nothing]
424+ return [JSIfElse Nothing (JSBinary Nothing EqualTo (accessorString "length" (JSVar Nothing varName)) (JSNumericLiteral Nothing (Left (fromIntegral $ length bs)))) (JSBlock Nothing js) Nothing]
430425 where
431426 go :: [JS] -> Integer -> [Binder Ann] -> m [JS]
432427 go done' _ [] = return done'
src/Language/PureScript/CodeGen/JS/AST.hs−9
@@ -159,10 +159,6 @@ data JS
159159 --
160160 | JSObjectLiteral (Maybe SourceSpan) [(PSString, JS)]
161161 -- |
162− -- An object property accessor expression
163− --
164− | JSAccessor (Maybe SourceSpan) Text JS
165− -- |
166162 -- A function introduction (optional name, arguments, body)
167163 --
168164 | JSFunction (Maybe SourceSpan) (Maybe Text) [Text] JS
@@ -259,7 +255,6 @@ withSourceSpan withSpan = go
259255 go (JSArrayLiteral _ js) = JSArrayLiteral ss js
260256 go (JSIndexer _ j1 j2) = JSIndexer ss j1 j2
261257 go (JSObjectLiteral _ js) = JSObjectLiteral ss js
262− go (JSAccessor _ prop j) = JSAccessor ss prop j
263258 go (JSFunction _ name args j) = JSFunction ss name args j
264259 go (JSApp _ j js) = JSApp ss j js
265260 go (JSVar _ s) = JSVar ss s
@@ -293,7 +288,6 @@ getSourceSpan = go
293288 go (JSArrayLiteral ss _) = ss
294289 go (JSIndexer ss _ _) = ss
295290 go (JSObjectLiteral ss _) = ss
296− go (JSAccessor ss _ _) = ss
297291 go (JSFunction ss _ _ _) = ss
298292 go (JSApp ss _ _) = ss
299293 go (JSVar ss _) = ss
@@ -328,7 +322,6 @@ everywhereOnJS f = go
328322 go (JSArrayLiteral ss js) = f (JSArrayLiteral ss (map go js))
329323 go (JSIndexer ss j1 j2) = f (JSIndexer ss (go j1) (go j2))
330324 go (JSObjectLiteral ss js) = f (JSObjectLiteral ss (map (fmap go) js))
331− go (JSAccessor ss prop j) = f (JSAccessor ss prop (go j))
332325 go (JSFunction ss name args j) = f (JSFunction ss name args (go j))
333326 go (JSApp ss j js) = f (JSApp ss (go j) (map go js))
334327 go (JSConditional ss j1 j2 j3) = f (JSConditional ss (go j1) (go j2) (go j3))
@@ -359,7 +352,6 @@ everywhereOnJSTopDownM f = f >=> go
359352 go (JSArrayLiteral ss js) = JSArrayLiteral ss <$> traverse f' js
360353 go (JSIndexer ss j1 j2) = JSIndexer ss <$> f' j1 <*> f' j2
361354 go (JSObjectLiteral ss js) = JSObjectLiteral ss <$> traverse (sndM f') js
362− go (JSAccessor ss prop j) = JSAccessor ss prop <$> f' j
363355 go (JSFunction ss name args j) = JSFunction ss name args <$> f' j
364356 go (JSApp ss j js) = JSApp ss <$> f' j <*> traverse f' js
365357 go (JSConditional ss j1 j2 j3) = JSConditional ss <$> f' j1 <*> f' j2 <*> f' j3
@@ -386,7 +378,6 @@ everythingOnJS (<>) f = go
386378 go j@(JSArrayLiteral _ js) = foldl (<>) (f j) (map go js)
387379 go j@(JSIndexer _ j1 j2) = f j <> go j1 <> go j2
388380 go j@(JSObjectLiteral _ js) = foldl (<>) (f j) (map (go . snd) js)
389− go j@(JSAccessor _ _ j1) = f j <> go j1
390381 go j@(JSFunction _ _ _ j1) = f j <> go j1
391382 go j@(JSApp _ j1 js) = foldl (<>) (f j <> go j1) (map go js)
392383 go j@(JSConditional _ j1 j2 j3) = f j <> go j1 <> go j2 <> go j3
src/Language/PureScript/CodeGen/JS/Optimizer/Common.hs+5−12
@@ -11,7 +11,7 @@ import Data.Maybe (fromMaybe)
1111
1212import Language.PureScript.Crash
1313import Language.PureScript.CodeGen.JS.AST
14−import Language.PureScript.PSString (mkString)
14+import Language.PureScript.PSString (PSString)
1515
1616applyAll :: [a -> a] -> a -> a
1717applyAll = foldl' (.) id
@@ -55,7 +55,6 @@ isUsed var1 = everythingOnJS (||) check
5555
5656targetVariable :: JS -> Text
5757targetVariable (JSVar _ var) = var
58−targetVariable (JSAccessor _ _ tgt) = targetVariable tgt
5958targetVariable (JSIndexer _ _ tgt) = targetVariable tgt
6059targetVariable _ = internalError "Invalid argument to targetVariable"
6160
@@ -70,16 +69,10 @@ removeFromBlock :: ([JS] -> [JS]) -> JS -> JS
7069removeFromBlock go (JSBlock ss sts) = JSBlock ss (go sts)
7170removeFromBlock _ js = js
7271
73−isFn :: (Text, Text) -> JS -> Bool
74−isFn (moduleName, fnName) (JSAccessor _ x (JSVar _ y)) =
75− x == fnName && y == moduleName
76−isFn (moduleName, fnName) (JSIndexer _ (JSStringLiteral _ x) (JSVar _ y)) =
77− x == mkString fnName && y == moduleName
78−isFn _ _ = False
79−
80−isDict :: (Text, Text) -> JS -> Bool
81−isDict (moduleName, dictName) (JSAccessor _ x (JSVar _ y)) = x == dictName && y == moduleName
72+isDict :: (Text, PSString) -> JS -> Bool
73+isDict (moduleName, dictName) (JSIndexer _ (JSStringLiteral _ x) (JSVar _ y)) =
74+ x == dictName && y == moduleName
8275isDict _ _ = False
8376
84−isDict' :: [(Text, Text)] -> JS -> Bool
77+isDict' :: [(Text, PSString)] -> JS -> Bool
8578isDict' xs js = any (`isDict` js) xs
src/Language/PureScript/CodeGen/JS/Optimizer/Inliner.hs+67−63
@@ -17,9 +17,11 @@ import Control.Monad.Supply.Class (MonadSupply, freshName)
1717
1818import Data.Maybe (fromMaybe)
1919import Data.Monoid ((<>))
20+import Data.String (IsString, fromString)
2021import Data.Text (Text)
2122import qualified Data.Text as T
2223
24+import Language.PureScript.PSString (PSString)
2325import Language.PureScript.CodeGen.JS.AST
2426import Language.PureScript.CodeGen.JS.Optimizer.Common
2527import qualified Language.PureScript.Constants as C
@@ -33,7 +35,6 @@ shouldInline (JSVar _ _) = True
3335shouldInline (JSNumericLiteral _ _) = True
3436shouldInline (JSStringLiteral _ _) = True
3537shouldInline (JSBooleanLiteral _ _) = True
36−shouldInline (JSAccessor _ _ val) = shouldInline val
3738shouldInline (JSIndexer _ index val) = shouldInline index && shouldInline val
3839shouldInline _ = False
3940
@@ -82,17 +83,17 @@ inlineCommonValues = everywhereOnJS convert
8283 where
8384 convert :: JS -> JS
8485 convert (JSApp ss fn [dict])
85− | isDict' [semiringNumber, semiringInt] dict && isFn fnZero fn = JSNumericLiteral ss (Left 0)
86− | isDict' [semiringNumber, semiringInt] dict && isFn fnOne fn = JSNumericLiteral ss (Left 1)
87− | isDict boundedBoolean dict && isFn fnBottom fn = JSBooleanLiteral ss False
88− | isDict boundedBoolean dict && isFn fnTop fn = JSBooleanLiteral ss True
86+ | isDict' [semiringNumber, semiringInt] dict && isDict fnZero fn = JSNumericLiteral ss (Left 0)
87+ | isDict' [semiringNumber, semiringInt] dict && isDict fnOne fn = JSNumericLiteral ss (Left 1)
88+ | isDict boundedBoolean dict && isDict fnBottom fn = JSBooleanLiteral ss False
89+ | isDict boundedBoolean dict && isDict fnTop fn = JSBooleanLiteral ss True
8990 convert (JSApp ss (JSApp _ fn [dict]) [x])
90− | isDict ringInt dict && isFn fnNegate fn = JSBinary ss BitwiseOr (JSUnary ss Negate x) (JSNumericLiteral ss (Left 0))
91+ | isDict ringInt dict && isDict fnNegate fn = JSBinary ss BitwiseOr (JSUnary ss Negate x) (JSNumericLiteral ss (Left 0))
9192 convert (JSApp ss (JSApp _ (JSApp _ fn [dict]) [x]) [y])
92− | isDict semiringInt dict && isFn fnAdd fn = intOp ss Add x y
93− | isDict semiringInt dict && isFn fnMultiply fn = intOp ss Multiply x y
94− | isDict euclideanRingInt dict && isFn fnDivide fn = intOp ss Divide x y
95− | isDict ringInt dict && isFn fnSubtract fn = intOp ss Subtract x y
93+ | isDict semiringInt dict && isDict fnAdd fn = intOp ss Add x y
94+ | isDict semiringInt dict && isDict fnMultiply fn = intOp ss Multiply x y
95+ | isDict euclideanRingInt dict && isDict fnDivide fn = intOp ss Divide x y
96+ | isDict ringInt dict && isDict fnSubtract fn = intOp ss Subtract x y
9697 convert other = other
9798 fnZero = (C.dataSemiring, C.zero)
9899 fnOne = (C.dataSemiring, C.one)
@@ -168,29 +169,29 @@ inlineCommonOperators = applyAll $
168169 ] ++
169170 [ fn | i <- [0..10], fn <- [ mkFn i, runFn i ] ]
170171 where
171− binary :: (Text, Text) -> (Text, Text) -> BinaryOperator -> JS -> JS
172+ binary :: (Text, PSString) -> (Text, PSString) -> BinaryOperator -> JS -> JS
172173 binary dict fns op = everywhereOnJS convert
173174 where
174175 convert :: JS -> JS
175− convert (JSApp ss (JSApp _ (JSApp _ fn [dict']) [x]) [y]) | isDict dict dict' && isFn fns fn = JSBinary ss op x y
176+ convert (JSApp ss (JSApp _ (JSApp _ fn [dict']) [x]) [y]) | isDict dict dict' && isDict fns fn = JSBinary ss op x y
176177 convert other = other
177− binary' :: Text -> Text -> BinaryOperator -> JS -> JS
178+ binary' :: Text -> PSString -> BinaryOperator -> JS -> JS
178179 binary' moduleName opString op = everywhereOnJS convert
179180 where
180181 convert :: JS -> JS
181− convert (JSApp ss (JSApp _ fn [x]) [y]) | isFn (moduleName, opString) fn = JSBinary ss op x y
182+ convert (JSApp ss (JSApp _ fn [x]) [y]) | isDict (moduleName, opString) fn = JSBinary ss op x y
182183 convert other = other
183− unary :: (Text, Text) -> (Text, Text) -> UnaryOperator -> JS -> JS
184+ unary :: (Text, PSString) -> (Text, PSString) -> UnaryOperator -> JS -> JS
184185 unary dicts fns op = everywhereOnJS convert
185186 where
186187 convert :: JS -> JS
187− convert (JSApp ss (JSApp _ fn [dict']) [x]) | isDict dicts dict' && isFn fns fn = JSUnary ss op x
188+ convert (JSApp ss (JSApp _ fn [dict']) [x]) | isDict dicts dict' && isDict fns fn = JSUnary ss op x
188189 convert other = other
189− unary' :: Text -> Text -> UnaryOperator -> JS -> JS
190+ unary' :: Text -> PSString -> UnaryOperator -> JS -> JS
190191 unary' moduleName fnName op = everywhereOnJS convert
191192 where
192193 convert :: JS -> JS
193− convert (JSApp ss fn [x]) | isFn (moduleName, fnName) fn = JSUnary ss op x
194+ convert (JSApp ss fn [x]) | isDict (moduleName, fnName) fn = JSUnary ss op x
194195 convert other = other
195196 mkFn :: Int -> JS -> JS
196197 mkFn 0 = everywhereOnJS convert
@@ -214,7 +215,8 @@ inlineCommonOperators = applyAll $
214215
215216 isNFn :: Text -> Int -> JS -> Bool
216217 isNFn prefix n (JSVar _ name) = name == (prefix <> T.pack (show n))
217− isNFn prefix n (JSAccessor _ name (JSVar _ dataFunctionUncurried)) | dataFunctionUncurried == C.dataFunctionUncurried = name == (prefix <> T.pack (show n))
218+ isNFn prefix n (JSIndexer _ (JSStringLiteral _ name) (JSVar _ dataFunctionUncurried)) | dataFunctionUncurried == C.dataFunctionUncurried =
219+ name == fromString (T.unpack prefix <> show n)
218220 isNFn _ _ _ = False
219221
220222 runFn :: Int -> JS -> JS
@@ -235,12 +237,14 @@ inlineCommonOperators = applyAll $
235237 convert (JSApp _ (JSApp _ op' [x]) [y]) | p op' = f x y
236238 convert other = other
237239
238− isModFn :: (Text, Text) -> JS -> Bool
239− isModFn (m, op) (JSAccessor _ op' (JSVar _ m')) = m == m' && op == op'
240+ isModFn :: (Text, PSString) -> JS -> Bool
241+ isModFn (m, op) (JSIndexer _ (JSStringLiteral _ op') (JSVar _ m')) =
242+ m == m' && op == op'
240243 isModFn _ _ = False
241244
242− isModFnWithDict :: (Text, Text) -> JS -> Bool
243− isModFnWithDict (m, op) (JSApp _ (JSAccessor _ op' (JSVar _ m')) [JSVar _ _]) = m == m' && op == op'
245+ isModFnWithDict :: (Text, PSString) -> JS -> Bool
246+ isModFnWithDict (m, op) (JSApp _ (JSIndexer _ (JSStringLiteral _ op') (JSVar _ m')) [JSVar _ _]) =
247+ m == m' && op == op'
244248 isModFnWithDict _ _ = False
245249
246250-- (f <<< g $ x) = f (g x)
@@ -261,118 +265,118 @@ inlineFnComposition = everywhereOnJSTopDownM convert
261265 return $ JSFunction ss Nothing [arg] (JSBlock ss [JSReturn Nothing $ JSApp Nothing y [JSApp Nothing x [JSVar Nothing arg]]])
262266 convert other = return other
263267 isFnCompose :: JS -> JS -> Bool
264− isFnCompose dict' fn = isDict semigroupoidFn dict' && isFn fnCompose fn
268+ isFnCompose dict' fn = isDict semigroupoidFn dict' && isDict fnCompose fn
265269 isFnComposeFlipped :: JS -> JS -> Bool
266− isFnComposeFlipped dict' fn = isDict semigroupoidFn dict' && isFn fnComposeFlipped fn
267− fnCompose :: (Text, Text)
270+ isFnComposeFlipped dict' fn = isDict semigroupoidFn dict' && isDict fnComposeFlipped fn
271+ fnCompose :: forall a b. (IsString a, IsString b) => (a, b)
268272 fnCompose = (C.controlSemigroupoid, C.compose)
269− fnComposeFlipped :: (Text, Text)
273+ fnComposeFlipped :: forall a b. (IsString a, IsString b) => (a, b)
270274 fnComposeFlipped = (C.controlSemigroupoid, C.composeFlipped)
271275
272−semiringNumber :: (Text, Text)
276+semiringNumber :: forall a b. (IsString a, IsString b) => (a, b)
273277semiringNumber = (C.dataSemiring, C.semiringNumber)
274278
275−semiringInt :: (Text, Text)
279+semiringInt :: forall a b. (IsString a, IsString b) => (a, b)
276280semiringInt = (C.dataSemiring, C.semiringInt)
277281
278−ringNumber :: (Text, Text)
282+ringNumber :: forall a b. (IsString a, IsString b) => (a, b)
279283ringNumber = (C.dataRing, C.ringNumber)
280284
281−ringInt :: (Text, Text)
285+ringInt :: forall a b. (IsString a, IsString b) => (a, b)
282286ringInt = (C.dataRing, C.ringInt)
283287
284−euclideanRingNumber :: (Text, Text)
288+euclideanRingNumber :: forall a b. (IsString a, IsString b) => (a, b)
285289euclideanRingNumber = (C.dataEuclideanRing, C.euclideanRingNumber)
286290
287−euclideanRingInt :: (Text, Text)
291+euclideanRingInt :: forall a b. (IsString a, IsString b) => (a, b)
288292euclideanRingInt = (C.dataEuclideanRing, C.euclideanRingInt)
289293
290−eqNumber :: (Text, Text)
294+eqNumber :: forall a b. (IsString a, IsString b) => (a, b)
291295eqNumber = (C.dataEq, C.eqNumber)
292296
293−eqInt :: (Text, Text)
297+eqInt :: forall a b. (IsString a, IsString b) => (a, b)
294298eqInt = (C.dataEq, C.eqInt)
295299
296−eqString :: (Text, Text)
300+eqString :: forall a b. (IsString a, IsString b) => (a, b)
297301eqString = (C.dataEq, C.eqString)
298302
299−eqChar :: (Text, Text)
303+eqChar :: forall a b. (IsString a, IsString b) => (a, b)
300304eqChar = (C.dataEq, C.eqChar)
301305
302−eqBoolean :: (Text, Text)
306+eqBoolean :: forall a b. (IsString a, IsString b) => (a, b)
303307eqBoolean = (C.dataEq, C.eqBoolean)
304308
305−ordBoolean :: (Text, Text)
309+ordBoolean :: forall a b. (IsString a, IsString b) => (a, b)
306310ordBoolean = (C.dataOrd, C.ordBoolean)
307311
308−ordNumber :: (Text, Text)
312+ordNumber :: forall a b. (IsString a, IsString b) => (a, b)
309313ordNumber = (C.dataOrd, C.ordNumber)
310314
311−ordInt :: (Text, Text)
315+ordInt :: forall a b. (IsString a, IsString b) => (a, b)
312316ordInt = (C.dataOrd, C.ordInt)
313317
314−ordString :: (Text, Text)
318+ordString :: forall a b. (IsString a, IsString b) => (a, b)
315319ordString = (C.dataOrd, C.ordString)
316320
317−ordChar :: (Text, Text)
321+ordChar :: forall a b. (IsString a, IsString b) => (a, b)
318322ordChar = (C.dataOrd, C.ordChar)
319323
320−semigroupString :: (Text, Text)
324+semigroupString :: forall a b. (IsString a, IsString b) => (a, b)
321325semigroupString = (C.dataSemigroup, C.semigroupString)
322326
323−boundedBoolean :: (Text, Text)
327+boundedBoolean :: forall a b. (IsString a, IsString b) => (a, b)
324328boundedBoolean = (C.dataBounded, C.boundedBoolean)
325329
326−heytingAlgebraBoolean :: (Text, Text)
330+heytingAlgebraBoolean :: forall a b. (IsString a, IsString b) => (a, b)
327331heytingAlgebraBoolean = (C.dataHeytingAlgebra, C.heytingAlgebraBoolean)
328332
329−semigroupoidFn :: (Text, Text)
333+semigroupoidFn :: forall a b. (IsString a, IsString b) => (a, b)
330334semigroupoidFn = (C.controlSemigroupoid, C.semigroupoidFn)
331335
332−opAdd :: (Text, Text)
336+opAdd :: forall a b. (IsString a, IsString b) => (a, b)
333337opAdd = (C.dataSemiring, C.add)
334338
335−opMul :: (Text, Text)
339+opMul :: forall a b. (IsString a, IsString b) => (a, b)
336340opMul = (C.dataSemiring, C.mul)
337341
338−opEq :: (Text, Text)
342+opEq :: forall a b. (IsString a, IsString b) => (a, b)
339343opEq = (C.dataEq, C.eq)
340344
341−opNotEq :: (Text, Text)
345+opNotEq :: forall a b. (IsString a, IsString b) => (a, b)
342346opNotEq = (C.dataEq, C.notEq)
343347
344−opLessThan :: (Text, Text)
348+opLessThan :: forall a b. (IsString a, IsString b) => (a, b)
345349opLessThan = (C.dataOrd, C.lessThan)
346350
347−opLessThanOrEq :: (Text, Text)
351+opLessThanOrEq :: forall a b. (IsString a, IsString b) => (a, b)
348352opLessThanOrEq = (C.dataOrd, C.lessThanOrEq)
349353
350−opGreaterThan :: (Text, Text)
354+opGreaterThan :: forall a b. (IsString a, IsString b) => (a, b)
351355opGreaterThan = (C.dataOrd, C.greaterThan)
352356
353−opGreaterThanOrEq :: (Text, Text)
357+opGreaterThanOrEq :: forall a b. (IsString a, IsString b) => (a, b)
354358opGreaterThanOrEq = (C.dataOrd, C.greaterThanOrEq)
355359
356−opAppend :: (Text, Text)
360+opAppend :: forall a b. (IsString a, IsString b) => (a, b)
357361opAppend = (C.dataSemigroup, C.append)
358362
359−opSub :: (Text, Text)
363+opSub :: forall a b. (IsString a, IsString b) => (a, b)
360364opSub = (C.dataRing, C.sub)
361365
362−opNegate :: (Text, Text)
366+opNegate :: forall a b. (IsString a, IsString b) => (a, b)
363367opNegate = (C.dataRing, C.negate)
364368
365−opDiv :: (Text, Text)
369+opDiv :: forall a b. (IsString a, IsString b) => (a, b)
366370opDiv = (C.dataEuclideanRing, C.div)
367371
368−opMod :: (Text, Text)
372+opMod :: forall a b. (IsString a, IsString b) => (a, b)
369373opMod = (C.dataEuclideanRing, C.mod)
370374
371−opConj :: (Text, Text)
375+opConj :: forall a b. (IsString a, IsString b) => (a, b)
372376opConj = (C.dataHeytingAlgebra, C.conj)
373377
374−opDisj :: (Text, Text)
378+opDisj :: forall a b. (IsString a, IsString b) => (a, b)
375379opDisj = (C.dataHeytingAlgebra, C.disj)
376380
377−opNot :: (Text, Text)
381+opNot :: forall a b. (IsString a, IsString b) => (a, b)
378382opNot = (C.dataHeytingAlgebra, C.not)
src/Language/PureScript/CodeGen/JS/Optimizer/MagicDo.hs+7−7
@@ -64,11 +64,11 @@ magicDo' = everywhereOnJS undo . everywhereOnJSTopDown convert
6464 isPure (JSApp _ fn [dict]) | isDict (C.eff, C.applicativeEffDictionary) dict && isPurePoly fn = True
6565 isPure _ = False
6666 -- Check if an expression represents the polymorphic >>= function
67− isBindPoly = isFn (C.controlBind, C.bind)
67+ isBindPoly = isDict (C.controlBind, C.bind)
6868 -- Check if an expression represents the polymorphic pure or return function
69− isPurePoly = isFn (C.controlApplicative, C.pure')
69+ isPurePoly = isDict (C.controlApplicative, C.pure')
7070 -- Check if an expression represents a function in the Eff module
71− isEffFunc name (JSAccessor _ name' (JSVar _ eff)) = eff == C.eff && name == name'
71+ isEffFunc name (JSIndexer _ (JSStringLiteral _ name') (JSVar _ eff)) = eff == C.eff && name == name'
7272 isEffFunc _ _ = False
7373
7474 -- Remove __do function applications which remain after desugaring
@@ -107,14 +107,14 @@ inlineST = everywhereOnJS convertBlock
107107 convert agg (JSApp s1 f [arg]) | isSTFunc C.newSTRef f =
108108 JSFunction s1 Nothing [] (JSBlock s1 [JSReturn s1 $ if agg then arg else JSObjectLiteral s1 [(mkString C.stRefValue, arg)]])
109109 convert agg (JSApp _ (JSApp s1 f [ref]) []) | isSTFunc C.readSTRef f =
110− if agg then ref else JSAccessor s1 C.stRefValue ref
110+ if agg then ref else JSIndexer s1 (JSStringLiteral s1 C.stRefValue) ref
111111 convert agg (JSApp _ (JSApp _ (JSApp s1 f [ref]) [arg]) []) | isSTFunc C.writeSTRef f =
112− if agg then JSAssignment s1 ref arg else JSAssignment s1 (JSAccessor s1 C.stRefValue ref) arg
112+ if agg then JSAssignment s1 ref arg else JSAssignment s1 (JSIndexer s1 (JSStringLiteral s1 C.stRefValue) ref) arg
113113 convert agg (JSApp _ (JSApp _ (JSApp s1 f [ref]) [func]) []) | isSTFunc C.modifySTRef f =
114− if agg then JSAssignment s1 ref (JSApp s1 func [ref]) else JSAssignment s1 (JSAccessor s1 C.stRefValue ref) (JSApp s1 func [JSAccessor s1 C.stRefValue ref])
114+ if agg then JSAssignment s1 ref (JSApp s1 func [ref]) else JSAssignment s1 (JSIndexer s1 (JSStringLiteral s1 C.stRefValue) ref) (JSApp s1 func [JSIndexer s1 (JSStringLiteral s1 C.stRefValue) ref])
115115 convert _ other = other
116116 -- Check if an expression represents a function in the ST module
117− isSTFunc name (JSAccessor _ name' (JSVar _ st)) = st == C.st && name == name'
117+ isSTFunc name (JSIndexer _ (JSStringLiteral _ name') (JSVar _ st)) = st == C.st && name == name'
118118 isSTFunc _ _ = False
119119 -- Find all ST Refs initialized in this block
120120 findSTRefsIn = everythingOnJS (++) isSTRef
src/Language/PureScript/Constants.hs+127−127
@@ -2,319 +2,319 @@
22module Language.PureScript.Constants where
33
44import Prelude.Compat
5−import Data.Text (Text)
5+import Data.String (IsString)
66import Language.PureScript.Names
77
88-- Operators
99
10−($) :: Text
10+($) :: forall a. (IsString a) => a
1111($) = "$"
1212
13−apply :: Text
13+apply :: forall a. (IsString a) => a
1414apply = "apply"
1515
16−(#) :: Text
16+(#) :: forall a. (IsString a) => a
1717(#) = "#"
1818
19−applyFlipped :: Text
19+applyFlipped :: forall a. (IsString a) => a
2020applyFlipped = "applyFlipped"
2121
22−(<>) :: Text
22+(<>) :: forall a. (IsString a) => a
2323(<>) = "<>"
2424
25−(++) :: Text
25+(++) :: forall a. (IsString a) => a
2626(++) = "++"
2727
28−append :: Text
28+append :: forall a. (IsString a) => a
2929append = "append"
3030
31−(>>=) :: Text
31+(>>=) :: forall a. (IsString a) => a
3232(>>=) = ">>="
3333
34−bind :: Text
34+bind :: forall a. (IsString a) => a
3535bind = "bind"
3636
37−(+) :: Text
37+(+) :: forall a. (IsString a) => a
3838(+) = "+"
3939
40−add :: Text
40+add :: forall a. (IsString a) => a
4141add = "add"
4242
43−(-) :: Text
43+(-) :: forall a. (IsString a) => a
4444(-) = "-"
4545
46−sub :: Text
46+sub :: forall a. (IsString a) => a
4747sub = "sub"
4848
49−(*) :: Text
49+(*) :: forall a. (IsString a) => a
5050(*) = "*"
5151
52−mul :: Text
52+mul :: forall a. (IsString a) => a
5353mul = "mul"
5454
55−(/) :: Text
55+(/) :: forall a. (IsString a) => a
5656(/) = "/"
5757
58−div :: Text
58+div :: forall a. (IsString a) => a
5959div = "div"
6060
61−(%) :: Text
61+(%) :: forall a. (IsString a) => a
6262(%) = "%"
6363
64−mod :: Text
64+mod :: forall a. (IsString a) => a
6565mod = "mod"
6666
67−(<) :: Text
67+(<) :: forall a. (IsString a) => a
6868(<) = "<"
6969
70−lessThan :: Text
70+lessThan :: forall a. (IsString a) => a
7171lessThan = "lessThan"
7272
73−(>) :: Text
73+(>) :: forall a. (IsString a) => a
7474(>) = ">"
7575
76−greaterThan :: Text
76+greaterThan :: forall a. (IsString a) => a
7777greaterThan = "greaterThan"
7878
79−(<=) :: Text
79+(<=) :: forall a. (IsString a) => a
8080(<=) = "<="
8181
82−lessThanOrEq :: Text
82+lessThanOrEq :: forall a. (IsString a) => a
8383lessThanOrEq = "lessThanOrEq"
8484
85−(>=) :: Text
85+(>=) :: forall a. (IsString a) => a
8686(>=) = ">="
8787
88−greaterThanOrEq :: Text
88+greaterThanOrEq :: forall a. (IsString a) => a
8989greaterThanOrEq = "greaterThanOrEq"
9090
91−(==) :: Text
91+(==) :: forall a. (IsString a) => a
9292(==) = "=="
9393
94−eq :: Text
94+eq :: forall a. (IsString a) => a
9595eq = "eq"
9696
97−(/=) :: Text
97+(/=) :: forall a. (IsString a) => a
9898(/=) = "/="
9999
100−notEq :: Text
100+notEq :: forall a. (IsString a) => a
101101notEq = "notEq"
102102
103−compare :: Text
103+compare :: forall a. (IsString a) => a
104104compare = "compare"
105105
106−(&&) :: Text
106+(&&) :: forall a. (IsString a) => a
107107(&&) = "&&"
108108
109−conj :: Text
109+conj :: forall a. (IsString a) => a
110110conj = "conj"
111111
112−(||) :: Text
112+(||) :: forall a. (IsString a) => a
113113(||) = "||"
114114
115−disj :: Text
115+disj :: forall a. (IsString a) => a
116116disj = "disj"
117117
118−unsafeIndex :: Text
118+unsafeIndex :: forall a. (IsString a) => a
119119unsafeIndex = "unsafeIndex"
120120
121−or :: Text
121+or :: forall a. (IsString a) => a
122122or = "or"
123123
124−and :: Text
124+and :: forall a. (IsString a) => a
125125and = "and"
126126
127−xor :: Text
127+xor :: forall a. (IsString a) => a
128128xor = "xor"
129129
130−(<<<) :: Text
130+(<<<) :: forall a. (IsString a) => a
131131(<<<) = "<<<"
132132
133−compose :: Text
133+compose :: forall a. (IsString a) => a
134134compose = "compose"
135135
136−(>>>) :: Text
136+(>>>) :: forall a. (IsString a) => a
137137(>>>) = ">>>"
138138
139−composeFlipped :: Text
139+composeFlipped :: forall a. (IsString a) => a
140140composeFlipped = "composeFlipped"
141141
142−map :: Text
142+map :: forall a. (IsString a) => a
143143map = "map"
144144
145145-- Functions
146146
147−negate :: Text
147+negate :: forall a. (IsString a) => a
148148negate = "negate"
149149
150−not :: Text
150+not :: forall a. (IsString a) => a
151151not = "not"
152152
153−shl :: Text
153+shl :: forall a. (IsString a) => a
154154shl = "shl"
155155
156−shr :: Text
156+shr :: forall a. (IsString a) => a
157157shr = "shr"
158158
159−zshr :: Text
159+zshr :: forall a. (IsString a) => a
160160zshr = "zshr"
161161
162−complement :: Text
162+complement :: forall a. (IsString a) => a
163163complement = "complement"
164164
165165-- Prelude Values
166166
167−zero :: Text
167+zero :: forall a. (IsString a) => a
168168zero = "zero"
169169
170−one :: Text
170+one :: forall a. (IsString a) => a
171171one = "one"
172172
173−bottom :: Text
173+bottom :: forall a. (IsString a) => a
174174bottom = "bottom"
175175
176−top :: Text
176+top :: forall a. (IsString a) => a
177177top = "top"
178178
179−return :: Text
179+return :: forall a. (IsString a) => a
180180return = "return"
181181
182−pure' :: Text
182+pure' :: forall a. (IsString a) => a
183183pure' = "pure"
184184
185−returnEscaped :: Text
185+returnEscaped :: forall a. (IsString a) => a
186186returnEscaped = "$return"
187187
188−untilE :: Text
188+untilE :: forall a. (IsString a) => a
189189untilE = "untilE"
190190
191−whileE :: Text
191+whileE :: forall a. (IsString a) => a
192192whileE = "whileE"
193193
194−runST :: Text
194+runST :: forall a. (IsString a) => a
195195runST = "runST"
196196
197−stRefValue :: Text
197+stRefValue :: forall a. (IsString a) => a
198198stRefValue = "value"
199199
200−newSTRef :: Text
200+newSTRef :: forall a. (IsString a) => a
201201newSTRef = "newSTRef"
202202
203−readSTRef :: Text
203+readSTRef :: forall a. (IsString a) => a
204204readSTRef = "readSTRef"
205205
206−writeSTRef :: Text
206+writeSTRef :: forall a. (IsString a) => a
207207writeSTRef = "writeSTRef"
208208
209−modifySTRef :: Text
209+modifySTRef :: forall a. (IsString a) => a
210210modifySTRef = "modifySTRef"
211211
212−mkFn :: Text
212+mkFn :: forall a. (IsString a) => a
213213mkFn = "mkFn"
214214
215−runFn :: Text
215+runFn :: forall a. (IsString a) => a
216216runFn = "runFn"
217217
218−unit :: Text
218+unit :: forall a. (IsString a) => a
219219unit = "unit"
220220
221221-- Prim values
222222
223−undefined :: Text
223+undefined :: forall a. (IsString a) => a
224224undefined = "undefined"
225225
226226-- Type Class Dictionary Names
227227
228−monadEffDictionary :: Text
228+monadEffDictionary :: forall a. (IsString a) => a
229229monadEffDictionary = "monadEff"
230230
231−applicativeEffDictionary :: Text
231+applicativeEffDictionary :: forall a. (IsString a) => a
232232applicativeEffDictionary = "applicativeEff"
233233
234−bindEffDictionary :: Text
234+bindEffDictionary :: forall a. (IsString a) => a
235235bindEffDictionary = "bindEff"
236236
237−semiringNumber :: Text
237+semiringNumber :: forall a. (IsString a) => a
238238semiringNumber = "semiringNumber"
239239
240−semiringInt :: Text
240+semiringInt :: forall a. (IsString a) => a
241241semiringInt = "semiringInt"
242242
243−ringNumber :: Text
243+ringNumber :: forall a. (IsString a) => a
244244ringNumber = "ringNumber"
245245
246−ringInt :: Text
246+ringInt :: forall a. (IsString a) => a
247247ringInt = "ringInt"
248248
249−moduloSemiringNumber :: Text
249+moduloSemiringNumber :: forall a. (IsString a) => a
250250moduloSemiringNumber = "moduloSemiringNumber"
251251
252−moduloSemiringInt :: Text
252+moduloSemiringInt :: forall a. (IsString a) => a
253253moduloSemiringInt = "moduloSemiringInt"
254254
255−euclideanRingNumber :: Text
255+euclideanRingNumber :: forall a. (IsString a) => a
256256euclideanRingNumber = "euclideanRingNumber"
257257
258−euclideanRingInt :: Text
258+euclideanRingInt :: forall a. (IsString a) => a
259259euclideanRingInt = "euclideanRingInt"
260260
261−ordBoolean :: Text
261+ordBoolean :: forall a. (IsString a) => a
262262ordBoolean = "ordBoolean"
263263
264−ordNumber :: Text
264+ordNumber :: forall a. (IsString a) => a
265265ordNumber = "ordNumber"
266266
267−ordInt :: Text
267+ordInt :: forall a. (IsString a) => a
268268ordInt = "ordInt"
269269
270−ordString :: Text
270+ordString :: forall a. (IsString a) => a
271271ordString = "ordString"
272272
273−ordChar :: Text
273+ordChar :: forall a. (IsString a) => a
274274ordChar = "ordChar"
275275
276−eqNumber :: Text
276+eqNumber :: forall a. (IsString a) => a
277277eqNumber = "eqNumber"
278278
279−eqInt :: Text
279+eqInt :: forall a. (IsString a) => a
280280eqInt = "eqInt"
281281
282−eqString :: Text
282+eqString :: forall a. (IsString a) => a
283283eqString = "eqString"
284284
285−eqChar :: Text
285+eqChar :: forall a. (IsString a) => a
286286eqChar = "eqChar"
287287
288−eqBoolean :: Text
288+eqBoolean :: forall a. (IsString a) => a
289289eqBoolean = "eqBoolean"
290290
291−boundedBoolean :: Text
291+boundedBoolean :: forall a. (IsString a) => a
292292boundedBoolean = "boundedBoolean"
293293
294−booleanAlgebraBoolean :: Text
294+booleanAlgebraBoolean :: forall a. (IsString a) => a
295295booleanAlgebraBoolean = "booleanAlgebraBoolean"
296296
297−heytingAlgebraBoolean :: Text
297+heytingAlgebraBoolean :: forall a. (IsString a) => a
298298heytingAlgebraBoolean = "heytingAlgebraBoolean"
299299
300−semigroupString :: Text
300+semigroupString :: forall a. (IsString a) => a
301301semigroupString = "semigroupString"
302302
303−semigroupoidFn :: Text
303+semigroupoidFn :: forall a. (IsString a) => a
304304semigroupoidFn = "semigroupoidFn"
305305
306306-- Generic Deriving
307307
308−generic :: Text
308+generic :: forall a. (IsString a) => a
309309generic = "Generic"
310310
311−toSpine :: Text
311+toSpine :: forall a. (IsString a) => a
312312toSpine = "toSpine"
313313
314−fromSpine :: Text
314+fromSpine :: forall a. (IsString a) => a
315315fromSpine = "fromSpine"
316316
317−toSignature :: Text
317+toSignature :: forall a. (IsString a) => a
318318toSignature = "toSignature"
319319
320320-- Data.Symbol
@@ -352,12 +352,12 @@ orderingGT = Qualified (Just typeDataOrdering) (ProperName "GT")
352352
353353-- Main module
354354
355−main :: Text
355+main :: forall a. (IsString a) => a
356356main = "main"
357357
358358-- Prim
359359
360−partial :: Text
360+partial :: forall a. (IsString a) => a
361361partial = "Partial"
362362
363363pattern Prim :: ModuleName
@@ -369,78 +369,78 @@ pattern Partial = Qualified (Just Prim) (ProperName "Partial")
369369pattern Fail :: Qualified (ProperName 'ClassName)
370370pattern Fail = Qualified (Just Prim) (ProperName "Fail")
371371
372−typ :: Text
372+typ :: forall a. (IsString a) => a
373373typ = "Type"
374374
375−effect :: Text
375+effect :: forall a. (IsString a) => a
376376effect = "Effect"
377377
378−symbol :: Text
378+symbol :: forall a. (IsString a) => a
379379symbol = "Symbol"
380380
381381-- Code Generation
382382
383−__superclass_ :: Text
383+__superclass_ :: forall a. (IsString a) => a
384384__superclass_ = "__superclass_"
385385
386−__unused :: Text
386+__unused :: forall a. (IsString a) => a
387387__unused = "__unused"
388388
389389-- Modules
390390
391−prim :: Text
391+prim :: forall a. (IsString a) => a
392392prim = "Prim"
393393
394−prelude :: Text
394+prelude :: forall a. (IsString a) => a
395395prelude = "Prelude"
396396
397−dataArray :: Text
397+dataArray :: forall a. (IsString a) => a
398398dataArray = "Data_Array"
399399
400−eff :: Text
400+eff :: forall a. (IsString a) => a
401401eff = "Control_Monad_Eff"
402402
403−st :: Text
403+st :: forall a. (IsString a) => a
404404st = "Control_Monad_ST"
405405
406−controlApplicative :: Text
406+controlApplicative :: forall a. (IsString a) => a
407407controlApplicative = "Control_Applicative"
408408
409−controlSemigroupoid :: Text
409+controlSemigroupoid :: forall a. (IsString a) => a
410410controlSemigroupoid = "Control_Semigroupoid"
411411
412−controlBind :: Text
412+controlBind :: forall a. (IsString a) => a
413413controlBind = "Control_Bind"
414414
415−dataBounded :: Text
415+dataBounded :: forall a. (IsString a) => a
416416dataBounded = "Data_Bounded"
417417
418−dataSemigroup :: Text
418+dataSemigroup :: forall a. (IsString a) => a
419419dataSemigroup = "Data_Semigroup"
420420
421−dataHeytingAlgebra :: Text
421+dataHeytingAlgebra :: forall a. (IsString a) => a
422422dataHeytingAlgebra = "Data_HeytingAlgebra"
423423
424−dataEq :: Text
424+dataEq :: forall a. (IsString a) => a
425425dataEq = "Data_Eq"
426426
427−dataOrd :: Text
427+dataOrd :: forall a. (IsString a) => a
428428dataOrd = "Data_Ord"
429429
430−dataSemiring :: Text
430+dataSemiring :: forall a. (IsString a) => a
431431dataSemiring = "Data_Semiring"
432432
433−dataRing :: Text
433+dataRing :: forall a. (IsString a) => a
434434dataRing = "Data_Ring"
435435
436−dataEuclideanRing :: Text
436+dataEuclideanRing :: forall a. (IsString a) => a
437437dataEuclideanRing = "Data_EuclideanRing"
438438
439−dataFunction :: Text
439+dataFunction :: forall a. (IsString a) => a
440440dataFunction = "Data_Function"
441441
442−dataFunctionUncurried :: Text
442+dataFunctionUncurried :: forall a. (IsString a) => a
443443dataFunctionUncurried = "Data_Function_Uncurried"
444444
445−dataIntBits :: Text
445+dataIntBits :: forall a. (IsString a) => a
446446dataIntBits = "Data_Int_Bits"
src/Language/PureScript/Pretty/JS.hs+4−2
@@ -162,8 +162,10 @@ conditional = mkPattern match
162162accessor :: (Emit gen) => Pattern PrinterState JS (gen, JS)
163163accessor = mkPattern match
164164 where
165− -- WARN: if `prop` does not match the `IdentifierName` grammar, this will generate invalid code; see #2513
166− match (JSAccessor _ prop val) = Just (emit prop, val)
165+ match (JSIndexer _ (JSStringLiteral _ prop) val) =
166+ case decodeString prop of
167+ Just s | not (identNeedsEscaping s) -> Just (emit s, val)
168+ _ -> Nothing
167169 match _ = Nothing
168170
169171indexer :: (Emit gen) => Pattern PrinterState JS (gen, JS)