@@ -1,486 +1,30 @@
1-----------------------------------------------------------------------------
1-----------------------------------------------------------------------------
3−-- Module : Language.PureScript.Declarations
3+-- Module : Language.PureScript.AST.Traversals
4−-- Copyright : (c) Phil Freeman 2013
4+-- Copyright : (c) 2013-14 Phil Freeman, (c) 2014 Gary Burgess, and other contributors
5-- License : MIT
5-- License : MIT
7-- Maintainer : Phil Freeman <paf31@cantab.net>
7-- Maintainer : Phil Freeman <paf31@cantab.net>
8-- Stability : experimental
8-- Stability : experimental
9-- Portability :
9-- Portability :
11−-- | Data types for modules and declarations
11+-- | AST traversal helpers
13-----------------------------------------------------------------------------
13-----------------------------------------------------------------------------
15−{-# LANGUAGE DeriveDataTypeable, ScopedTypeVariables #-}
17−module Language.PureScript.Declarations where
15+module Language.PureScript.AST.Traversals where
19import Data.Monoid (Monoid(..), mconcat)
17import Data.Monoid (Monoid(..), mconcat)
21−import qualified Data.Data as D
23import Control.Applicative
19import Control.Applicative
24import Control.Monad
20import Control.Monad
25import Control.Arrow ((***), (+++))
21import Control.Arrow ((***), (+++))
23+import Language.PureScript.AST.Binders
24+import Language.PureScript.AST.Declarations
27import Language.PureScript.Types
25import Language.PureScript.Types
28−import Language.PureScript.Names
29−import Language.PureScript.Kinds
30−import Language.PureScript.TypeClassDictionaries
31−import Language.PureScript.CodeGen.JS.AST
32−import Language.PureScript.Environment
33import Language.PureScript.Traversals
26import Language.PureScript.Traversals
36−-- A precedence level for an infix operator
38−type Precedence = Integer
41−-- Associativity for infix operators
43−data Associativity = Infixl | Infixr | Infix deriving (D.Data, D.Typeable)
45−instance Show Associativity where
46− show Infixl = "infixl"
47− show Infixr = "infixr"
51−-- Source position information
53−data SourcePos = SourcePos
61− , sourcePosLine :: Int
65− , sourcePosColumn :: Int
66− } deriving (D.Data, D.Typeable)
68−instance Show SourcePos where
69− show sp = (sourceName sp) ++ " line " ++ show (sourcePosLine sp) ++ ", column " ++ show (sourcePosColumn sp)
72−-- Fixity data for infix operators
74−data Fixity = Fixity Associativity Precedence deriving (Show, D.Data, D.Typeable)
77−-- A module declaration, consisting of a module name, a list of declarations, and a list of the
78−-- declarations that are explicitly exported. If the export list is Nothing, everything is exported.
80−data Module = Module ModuleName [Declaration] (Maybe [DeclarationRef]) deriving (Show, D.Data, D.Typeable)
83−-- An item in a list of explicit imports or exports
87− -- A type constructor with data constructors
89− = TypeRef ProperName (Maybe [ProperName])
97− | TypeClassRef ProperName
99− -- A type class instance, created during typeclass desugaring (name, class name, instance types)
101− | TypeInstanceRef Ident
103− -- A declaration reference with source position information
105− | PositionedDeclarationRef SourcePos DeclarationRef
106− deriving (Show, D.Data, D.Typeable)
108−instance Eq DeclarationRef where
109− (TypeRef name dctors) == (TypeRef name' dctors') = name == name' && dctors == dctors'
110− (ValueRef name) == (ValueRef name') = name == name'
111− (TypeClassRef name) == (TypeClassRef name') = name == name'
112− (TypeInstanceRef name) == (TypeInstanceRef name') = name == name'
113− (PositionedDeclarationRef _ r) == r' = r == r'
114− r == (PositionedDeclarationRef _ r') = r == r'
118−-- The data type which specifies type of import declaration
120−data ImportDeclarationType
122− -- Unqualified import
126− -- Qualified import with a list of references to import
128− | Qualifying [DeclarationRef]
130− -- Import with hiding clause with a list of references to hide
132− | Hiding [DeclarationRef]
133− deriving (Show, D.Data, D.Typeable)
136−-- The data type of declarations
140− -- A data type declaration (data or newtype, name, arguments, data constructors)
142− = DataDeclaration DataDeclType ProperName [(String, Maybe Kind)] [(ProperName, [Type])]
144− -- A minimal mutually recursive set of data type declarations
146− | DataBindingGroupDeclaration [Declaration]
148− -- A type synonym declaration (name, arguments, type)
150− | TypeSynonymDeclaration ProperName [(String, Maybe Kind)] Type
152− -- A type declaration for a value (name, ty)
154− | TypeDeclaration Ident Type
156− -- A value declaration (name, top-level binders, optional guard, value)
158− | ValueDeclaration Ident NameKind [Binder] (Either [(Guard, Expr)] Expr)
160− -- A minimal mutually recursive set of value declarations
162− | BindingGroupDeclaration [(Ident, NameKind, Expr)]
164− -- A foreign import declaration (type, name, optional inline Javascript, type)
166− | ExternDeclaration ForeignImportType Ident (Maybe JS) Type
168− -- A data type foreign import (name, kind)
170− | ExternDataDeclaration ProperName Kind
172− -- A type class instance foreign import
174− | ExternInstanceDeclaration Ident [(Qualified ProperName, [Type])] (Qualified ProperName) [Type]
176− -- A fixity declaration (fixity data, operator name)
178− | FixityDeclaration Fixity String
180− -- A module import (module name, qualified/unqualified/hiding, optional "qualified as" name)
182− | ImportDeclaration ModuleName ImportDeclarationType (Maybe ModuleName)
184− -- A type class declaration (name, argument, implies, member declarations)
186− | TypeClassDeclaration ProperName [(String, Maybe Kind)] [(Qualified ProperName, [Type])] [Declaration]
188− -- A type instance declaration (name, dependencies, class name, instance types, member
191− | TypeInstanceDeclaration Ident [(Qualified ProperName, [Type])] (Qualified ProperName) [Type] [Declaration]
193− -- A declaration with source position information
195− | PositionedDeclaration SourcePos Declaration
196− deriving (Show, D.Data, D.Typeable)
199−-- Test if a declaration is a value declaration
201−isValueDecl :: Declaration -> Bool
202−isValueDecl ValueDeclaration{} = True
203−isValueDecl (PositionedDeclaration _ d) = isValueDecl d
204−isValueDecl _ = False
207−-- Test if a declaration is a data type or type synonym declaration
209−isDataDecl :: Declaration -> Bool
210−isDataDecl DataDeclaration{} = True
211−isDataDecl TypeSynonymDeclaration{} = True
212−isDataDecl (PositionedDeclaration _ d) = isDataDecl d
216−-- Test if a declaration is a module import
218−isImportDecl :: Declaration -> Bool
219−isImportDecl ImportDeclaration{} = True
220−isImportDecl (PositionedDeclaration _ d) = isImportDecl d
221−isImportDecl _ = False
224−-- Test if a declaration is a data type foreign import
226−isExternDataDecl :: Declaration -> Bool
227−isExternDataDecl ExternDataDeclaration{} = True
228−isExternDataDecl (PositionedDeclaration _ d) = isExternDataDecl d
229−isExternDataDecl _ = False
232−-- Test if a declaration is a type class instance foreign import
234−isExternInstanceDecl :: Declaration -> Bool
235−isExternInstanceDecl ExternInstanceDeclaration{} = True
236−isExternInstanceDecl (PositionedDeclaration _ d) = isExternInstanceDecl d
237−isExternInstanceDecl _ = False
240−-- Test if a declaration is a fixity declaration
242−isFixityDecl :: Declaration -> Bool
243−isFixityDecl FixityDeclaration{} = True
244−isFixityDecl (PositionedDeclaration _ d) = isFixityDecl d
245−isFixityDecl _ = False
248−-- Test if a declaration is a foreign import
250−isExternDecl :: Declaration -> Bool
251−isExternDecl ExternDeclaration{} = True
252−isExternDecl (PositionedDeclaration _ d) = isExternDecl d
253−isExternDecl _ = False
256−-- Test if a declaration is a type class or instance declaration
258−isTypeClassDeclaration :: Declaration -> Bool
259−isTypeClassDeclaration TypeClassDeclaration{} = True
260−isTypeClassDeclaration TypeInstanceDeclaration{} = True
261−isTypeClassDeclaration (PositionedDeclaration _ d) = isTypeClassDeclaration d
262−isTypeClassDeclaration _ = False
265−-- A guard is just a boolean-valued expression that appears alongside a set of binders
270−-- Data type for expressions and terms
274− -- A numeric literal
276− = NumericLiteral (Either Integer Double)
280− | StringLiteral String
282− -- A boolean literal
284− | BooleanLiteral Bool
286− -- A prefix -, will be desugared
290− -- Binary operator application. During the rebracketing phase of desugaring, this data constructor
293− | BinaryNoParens (Qualified Ident) Expr Expr
295− -- Explicit parentheses. During the rebracketing phase of desugaring, this data constructor
302− | ArrayLiteral [Expr]
304− -- An object literal
306− | ObjectLiteral [(String, Expr)]
308− -- An record property accessor expression
310− | Accessor String Expr
312− -- Partial record update
314− | ObjectUpdate Expr [(String, Expr)]
316− -- Function introduction
318− | Abs (Either Ident Binder) Expr
320− -- Function application
326− | Var (Qualified Ident)
328− -- Conditional (if-then-else expression)
330− | IfThenElse Expr Expr Expr
332− -- A data constructor
334− | Constructor (Qualified ProperName)
336− -- A case expression. During the case expansion phase of desugaring, top-level binders will get
337− -- desugared into case expressions, hence the need for guards and multiple binders per branch here.
339− | Case [Expr] [CaseAlternative]
341− -- A value with a type annotation
343− | TypedValue Bool Expr Type
347− | Let [Declaration] Expr
349− -- A do-notation block
351− | Do [DoNotationElement]
353− -- An application of a typeclass dictionary constructor. The value should be
354− -- an ObjectLiteral.
356− | TypeClassDictionaryConstructorApp (Qualified ProperName) Expr
358− -- A placeholder for a type class dictionary to be inserted later. At the end of type checking, these
359− -- placeholders will be replaced with actual expressions representing type classes dictionaries which
360− -- can be evaluated at runtime. The constructor arguments represent (in order): whether or not to look
361− -- at superclass implementations when searching for a dictionary, the type class name and
362− -- instance type, and the type class dictionaries in scope.
364− | TypeClassDictionary Bool (Qualified ProperName, [Type]) [TypeClassDictionaryInScope]
366− -- A placeholder for a superclass dictionary to be turned into a TypeClassDictionary during typechecking
368− | SuperClassDictionary (Qualified ProperName) [Type]
370− -- A value with source position information
372− | PositionedValue SourcePos Expr deriving (Show, D.Data, D.Typeable)
375−-- An alternative in a case statement
377−data CaseAlternative = CaseAlternative
379− -- A collection of binders with which to match the inputs
381− caseAlternativeBinders :: [Binder]
383− -- The result expression or a collect of guarded expressions
385− , caseAlternativeResult :: Either [(Guard, Expr)] Expr
386− } deriving (Show, D.Data, D.Typeable)
389−-- Find the original dictionary which a type class dictionary in scope refers to
391−canonicalizeDictionary :: TypeClassDictionaryInScope -> Qualified Ident
392−canonicalizeDictionary (TypeClassDictionaryInScope { tcdType = TCDRegular, tcdName = nm }) = nm
393−canonicalizeDictionary (TypeClassDictionaryInScope { tcdType = TCDAlias nm }) = nm
396−-- A statement in a do-notation block
398−data DoNotationElement
400− -- A monadic value without a binder
402− = DoNotationValue Expr
404− -- A monadic value with a binder
406− | DoNotationBind Binder Expr
408− -- A let statement, i.e. a pure value with a binder
410− | DoNotationLet [Declaration]
412− -- A do notation element with source position information
414− | PositionedDoNotationElement SourcePos DoNotationElement deriving (Show, D.Data, D.Typeable)
417−-- Data type for binders
425− -- A binder which matches a boolean literal
427− | BooleanBinder Bool
429− -- A binder which matches a string literal
431− | StringBinder String
433− -- A binder which matches a numeric literal
435− | NumberBinder (Either Integer Double)
437− -- A binder which binds an identifier
441− -- A binder which matches a data constructor
443− | ConstructorBinder (Qualified ProperName) [Binder]
445− -- A binder which matches a record and binds its properties
447− | ObjectBinder [(String, Binder)]
449− -- A binder which matches an array and binds its elements
451− | ArrayBinder [Binder]
453− -- A binder which matches an array and binds its head and tail
455− | ConsBinder Binder Binder
457− -- A binder which binds its input to an identifier
459− | NamedBinder Ident Binder
461− -- A binder with source position information
463− | PositionedBinder SourcePos Binder deriving (Show, D.Data, D.Typeable)
466−-- Collect all names introduced in binders in an expression
468−binderNames :: Binder -> [Ident]
471− go ns (VarBinder name) = name : ns
472− go ns (ConstructorBinder _ bs) = foldl go ns bs
473− go ns (ObjectBinder bs) = foldl go ns (map snd bs)
474− go ns (ArrayBinder bs) = foldl go ns bs
475− go ns (ConsBinder b1 b2) = go (go ns b1) b2
476− go ns (NamedBinder name b) = go (name : ns) b
477− go ns (PositionedBinder _ b) = go ns b
484everywhereOnValues :: (Declaration -> Declaration) ->
28everywhereOnValues :: (Declaration -> Declaration) ->
485 (Expr -> Expr) ->
29 (Expr -> Expr) ->
486 (Binder -> Binder) ->
30 (Binder -> Binder) ->
@@ -545,7 +89,7 @@ everywhereOnValuesTopDownM :: (Functor m, Applicative m, Monad m) =>
545everywhereOnValuesTopDownM f g h = (f' <=< f, g' <=< g, h' <=< h)
89everywhereOnValuesTopDownM f g h = (f' <=< f, g' <=< g, h' <=< h)
547 f' (DataBindingGroupDeclaration ds) = DataBindingGroupDeclaration <$> mapM (f' <=< f) ds
91 f' (DataBindingGroupDeclaration ds) = DataBindingGroupDeclaration <$> mapM (f' <=< f) ds
548− f' (ValueDeclaration name nameKind bs val) = ValueDeclaration name nameKind <$> mapM (h' <=< h) bs <*> eitherM (mapM (pairM (g' <=< g) (g' <=< g))) (g' <=< g) val
92+ f' (ValueDeclaration name nameKind bs val) = ValueDeclaration name nameKind <$> mapM (h' <=< h) bs <*> eitherM (mapM (pairM (g' <=< g) (g' <=< g))) (g' <=< g) val
549 f' (BindingGroupDeclaration ds) = BindingGroupDeclaration <$> mapM (\(name, nameKind, val) -> (,,) name nameKind <$> (g val >>= g')) ds
93 f' (BindingGroupDeclaration ds) = BindingGroupDeclaration <$> mapM (\(name, nameKind, val) -> (,,) name nameKind <$> (g val >>= g')) ds
550 f' (TypeClassDeclaration name args implies ds) = TypeClassDeclaration name args implies <$> mapM (f' <=< f) ds
94 f' (TypeClassDeclaration name args implies ds) = TypeClassDeclaration name args implies <$> mapM (f' <=< f) ds
551 f' (TypeInstanceDeclaration name cs className args ds) = TypeInstanceDeclaration name cs className args <$> mapM (f' <=< f) ds
95 f' (TypeInstanceDeclaration name cs className args ds) = TypeInstanceDeclaration name cs className args <$> mapM (f' <=< f) ds
@@ -602,7 +146,7 @@ everywhereOnValuesM f g h = (f' <=< f, g' <=< g, h' <=< h)
602 f' other = f other
146 f' other = f other
604 g' (UnaryMinus v) = (UnaryMinus <$> g' v) >>= g
148 g' (UnaryMinus v) = (UnaryMinus <$> g' v) >>= g
605− g' (BinaryNoParens op v1 v2) = (BinaryNoParens op <$> (g' v1) <*> (g' v2)) >>= g
149+ g' (BinaryNoParens op v1 v2) = (BinaryNoParens op <$> g' v1 <*> g' v2) >>= g
606 g' (Parens v) = (Parens <$> g' v) >>= g
150 g' (Parens v) = (Parens <$> g' v) >>= g
607 g' (ArrayLiteral vs) = (ArrayLiteral <$> mapM g' vs) >>= g
151 g' (ArrayLiteral vs) = (ArrayLiteral <$> mapM g' vs) >>= g
608 g' (ObjectLiteral vs) = (ObjectLiteral <$> mapM (sndM g') vs) >>= g
152 g' (ObjectLiteral vs) = (ObjectLiteral <$> mapM (sndM g') vs) >>= g
@@ -666,7 +210,7 @@ everythingOnValues (<>) f g h i j = (f', g', h', i', j')
666 g' v@(IfThenElse v1 v2 v3) = g v <> g' v1 <> g' v2 <> g' v3
210 g' v@(IfThenElse v1 v2 v3) = g v <> g' v1 <> g' v2 <> g' v3
667 g' v@(Case vs alts) = foldl (<>) (foldl (<>) (g v) (map g' vs)) (map i' alts)
211 g' v@(Case vs alts) = foldl (<>) (foldl (<>) (g v) (map g' vs)) (map i' alts)
668 g' v@(TypedValue _ v1 _) = g v <> g' v1
212 g' v@(TypedValue _ v1 _) = g v <> g' v1
669− g' v@(Let ds v1) = (foldl (<>) (g v) (map f' ds)) <> g' v1
213+ g' v@(Let ds v1) = foldl (<>) (g v) (map f' ds) <> g' v1
670 g' v@(Do es) = foldl (<>) (g v) (map j' es)
214 g' v@(Do es) = foldl (<>) (g v) (map j' es)
671 g' v@(PositionedValue _ v1) = g v <> g' v1
215 g' v@(PositionedValue _ v1) = g v <> g' v1
672 g' v = g v
216 g' v = g v
@@ -692,12 +236,12 @@ everythingWithContextOnValues ::
693 (r -> r -> r) ->
237 (r -> r -> r) ->
694 (s -> Declaration -> (s, r)) ->
238 (s -> Declaration -> (s, r)) ->
695− (s -> Expr -> (s, r)) ->
239+ (s -> Expr -> (s, r)) ->
696 (s -> Binder -> (s, r)) ->
240 (s -> Binder -> (s, r)) ->
697 (s -> CaseAlternative -> (s, r)) ->
241 (s -> CaseAlternative -> (s, r)) ->
698 (s -> DoNotationElement -> (s, r)) ->
242 (s -> DoNotationElement -> (s, r)) ->
699 ( Declaration -> r
243 ( Declaration -> r
700− , Expr -> r
244+ , Expr -> r
701 , Binder -> r
245 , Binder -> r
702 , CaseAlternative -> r
246 , CaseAlternative -> r
703 , DoNotationElement -> r)
247 , DoNotationElement -> r)
@@ -706,32 +250,32 @@ everythingWithContextOnValues s0 r0 (<>) f g h i j = (f'' s0, g'' s0, h'' s0, i'
706 f'' s d = let (s', r) = f s d in r <> f' s' d
250 f'' s d = let (s', r) = f s d in r <> f' s' d
708 f' s (DataBindingGroupDeclaration ds) = foldl (<>) r0 (map (f'' s) ds)
252 f' s (DataBindingGroupDeclaration ds) = foldl (<>) r0 (map (f'' s) ds)
709− f' s (ValueDeclaration _ _ bs (Right val)) = foldl (<>) r0 (map (h'' s) bs) <> (g'' s) val
253+ f' s (ValueDeclaration _ _ bs (Right val)) = foldl (<>) r0 (map (h'' s) bs) <> g'' s val
710 f' s (ValueDeclaration _ _ bs (Left gs)) = foldl (<>) r0 (map (h'' s) bs ++ concatMap (\(grd, val) -> [g'' s grd, g'' s val]) gs)
254 f' s (ValueDeclaration _ _ bs (Left gs)) = foldl (<>) r0 (map (h'' s) bs ++ concatMap (\(grd, val) -> [g'' s grd, g'' s val]) gs)
711− f' s (BindingGroupDeclaration ds) = foldl (<>) r0 (map (\(_, _, val) -> (g'' s) val) ds)
255+ f' s (BindingGroupDeclaration ds) = foldl (<>) r0 (map (\(_, _, val) -> g'' s val) ds)
712 f' s (TypeClassDeclaration _ _ _ ds) = foldl (<>) r0 (map (f'' s) ds)
256 f' s (TypeClassDeclaration _ _ _ ds) = foldl (<>) r0 (map (f'' s) ds)
713 f' s (TypeInstanceDeclaration _ _ _ _ ds) = foldl (<>) r0 (map (f'' s) ds)
257 f' s (TypeInstanceDeclaration _ _ _ _ ds) = foldl (<>) r0 (map (f'' s) ds)
714− f' s (PositionedDeclaration _ d1) = (f'' s) d1
258+ f' s (PositionedDeclaration _ d1) = f'' s d1
715 f' _ _ = r0
259 f' _ _ = r0
717 g'' s v = let (s', r) = g s v in r <> g' s' v
261 g'' s v = let (s', r) = g s v in r <> g' s' v
719− g' s (UnaryMinus v1) = (g'' s) v1
263+ g' s (UnaryMinus v1) = g'' s v1
720− g' s (BinaryNoParens _ v1 v2) = (g'' s) v1 <> (g'' s) v2
264+ g' s (BinaryNoParens _ v1 v2) = g'' s v1 <> g'' s v2
721− g' s (Parens v1) = (g'' s) v1
265+ g' s (Parens v1) = g'' s v1
722 g' s (ArrayLiteral vs) = foldl (<>) r0 (map (g'' s) vs)
266 g' s (ArrayLiteral vs) = foldl (<>) r0 (map (g'' s) vs)
723 g' s (ObjectLiteral vs) = foldl (<>) r0 (map (g'' s . snd) vs)
267 g' s (ObjectLiteral vs) = foldl (<>) r0 (map (g'' s . snd) vs)
724− g' s (TypeClassDictionaryConstructorApp _ v1) = (g'' s) v1
268+ g' s (TypeClassDictionaryConstructorApp _ v1) = g'' s v1
725− g' s (Accessor _ v1) = (g'' s) v1
269+ g' s (Accessor _ v1) = g'' s v1
726− g' s (ObjectUpdate obj vs) = foldl (<>) ((g'' s) obj) (map (g'' s . snd) vs)
270+ g' s (ObjectUpdate obj vs) = foldl (<>) (g'' s obj) (map (g'' s . snd) vs)
727− g' s (Abs _ v1) = (g'' s) v1
271+ g' s (Abs _ v1) = g'' s v1
728− g' s (App v1 v2) = (g'' s) v1 <> (g'' s) v2
272+ g' s (App v1 v2) = g'' s v1 <> g'' s v2
729− g' s (IfThenElse v1 v2 v3) = (g'' s) v1 <> (g'' s) v2 <> (g'' s) v3
273+ g' s (IfThenElse v1 v2 v3) = g'' s v1 <> g'' s v2 <> g'' s v3
730 g' s (Case vs alts) = foldl (<>) (foldl (<>) r0 (map (g'' s) vs)) (map (i'' s) alts)
274 g' s (Case vs alts) = foldl (<>) (foldl (<>) r0 (map (g'' s) vs)) (map (i'' s) alts)
731− g' s (TypedValue _ v1 _) = (g'' s) v1
275+ g' s (TypedValue _ v1 _) = g'' s v1
732− g' s (Let ds v1) = (foldl (<>) r0 (map (f'' s) ds)) <> (g'' s) v1
276+ g' s (Let ds v1) = foldl (<>) r0 (map (f'' s) ds) <> g'' s v1
733 g' s (Do es) = foldl (<>) r0 (map (j'' s) es)
277 g' s (Do es) = foldl (<>) r0 (map (j'' s) es)
734− g' s (PositionedValue _ v1) = (g'' s) v1
278+ g' s (PositionedValue _ v1) = g'' s v1
735 g' _ _ = r0
279 g' _ _ = r0
737 h'' s b = let (s', r) = h s b in r <> h' s' b
281 h'' s b = let (s', r) = h s b in r <> h' s' b
@@ -739,9 +283,9 @@ everythingWithContextOnValues s0 r0 (<>) f g h i j = (f'' s0, g'' s0, h'' s0, i'
739 h' s (ConstructorBinder _ bs) = foldl (<>) r0 (map (h'' s) bs)
283 h' s (ConstructorBinder _ bs) = foldl (<>) r0 (map (h'' s) bs)
740 h' s (ObjectBinder bs) = foldl (<>) r0 (map (h'' s . snd) bs)
284 h' s (ObjectBinder bs) = foldl (<>) r0 (map (h'' s . snd) bs)
741 h' s (ArrayBinder bs) = foldl (<>) r0 (map (h'' s) bs)
285 h' s (ArrayBinder bs) = foldl (<>) r0 (map (h'' s) bs)
742− h' s (ConsBinder b1 b2) = (h'' s) b1 <> (h'' s) b2
286+ h' s (ConsBinder b1 b2) = h'' s b1 <> h'' s b2
743− h' s (NamedBinder _ b1) = (h'' s) b1
287+ h' s (NamedBinder _ b1) = h'' s b1
744− h' s (PositionedBinder _ b1) = (h'' s) b1
288+ h' s (PositionedBinder _ b1) = h'' s b1
745 h' _ _ = r0
289 h' _ _ = r0
747 i'' s ca = let (s', r) = i s ca in r <> i' s' ca
291 i'' s ca = let (s', r) = i s ca in r <> i' s' ca
@@ -751,20 +295,20 @@ everythingWithContextOnValues s0 r0 (<>) f g h i j = (f'' s0, g'' s0, h'' s0, i'
752 j'' s e = let (s', r) = j s e in r <> j' s' e
296 j'' s e = let (s', r) = j s e in r <> j' s' e
754− j' s (DoNotationValue v) = (g'' s) v
298+ j' s (DoNotationValue v) = g'' s v
755− j' s (DoNotationBind b v) = (h'' s) b <> (g'' s) v
299+ j' s (DoNotationBind b v) = h'' s b <> g'' s v
756 j' s (DoNotationLet ds) = foldl (<>) r0 (map (f'' s) ds)
300 j' s (DoNotationLet ds) = foldl (<>) r0 (map (f'' s) ds)
757− j' s (PositionedDoNotationElement _ e1) = (j'' s) e1
301+ j' s (PositionedDoNotationElement _ e1) = j'' s e1
759everywhereWithContextOnValuesM :: (Functor m, Applicative m, Monad m) =>
303everywhereWithContextOnValuesM :: (Functor m, Applicative m, Monad m) =>
761 (s -> Declaration -> m (s, Declaration)) ->
305 (s -> Declaration -> m (s, Declaration)) ->
762− (s -> Expr -> m (s, Expr)) ->
306+ (s -> Expr -> m (s, Expr)) ->
763 (s -> Binder -> m (s, Binder)) ->
307 (s -> Binder -> m (s, Binder)) ->
764 (s -> CaseAlternative -> m (s, CaseAlternative)) ->
308 (s -> CaseAlternative -> m (s, CaseAlternative)) ->
765 (s -> DoNotationElement -> m (s, DoNotationElement)) ->
309 (s -> DoNotationElement -> m (s, DoNotationElement)) ->
766 ( Declaration -> m Declaration
310 ( Declaration -> m Declaration
767− , Expr -> m Expr
311+ , Expr -> m Expr
768 , Binder -> m Binder
312 , Binder -> m Binder
769 , CaseAlternative -> m CaseAlternative
313 , CaseAlternative -> m CaseAlternative
770 , DoNotationElement -> m DoNotationElement)
314 , DoNotationElement -> m DoNotationElement)
@@ -787,7 +331,7 @@ everywhereWithContextOnValuesM s0 f g h i j = (f'' s0, g'' s0, h'' s0, i'' s0, j
787 g' s (Parens v) = Parens <$> g'' s v
331 g' s (Parens v) = Parens <$> g'' s v
788 g' s (ArrayLiteral vs) = ArrayLiteral <$> mapM (g'' s) vs
332 g' s (ArrayLiteral vs) = ArrayLiteral <$> mapM (g'' s) vs
789 g' s (ObjectLiteral vs) = ObjectLiteral <$> mapM (sndM (g'' s)) vs
333 g' s (ObjectLiteral vs) = ObjectLiteral <$> mapM (sndM (g'' s)) vs
790− g' s (TypeClassDictionaryConstructorApp name v) = TypeClassDictionaryConstructorApp name <$> (g'' s) v
334+ g' s (TypeClassDictionaryConstructorApp name v) = TypeClassDictionaryConstructorApp name <$> g'' s v
791 g' s (Accessor prop v) = Accessor prop <$> g'' s v
335 g' s (Accessor prop v) = Accessor prop <$> g'' s v
792 g' s (ObjectUpdate obj vs) = ObjectUpdate <$> g'' s obj <*> mapM (sndM (g'' s)) vs
336 g' s (ObjectUpdate obj vs) = ObjectUpdate <$> g'' s obj <*> mapM (sndM (g'' s)) vs
793 g' s (Abs name v) = Abs name <$> g'' s v
337 g' s (Abs name v) = Abs name <$> g'' s v
@@ -837,5 +381,3 @@ accumTypes f = everythingOnValues mappend forDecls forValues (const mempty) (con
837 forValues (SuperClassDictionary _ tys) = mconcat (map f tys)
381 forValues (SuperClassDictionary _ tys) = mconcat (map f tys)
838 forValues (TypedValue _ _ ty) = f ty
382 forValues (TypedValue _ _ ty) = f ty
839 forValues _ = mempty
383 forValues _ = mempty