@@ -23,7 +23,7 @@ import Data.Foldable (fold)
2323import qualified Data.Set as S
2424
2525import Control.Monad
26−import Control.Arrow ((***), (+++), second)
26+import Control.Arrow ((***), (+++))
2727
2828import Language.PureScript.AST.Binders
2929import Language.PureScript.AST.Declarations
@@ -49,16 +49,13 @@ everywhereOnValues f g h = (f', g', h')
4949 g' :: Expr -> Expr
5050 g' (UnaryMinus v) = g (UnaryMinus (g' v))
5151 g' (BinaryNoParens op v1 v2) = g (BinaryNoParens (g' op) (g' v1) (g' v2))
52− g' (Parens v) = g (Parens (g' v))
5352 g' (OperatorSection op (Left v)) = g (OperatorSection (g' op) (Left $ g' v))
5453 g' (OperatorSection op (Right v)) = g (OperatorSection (g' op) (Right $ g' v))
5554 g' (ArrayLiteral vs) = g (ArrayLiteral (map g' vs))
5655 g' (ObjectLiteral vs) = g (ObjectLiteral (map (fmap g') vs))
57− g' (ObjectConstructor vs) = g (ObjectConstructor (map (second (fmap g')) vs))
5856 g' (TypeClassDictionaryConstructorApp name v) = g (TypeClassDictionaryConstructorApp name (g' v))
5957 g' (Accessor prop v) = g (Accessor prop (g' v))
6058 g' (ObjectUpdate obj vs) = g (ObjectUpdate (g' obj) (map (fmap g') vs))
61− g' (ObjectUpdater obj vs) = g (ObjectUpdater (fmap g' obj) (map (second (fmap g')) vs))
6259 g' (Abs name v) = g (Abs name (g' v))
6360 g' (App v1 v2) = g (App (g' v1) (g' v2))
6461 g' (IfThenElse v1 v2 v3) = g (IfThenElse (g' v1) (g' v2) (g' v3))
@@ -107,16 +104,13 @@ everywhereOnValuesTopDownM f g h = (f' <=< f, g' <=< g, h' <=< h)
107104
108105 g' (UnaryMinus v) = UnaryMinus <$> (g v >>= g')
109106 g' (BinaryNoParens op v1 v2) = BinaryNoParens <$> (g op >>= g') <*> (g v1 >>= g') <*> (g v2 >>= g')
110− g' (Parens v) = Parens <$> (g v >>= g')
111107 g' (OperatorSection op (Left v)) = OperatorSection <$> (g op >>= g') <*> (Left <$> (g v >>= g'))
112108 g' (OperatorSection op (Right v)) = OperatorSection <$> (g op >>= g') <*> (Right <$> (g v >>= g'))
113109 g' (ArrayLiteral vs) = ArrayLiteral <$> traverse (g' <=< g) vs
114110 g' (ObjectLiteral vs) = ObjectLiteral <$> traverse (sndM (g' <=< g)) vs
115− g' (ObjectConstructor vs) = ObjectConstructor <$> traverse (sndM $ maybeM (g' <=< g)) vs
116111 g' (TypeClassDictionaryConstructorApp name v) = TypeClassDictionaryConstructorApp name <$> (g v >>= g')
117112 g' (Accessor prop v) = Accessor prop <$> (g v >>= g')
118113 g' (ObjectUpdate obj vs) = ObjectUpdate <$> (g obj >>= g') <*> traverse (sndM (g' <=< g)) vs
119− g' (ObjectUpdater obj vs) = ObjectUpdater <$> (maybeM g obj >>= maybeM g') <*> traverse (sndM $ maybeM (g' <=< g)) vs
120114 g' (Abs name v) = Abs name <$> (g v >>= g')
121115 g' (App v1 v2) = App <$> (g v1 >>= g') <*> (g v2 >>= g')
122116 g' (IfThenElse v1 v2 v3) = IfThenElse <$> (g v1 >>= g') <*> (g v2 >>= g') <*> (g v3 >>= g')
@@ -160,16 +154,13 @@ everywhereOnValuesM f g h = (f', g', h')
160154
161155 g' (UnaryMinus v) = (UnaryMinus <$> g' v) >>= g
162156 g' (BinaryNoParens op v1 v2) = (BinaryNoParens <$> g' op <*> g' v1 <*> g' v2) >>= g
163− g' (Parens v) = (Parens <$> g' v) >>= g
164157 g' (OperatorSection op (Left v)) = (OperatorSection <$> g' op <*> (Left <$> g' v)) >>= g
165158 g' (OperatorSection op (Right v)) = (OperatorSection <$> g' op <*> (Right <$> g' v)) >>= g
166159 g' (ArrayLiteral vs) = (ArrayLiteral <$> traverse g' vs) >>= g
167160 g' (ObjectLiteral vs) = (ObjectLiteral <$> traverse (sndM g') vs) >>= g
168− g' (ObjectConstructor vs) = (ObjectConstructor <$> traverse (sndM $ maybeM g') vs) >>= g
169161 g' (TypeClassDictionaryConstructorApp name v) = (TypeClassDictionaryConstructorApp name <$> g' v) >>= g
170162 g' (Accessor prop v) = (Accessor prop <$> g' v) >>= g
171163 g' (ObjectUpdate obj vs) = (ObjectUpdate <$> g' obj <*> traverse (sndM g') vs) >>= g
172− g' (ObjectUpdater obj vs) = (ObjectUpdater <$> maybeM g' obj <*> traverse (sndM $ maybeM g') vs) >>= g
173164 g' (Abs name v) = (Abs name <$> g' v) >>= g
174165 g' (App v1 v2) = (App <$> g' v1 <*> g' v2) >>= g
175166 g' (IfThenElse v1 v2 v3) = (IfThenElse <$> g' v1 <*> g' v2 <*> g' v3) >>= g
@@ -216,16 +207,13 @@ everythingOnValues (<>) f g h i j = (f', g', h', i', j')
216207
217208 g' v@(UnaryMinus v1) = g v <> g' v1
218209 g' v@(BinaryNoParens op v1 v2) = g v <> g' op <> g' v1 <> g' v2
219− g' v@(Parens v1) = g v <> g' v1
220210 g' v@(OperatorSection op (Left v1)) = g v <> g' op <> g' v1
221211 g' v@(OperatorSection op (Right v1)) = g v <> g' op <> g' v1
222212 g' v@(ArrayLiteral vs) = foldl (<>) (g v) (map g' vs)
223213 g' v@(ObjectLiteral vs) = foldl (<>) (g v) (map (g' . snd) vs)
224− g' v@(ObjectConstructor vs) = foldl (<>) (g v) (map g' (mapMaybe snd vs))
225214 g' v@(TypeClassDictionaryConstructorApp _ v1) = g v <> g' v1
226215 g' v@(Accessor _ v1) = g v <> g' v1
227216 g' v@(ObjectUpdate obj vs) = foldl (<>) (g v <> g' obj) (map (g' . snd) vs)
228− g' v@(ObjectUpdater obj vs) = foldl (<>) (maybe (g v) (\x -> g v <> g' x) obj) (map g' (mapMaybe snd vs))
229217 g' v@(Abs _ v1) = g v <> g' v1
230218 g' v@(App v1 v2) = g v <> g' v1 <> g' v2
231219 g' v@(IfThenElse v1 v2 v3) = g v <> g' v1 <> g' v2 <> g' v3
@@ -283,16 +271,13 @@ everythingWithContextOnValues s0 r0 (<>) f g h i j = (f'' s0, g'' s0, h'' s0, i'
283271
284272 g' s (UnaryMinus v1) = g'' s v1
285273 g' s (BinaryNoParens op v1 v2) = g'' s op <> g'' s v1 <> g'' s v2
286− g' s (Parens v1) = g'' s v1
287274 g' s (OperatorSection op (Left v)) = g'' s op <> g'' s v
288275 g' s (OperatorSection op (Right v)) = g'' s op <> g'' s v
289276 g' s (ArrayLiteral vs) = foldl (<>) r0 (map (g'' s) vs)
290277 g' s (ObjectLiteral vs) = foldl (<>) r0 (map (g'' s . snd) vs)
291− g' s (ObjectConstructor vs) = foldl (<>) r0 (map (g'' s) (mapMaybe snd vs))
292278 g' s (TypeClassDictionaryConstructorApp _ v1) = g'' s v1
293279 g' s (Accessor _ v1) = g'' s v1
294280 g' s (ObjectUpdate obj vs) = foldl (<>) (g'' s obj) (map (g'' s . snd) vs)
295− g' s (ObjectUpdater obj vs) = foldl (<>) (maybe r0 (g'' s) obj) (map (g'' s) (mapMaybe snd vs))
296281 g' s (Abs _ v1) = g'' s v1
297282 g' s (App v1 v2) = g'' s v1 <> g'' s v2
298283 g' s (IfThenElse v1 v2 v3) = g'' s v1 <> g'' s v2 <> g'' s v3
@@ -353,16 +338,13 @@ everywhereWithContextOnValuesM s0 f g h i j = (f'' s0, g'' s0, h'' s0, i'' s0, j
353338
354339 g' s (UnaryMinus v) = UnaryMinus <$> g'' s v
355340 g' s (BinaryNoParens op v1 v2) = BinaryNoParens <$> g'' s op <*> g'' s v1 <*> g'' s v2
356− g' s (Parens v) = Parens <$> g'' s v
357341 g' s (OperatorSection op (Left v)) = OperatorSection <$> g'' s op <*> (Left <$> g'' s v)
358342 g' s (OperatorSection op (Right v)) = OperatorSection <$> g'' s op <*> (Right <$> g'' s v)
359343 g' s (ArrayLiteral vs) = ArrayLiteral <$> traverse (g'' s) vs
360344 g' s (ObjectLiteral vs) = ObjectLiteral <$> traverse (sndM (g'' s)) vs
361− g' s (ObjectConstructor vs) = ObjectConstructor <$> traverse (sndM $ maybeM (g'' s)) vs
362345 g' s (TypeClassDictionaryConstructorApp name v) = TypeClassDictionaryConstructorApp name <$> g'' s v
363346 g' s (Accessor prop v) = Accessor prop <$> g'' s v
364347 g' s (ObjectUpdate obj vs) = ObjectUpdate <$> g'' s obj <*> traverse (sndM (g'' s)) vs
365− g' s (ObjectUpdater obj vs) = ObjectUpdater <$> maybeM (g'' s) obj <*> traverse (sndM $ maybeM (g'' s)) vs
366348 g' s (Abs name v) = Abs name <$> g'' s v
367349 g' s (App v1 v2) = App <$> g'' s v1 <*> g'' s v2
368350 g' s (IfThenElse v1 v2 v3) = IfThenElse <$> g'' s v1 <*> g'' s v2 <*> g'' s v3
@@ -435,16 +417,13 @@ everythingWithScope f g h i j = (f'', g'', h'', i'', \s -> snd . j'' s)
435417
436418 g' s (UnaryMinus v1) = g'' s v1
437419 g' s (BinaryNoParens op v1 v2) = g' s op <> g' s v1 <> g' s v2
438− g' s (Parens v1) = g'' s v1
439420 g' s (OperatorSection op (Left v)) = g'' s op <> g'' s v
440421 g' s (OperatorSection op (Right v)) = g'' s op <> g'' s v
441422 g' s (ArrayLiteral vs) = foldMap (g'' s) vs
442423 g' s (ObjectLiteral vs) = foldMap (g'' s . snd) vs
443− g' s (ObjectConstructor vs) = foldMap (g'' s) (mapMaybe snd vs)
444424 g' s (TypeClassDictionaryConstructorApp _ v1) = g'' s v1
445425 g' s (Accessor _ v1) = g'' s v1
446426 g' s (ObjectUpdate obj vs) = g'' s obj <> foldMap (g'' s . snd) vs
447− g' s (ObjectUpdater obj vs) = foldMap (g'' s) obj <> foldMap (g'' s) (mapMaybe snd vs)
448427 g' s (Abs (Left name) v1) =
449428 let s' = S.insert name s
450429 in g'' s' v1