-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Name resolution library for Haskell
--   
--   This package takes modules parsed with `haskell-src-exts`, resolves
--   used names and annotates the parsed module with scoping information.
@package haskell-names
@version 0.9.1

module Language.Haskell.Names.SyntaxUtils
dropAnn :: (Functor a) => a l -> a ()
setAnn :: (Functor a) => l' -> a l -> a l'
annName :: a -> a
nameQualification :: QName l -> Maybe (ModuleName ())
getModuleName :: Module l -> ModuleName l
getImports :: Module l -> [ImportDecl l]
getExportSpecList :: Module l -> Maybe (ExportSpecList l)
getDeclHead :: Decl l -> Maybe (DeclHead l)
getDeclHeadName :: DeclHead l -> Name l
getModuleDecls :: Module l -> [Decl l]
isTypeDecl :: Decl l -> Bool
opName :: Op l -> Name l
isCon :: Name l -> Bool
nameToString :: Name l -> String
stringToName :: String -> Name ()
specialConToString :: SpecialCon l -> String
qNameToName :: QName l -> Name l
nameToQName :: Name l -> QName l
unCName :: CName l -> Name l
getErrors :: (Ord l, Foldable a) => a (Scoped l) -> Set (Error l)
getModuleExtensions :: Module l -> (Maybe Language, [Extension])


-- | This module is designed to be imported qualified.
module Language.Haskell.Names.LocalSymbolTable

-- | Local symbol table — contains locally bound names
data Table
empty :: Table
lookupValue :: QName l -> Table -> Either (Error l) SrcLoc
addValue :: SrcInfo l => Name l -> Table -> Table
instance GHC.Base.Monoid Language.Haskell.Names.LocalSymbolTable.Table


-- | This module is designed to be imported qualified.
module Language.Haskell.Names.GlobalSymbolTable

-- | Global symbol table — contains names declared somewhere at the top
--   level.
type Table = Map (QName ()) [Symbol]

-- | Empty global symbol table.
empty :: Table

-- | For each name take the union of the lists of symbols they refer to.
mergeTables :: Table -> Table -> Table
lookupValue :: QName l -> Table -> [Symbol]
lookupType :: QName l -> Table -> [Symbol]
lookupMethodOrAssociate :: QName l -> Table -> [Symbol]
lookupSelector :: QName l -> Table -> [Symbol]
lookupName :: QName l -> Table -> [Symbol]
isValue :: Symbol -> Bool
isType :: Symbol -> Bool
isMethodOrAssociated :: Symbol -> Bool
isSelector :: Symbol -> Bool
fromList :: [(QName (), Symbol)] -> Table

module Language.Haskell.Names.Imports

-- | Compute a table of symbols imported by the given module from the given
--   environment.
importTable :: Environment -> Module l -> Table

-- | Annotate the given list of import declarations with scoping
--   information against the given environment. We need the name of the
--   module that contains the import declarations for error annotations.
annotateImportDecls :: ModuleName l -> Environment -> [ImportDecl l] -> [ImportDecl (Scoped l)]

module Language.Haskell.Names.GetBound

-- | Get bound value identifiers.
class GetBound a l | a -> l

-- | For record wildcards we need to know which fields the given
--   constructor has. So we pass the global table for that.
getBound :: GetBound a l => Table -> a -> [Name l]
instance Language.Haskell.Names.GetBound.GetBound a l => Language.Haskell.Names.GetBound.GetBound [a] l
instance Language.Haskell.Names.GetBound.GetBound a l => Language.Haskell.Names.GetBound.GetBound (GHC.Base.Maybe a) l
instance (Language.Haskell.Names.GetBound.GetBound a l, Language.Haskell.Names.GetBound.GetBound b l) => Language.Haskell.Names.GetBound.GetBound (a, b) l
instance Data.Data.Data l => Language.Haskell.Names.GetBound.GetBound (Language.Haskell.Exts.Syntax.Binds l) l
instance Data.Data.Data l => Language.Haskell.Names.GetBound.GetBound (Language.Haskell.Exts.Syntax.Decl l) l
instance Data.Data.Data l => Language.Haskell.Names.GetBound.GetBound (Language.Haskell.Exts.Syntax.QualConDecl l) l
instance Data.Data.Data l => Language.Haskell.Names.GetBound.GetBound (Language.Haskell.Exts.Syntax.GadtDecl l) l
instance Data.Data.Data l => Language.Haskell.Names.GetBound.GetBound (Language.Haskell.Exts.Syntax.ConDecl l) l
instance Data.Data.Data l => Language.Haskell.Names.GetBound.GetBound (Language.Haskell.Exts.Syntax.FieldDecl l) l
instance Data.Data.Data l => Language.Haskell.Names.GetBound.GetBound (Language.Haskell.Exts.Syntax.ClassDecl l) l
instance Data.Data.Data l => Language.Haskell.Names.GetBound.GetBound (Language.Haskell.Exts.Syntax.Match l) l
instance Data.Data.Data l => Language.Haskell.Names.GetBound.GetBound (Language.Haskell.Exts.Syntax.Stmt l) l
instance Data.Data.Data l => Language.Haskell.Names.GetBound.GetBound (Language.Haskell.Exts.Syntax.QualStmt l) l
instance Data.Data.Data l => Language.Haskell.Names.GetBound.GetBound (Language.Haskell.Exts.Syntax.Pat l) l

module Language.Haskell.Names.Open

-- | A type that implements <a>Resolvable</a> provides a way to perform a
--   shallow scope-aware traversal.
class Typeable a => Resolvable a
rtraverse :: (Resolvable a, Applicative f, ?alg :: Alg f) => a -> Scope -> f a

-- | The algebra for <a>rtraverse</a>. It's newtype-wrapped because an
--   implicit parameter cannot be polymorphic.
newtype Alg w
Alg :: (forall d. Resolvable d => d -> Scope -> w d) -> Alg w
[runAlg] :: Alg w -> forall d. Resolvable d => d -> Scope -> w d

-- | Analogous to <a>gmap</a>, but for <a>Resolvable</a>
rmap :: Resolvable a => (forall b. Resolvable b => Scope -> b -> b) -> Scope -> a -> a

-- | Analogous to <a>gmap</a>, but for <a>Resolvable</a>
rfoldMap :: (Monoid r, Resolvable a) => (forall b. Resolvable b => Scope -> b -> r) -> Scope -> a -> r

-- | Contains information about the node's enclosing scope. Can be accessed
--   through the lenses: <a>gTable</a>, <a>lTable</a>, <a>nameCtx</a>,
--   <tt>instanceQualification</tt>, <a>wcNames</a>. If we enter an
--   instance with a qualified class name we have to remember the
--   qualification to resolve method names.
data Scope

-- | Describes how we should treat names in the current context
data NameContext
BindingT :: NameContext
BindingV :: NameContext
ReferenceT :: NameContext
ReferenceV :: NameContext

-- | Reference a method in an instance declaration Unqualified names also
--   match qualified names in scope
--   <a>https://www.haskell.org/pipermail/haskell-prime/2008-April/002569.html</a>
ReferenceUV :: NameContext

-- | Reference an associated type in an instance declaration Unqualified
--   names also match qualified names in scope
--   <a>https://www.haskell.org/pipermail/haskell-prime/2008-April/002569.html</a>
ReferenceUT :: NameContext

-- | Reference a record field selector
ReferenceRS :: NameContext

-- | A type signature contains an always unqualified <a>Name</a> that
--   always refers to a value bound in the same module.
SignatureV :: NameContext
Other :: NameContext

-- | Create an initial scope
initialScope :: ModuleName () -> Table -> Scope
gTable :: Lens Scope Table
lTable :: Lens Scope Table
nameCtx :: Lens Scope NameContext

-- | Information about the names being introduced by a record wildcard
--   
--   During resolving traversal, we always (lazily) construct this list
--   when we process PRec or RecConstr, even if it doesn't contain a
--   wildcard.
--   
--   Then, if the pattern or construction actually contains a wildcard, we
--   use the computed value.
type WcNames = [WcField]

-- | Information about a field in the wildcard
data WcField
WcField :: Name () -> Symbol -> Bool -> WcField

-- | the field's simple name
[wcFieldName] :: WcField -> Name ()

-- | the field's selector symbol
[wcFieldSymbol] :: WcField -> Symbol

-- | whether there is a global value in scope with the same name as the
--   field but different from the field selector
[wcExistsGlobalValue] :: WcField -> Bool
wcNames :: Lens Scope WcNames

module Language.Haskell.Names.ModuleSymbols

-- | Compute the symbols that are defined in the given module.
--   
--   The import table is needed to resolve possible top-level record
--   wildcard bindings, such as
--   
--   <pre>
--   A {..} = foo
--   </pre>
moduleSymbols :: (Eq l, Data l) => Table -> Module l -> [Symbol]

-- | Compute module's global table. It contains both the imported entities
--   and the global entities defined in this module.
moduleTable :: (Eq l, Data l) => Table -> Module l -> Table
getTopDeclSymbols :: forall l. (Eq l, Data l) => Table -> ModuleName l -> Decl l -> [Symbol]

module Language.Haskell.Names.Exports

-- | Compute the list of symbols the given module exports using the given
--   table of symbols that are in scope in that module.
exportedSymbols :: (Data l, Eq l) => Table -> Module l -> [Symbol]

-- | Annotate the given export list with scoping information using the
--   given table of symbols that are in scope in that module.
annotateExportSpecList :: Table -> ExportSpecList l -> ExportSpecList (Scoped l)

module Language.Haskell.Names.Annotated

-- | A pair of the name information and original annotation. Used as an
--   annotation type for AST.
data Scoped l
Scoped :: (NameInfo l) -> l -> Scoped l

-- | Information about the names used in an AST.
data NameInfo l

-- | global entitiy and the way it is referenced
GlobalSymbol :: Symbol -> (QName ()) -> NameInfo l

-- | local value, and location where it is bound
LocalValue :: SrcLoc -> NameInfo l

-- | type variable, and location where it is bound
TypeVar :: SrcLoc -> NameInfo l

-- | here the value name is bound
ValueBinder :: NameInfo l

-- | here the type name is defined
TypeBinder :: NameInfo l

-- | <tt>import</tt> declaration, and the table of symbols that it
--   introduces
Import :: (Map (QName ()) [Symbol]) -> NameInfo l

-- | part of an <tt>import</tt> declaration
ImportPart :: [Symbol] -> NameInfo l

-- | part of an <tt>export</tt> declaration
Export :: [Symbol] -> NameInfo l

-- | wildcard in a record pattern. The list contains resolved names of the
--   fields that are brought in scope by this pattern.
RecPatWildcard :: [Symbol] -> NameInfo l

-- | wildcard in a record construction expression. The list contains
--   resolved names of the fields and information about values assigned to
--   those fields.
RecExpWildcard :: [(Symbol, NameInfo l)] -> NameInfo l

-- | no annotation
None :: NameInfo l

-- | scope error
ScopeError :: (Error l) -> NameInfo l
annotateDecl :: forall a l. (Resolvable (a (Scoped l)), Functor a, Typeable l) => Scope -> a l -> a (Scoped l)

module Language.Haskell.Names.Environment

-- | A map from module name to list of symbols it exports.
type Environment = Map (ModuleName ()) [Symbol]

-- | Load a basic environment that contains modules very similar to GHC's
--   base package.
loadBase :: IO Environment

-- | Read symbols from a file.
readSymbols :: FilePath -> IO [Symbol]

-- | Write symbols to a file.
writeSymbols :: FilePath -> [Symbol] -> IO ()
data SymbolsFileException

-- | Symbols could not be parsed. This tells you the name of the file and
--   the parse error text.
BadSymbolsFile :: FilePath -> String -> SymbolsFileException
instance GHC.Show.Show Language.Haskell.Names.Environment.SymbolsFileException
instance GHC.Exception.Exception Language.Haskell.Names.Environment.SymbolsFileException
instance Data.Aeson.Types.ToJSON.ToJSON Language.Haskell.Names.Types.Symbol
instance Data.Aeson.Types.FromJSON.FromJSON Language.Haskell.Names.Types.Symbol

module Language.Haskell.Names

-- | Takes a list of modules and an environment and updates the environment
--   with each of the given modules' exported symbols. The modules can
--   appear in any order and can be mutually recursive.
resolve :: (Data l, Eq l) => [Module l] -> Environment -> Environment

-- | Annotate a module with scoping information using the given
--   environment. All imports of the given module should be in the
--   environment.
annotate :: (Data l, Eq l, SrcInfo l) => Environment -> Module l -> Module (Scoped l)

-- | A map from module name to list of symbols it exports.
type Environment = Map (ModuleName ()) [Symbol]

-- | Information about an entity. Carries at least the module it was
--   originally declared in and its name.
data Symbol

-- | value or function
Value :: ModuleName () -> Name () -> Symbol
[symbolModule] :: Symbol -> ModuleName ()
[symbolName] :: Symbol -> Name ()

-- | class method
Method :: ModuleName () -> Name () -> Name () -> Symbol
[symbolModule] :: Symbol -> ModuleName ()
[symbolName] :: Symbol -> Name ()
[className] :: Symbol -> Name ()

-- | record field selector
Selector :: ModuleName () -> Name () -> Name () -> [Name ()] -> Symbol
[symbolModule] :: Symbol -> ModuleName ()
[symbolName] :: Symbol -> Name ()
[typeName] :: Symbol -> Name ()
[constructors] :: Symbol -> [Name ()]

-- | data constructor
Constructor :: ModuleName () -> Name () -> Name () -> Symbol
[symbolModule] :: Symbol -> ModuleName ()
[symbolName] :: Symbol -> Name ()
[typeName] :: Symbol -> Name ()

-- | type synonym
Type :: ModuleName () -> Name () -> Symbol
[symbolModule] :: Symbol -> ModuleName ()
[symbolName] :: Symbol -> Name ()

-- | data type
Data :: ModuleName () -> Name () -> Symbol
[symbolModule] :: Symbol -> ModuleName ()
[symbolName] :: Symbol -> Name ()

-- | newtype
NewType :: ModuleName () -> Name () -> Symbol
[symbolModule] :: Symbol -> ModuleName ()
[symbolName] :: Symbol -> Name ()

-- | type family
TypeFam :: ModuleName () -> Name () -> Maybe (Name ()) -> Symbol
[symbolModule] :: Symbol -> ModuleName ()
[symbolName] :: Symbol -> Name ()
[associate] :: Symbol -> Maybe (Name ())

-- | data family
DataFam :: ModuleName () -> Name () -> Maybe (Name ()) -> Symbol
[symbolModule] :: Symbol -> ModuleName ()
[symbolName] :: Symbol -> Name ()
[associate] :: Symbol -> Maybe (Name ())

-- | type class
Class :: ModuleName () -> Name () -> Symbol
[symbolModule] :: Symbol -> ModuleName ()
[symbolName] :: Symbol -> Name ()

-- | pattern synonym constructor
PatternConstructor :: ModuleName () -> Name () -> Maybe (Name ()) -> Symbol
[symbolModule] :: Symbol -> ModuleName ()
[symbolName] :: Symbol -> Name ()
[patternTypeName] :: Symbol -> Maybe (Name ())

-- | pattern synonym selector
PatternSelector :: ModuleName () -> Name () -> Maybe (Name ()) -> Name () -> Symbol
[symbolModule] :: Symbol -> ModuleName ()
[symbolName] :: Symbol -> Name ()
[patternTypeName] :: Symbol -> Maybe (Name ())
[patternConstructorName] :: Symbol -> Name ()

-- | A pair of the name information and original annotation. Used as an
--   annotation type for AST.
data Scoped l
Scoped :: (NameInfo l) -> l -> Scoped l

-- | Information about the names used in an AST.
data NameInfo l

-- | global entitiy and the way it is referenced
GlobalSymbol :: Symbol -> (QName ()) -> NameInfo l

-- | local value, and location where it is bound
LocalValue :: SrcLoc -> NameInfo l

-- | type variable, and location where it is bound
TypeVar :: SrcLoc -> NameInfo l

-- | here the value name is bound
ValueBinder :: NameInfo l

-- | here the type name is defined
TypeBinder :: NameInfo l

-- | <tt>import</tt> declaration, and the table of symbols that it
--   introduces
Import :: (Map (QName ()) [Symbol]) -> NameInfo l

-- | part of an <tt>import</tt> declaration
ImportPart :: [Symbol] -> NameInfo l

-- | part of an <tt>export</tt> declaration
Export :: [Symbol] -> NameInfo l

-- | wildcard in a record pattern. The list contains resolved names of the
--   fields that are brought in scope by this pattern.
RecPatWildcard :: [Symbol] -> NameInfo l

-- | wildcard in a record construction expression. The list contains
--   resolved names of the fields and information about values assigned to
--   those fields.
RecExpWildcard :: [(Symbol, NameInfo l)] -> NameInfo l

-- | no annotation
None :: NameInfo l

-- | scope error
ScopeError :: (Error l) -> NameInfo l

-- | Errors during name resolution.
data Error l

-- | name is not in scope
ENotInScope :: (QName l) -> Error l

-- | name is ambiguous
EAmbiguous :: (QName l) -> [Symbol] -> Error l

-- | type is used where a type class is expected
ETypeAsClass :: (QName l) -> Error l

-- | type class is used where a type is expected
EClassAsType :: (QName l) -> Error l

-- | Attempt to explicitly import a name which is not exported (or,
--   possibly, does not even exist). For example:
--   
--   <pre>
--   import Prelude(Bool(Right))
--   </pre>
--   
--   The fields are:
--   
--   <ol>
--   <li>optional parent in the import list, e.g. <tt>Bool</tt> in
--   <tt>Bool(Right)</tt></li>
--   <li>the name which is not exported</li>
--   <li>the module which does not export the name</li>
--   </ol>
ENotExported :: (Maybe (Name l)) -> (Name l) -> (ModuleName l) -> Error l

-- | module not found
EModNotFound :: (ModuleName l) -> Error l

-- | internal error
EInternal :: String -> Error l

-- | Read symbols from a file.
readSymbols :: FilePath -> IO [Symbol]

-- | Write symbols to a file.
writeSymbols :: FilePath -> [Symbol] -> IO ()

-- | Load a basic environment that contains modules very similar to GHC's
--   base package.
loadBase :: IO Environment

-- | Display an error.
--   
--   Note: can span multiple lines; the trailing newline is included.
ppError :: SrcInfo l => Error l -> String

-- | Pretty print a symbol.
ppSymbol :: Symbol -> String
