-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Name resolution library for Haskell -- -- For a high-level overview of this package, see -- http://documentup.com/haskell-suite/haskell-names @package haskell-names @version 0.2 -- | Reading Symbols from and writing to interface files module Language.Haskell.Names.Interfaces -- | The database used by hs-gen-iface. Use it together with -- functions from Distribution.HaskellSuite.Packages. newtype NamesDB NamesDB :: FilePath -> NamesDB -- | Specialized version of runModuleT that works with name files runNamesModuleT :: ModuleT Symbols IO a -> Packages -> Map ModuleName Symbols -> IO (a, Map ModuleName Symbols) -- | Specialized version of evalModuleT that works with name files evalNamesModuleT :: ModuleT Symbols IO a -> Packages -> IO a -- | Read an interface file readInterface :: FilePath -> IO Symbols -- | Write an interface file writeInterface :: FilePath -> Symbols -> IO () data IfaceException -- | Interface could not be parsed. This tells you the file name of the -- interface file and the parse error text. BadInterface :: FilePath -> String -> IfaceException instance IsPackageDB NamesDB instance FromJSON Symbols instance ToJSON Symbols instance FromJSON l0 => FromJSON (Assoc l0) instance ToJSON l0 => ToJSON (Assoc l0) instance Typeable IfaceException instance Show IfaceException instance FromJSON name => FromJSON (SymTypeInfo name) instance ToJSON name => ToJSON (SymTypeInfo name) instance FromJSON name => FromJSON (SymValueInfo name) instance ToJSON name => ToJSON (SymValueInfo name) instance FromJSON OrigName instance ToJSON OrigName instance Exception IfaceException module Language.Haskell.Names.SyntaxUtils dropAnn :: Functor a => a l -> a () setAnn :: Functor a => l' -> a l -> a l' getModuleName :: Module l -> ModuleName l getImports :: Module l -> [ImportDecl l] getExportSpecList :: Module l -> Maybe (ExportSpecList l) splitDeclHead :: DeclHead l -> (Name l, [TyVarBind l]) getDeclHeadName :: Decl l -> Name l getModuleDecls :: Module l -> [Decl l] isTypeDecl :: Decl l -> Bool class GetBound a l | a -> l getBound :: GetBound a l => a -> [Name l] opName :: Op l -> Name l isCon :: Name l -> Bool nameToString :: Name l -> String specialConToString :: SpecialCon l -> String qNameToName :: QName l -> Name l unCName :: CName l -> Name l getErrors :: (Ord l, Foldable a) => a (Scoped l) -> Set (Error l) type ExtensionSet = Set KnownExtension -- | Compute the extension set for the given module, based on the global -- preferences (e.g. specified on the command line) and module's LANGUAGE -- pragmas. moduleExtensions :: Language -> [Extension] -> Module l -> ExtensionSet instance Data l => GetBound (Pat l) l instance Data l => GetBound (QualStmt l) l instance Data l => GetBound (Stmt l) l instance Data l => GetBound (Match l) l instance Data l => GetBound (ClassDecl l) l instance Data l => GetBound (FieldDecl l) l instance Data l => GetBound (ConDecl l) l instance Data l => GetBound (GadtDecl l) l instance Data l => GetBound (QualConDecl l) l instance Data l => GetBound (Decl l) l instance Data l => GetBound (Binds l) l instance (GetBound a l, GetBound b l) => GetBound (a, b) l instance GetBound a l => GetBound (Maybe a) l instance GetBound a l => GetBound [a] l -- | This module is designed to be imported qualified. module Language.Haskell.Names.GlobalSymbolTable -- | Global symbol table — contains global names data Table -- | Possibly qualified name. If the name is not qualified, -- ModuleNameS is the empty string. data GName -- | Qualified name, where ModuleNameS points to the module where -- the name was originally defined. The module part is never empty. -- -- Also contains name and version of the package where it was defined. If -- it's Nothing, then the entity is defined in the "current" -- package. data OrigName empty :: Table data Result l a Result :: a -> Result l a Error :: (Error l) -> Result l a Special :: Result l a lookupValue :: QName l -> Table -> Result l (SymValueInfo OrigName) addValue :: QName l -> SymValueInfo OrigName -> Table -> Table lookupType :: QName l -> Table -> Result l (SymTypeInfo OrigName) addType :: QName l -> SymTypeInfo OrigName -> Table -> Table fromMaps :: Map GName (Set (SymValueInfo OrigName)) -> Map GName (Set (SymTypeInfo OrigName)) -> Table fromLists :: ([(GName, SymValueInfo OrigName)], [(GName, SymTypeInfo OrigName)]) -> Table types :: Table -> Map GName (Set (SymTypeInfo OrigName)) values :: Table -> Map GName (Set (SymValueInfo OrigName)) toSymbols :: Table -> Symbols instance Typeable Table instance Eq Table instance Ord Table instance Show Table instance Data Table instance Monoid Table -- | 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 module Language.Haskell.Names.Open class Typeable a => Resolvable a rtraverse :: (Resolvable a, Applicative f, ?alg :: Alg f) => a -> Scope -> f a 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 rmap :: Resolvable a => (forall b. Resolvable b => Scope -> b -> b) -> Scope -> a -> a data Scope data NameContext BindingT :: NameContext BindingV :: NameContext ReferenceT :: NameContext ReferenceV :: NameContext -- | we don't expect names in this context Other :: NameContext initialScope :: Table -> Scope gTable :: Lens Scope Table lTable :: Lens Scope Table nameCtx :: Lens Scope NameContext 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 data NameInfo l -- | global value GlobalValue :: (SymValueInfo OrigName) -> NameInfo l -- | global type GlobalType :: (SymTypeInfo OrigName) -> 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 -- | import declaration, and the table of symbols that it -- introduces Import :: Table -> NameInfo l -- | part of an import declaration ImportPart :: Symbols -> NameInfo l -- | export declaration, and the symbols it exports Export :: Symbols -> NameInfo l -- | no annotation None :: NameInfo l -- | scope error ScopeError :: (Error l) -> NameInfo l annotate :: (Resolvable (a (Scoped l)), Functor a, Typeable l) => Scope -> a l -> a (Scoped l) module Language.Haskell.Names.Imports processImport :: (MonadModule m, ModuleInfo m ~ Symbols) => ImportDecl l -> m (ImportDecl (Scoped l), Table) processImports :: (MonadModule m, ModuleInfo m ~ Symbols) => ExtensionSet -> [ImportDecl l] -> m ([ImportDecl (Scoped l)], Table) instance ModName (ModuleName l) module Language.Haskell.Names.ModuleSymbols moduleSymbols :: (Eq l, Data l) => Module l -> Symbols moduleTable :: (Eq l, Data l) => Module l -> Table module Language.Haskell.Names.Exports processExports :: (MonadModule m, ModuleInfo m ~ Symbols, Data l, Eq l) => Table -> Module l -> m (Maybe (ExportSpecList (Scoped l)), Symbols) resolveExportSpecList :: (MonadModule m, ModuleInfo m ~ Symbols) => Table -> ExportSpecList l -> m (ExportSpecList (Scoped l), Symbols) resolveExportSpec :: (MonadModule m, ModuleInfo m ~ Symbols) => Table -> ExportSpec l -> m (ExportSpec (Scoped l), Symbols) module Language.Haskell.Names -- | computeInterfaces takes a list of possibly recursive modules -- and computes the interface of each module. The computed interfaces are -- written into the m's cache and are available to further -- computations in this monad. -- -- Returns the set of import/export errors. Note that the interfaces are -- registered in the cache regardless of whether there are any errors, -- but if there are errors, the interfaces may be incomplete. computeInterfaces :: (MonadModule m, ModuleInfo m ~ Symbols, Data l, SrcInfo l, Ord l) => Language -> [Extension] -> [Module l] -> m (Set (Error l)) -- | Like computeInterfaces, but also returns a list of interfaces, -- one per module and in the same order getInterfaces :: (MonadModule m, ModuleInfo m ~ Symbols, Data l, SrcInfo l, Ord l) => Language -> [Extension] -> [Module l] -> m ([Symbols], Set (Error l)) -- | Annotate a module with scoping information. This assumes that all -- module dependencies have been resolved and cached — usually you need -- to run computeInterfaces first, unless you have one module in -- isolation. annotateModule :: (MonadModule m, ModuleInfo m ~ Symbols, Data l, SrcInfo l, Eq l) => Language -> [Extension] -> Module l -> m (Module (Scoped l)) -- | Annotate all local symbols with the package name and version qualifySymbols :: PackageId -> Symbols -> Symbols -- | Information about a value-level entitity data SymValueInfo name -- | value or function SymValue :: name -> Maybe SymFixity -> SymValueInfo name sv_origName :: SymValueInfo name -> name sv_fixity :: SymValueInfo name -> Maybe SymFixity -- | class method SymMethod :: name -> Maybe SymFixity -> name -> SymValueInfo name sv_origName :: SymValueInfo name -> name sv_fixity :: SymValueInfo name -> Maybe SymFixity sv_className :: SymValueInfo name -> name -- | record field selector SymSelector :: name -> Maybe SymFixity -> name -> SymValueInfo name sv_origName :: SymValueInfo name -> name sv_fixity :: SymValueInfo name -> Maybe SymFixity sv_typeName :: SymValueInfo name -> name -- | data constructor SymConstructor :: name -> Maybe SymFixity -> name -> SymValueInfo name sv_origName :: SymValueInfo name -> name sv_fixity :: SymValueInfo name -> Maybe SymFixity sv_typeName :: SymValueInfo name -> name -- | Information about a type-level entitity data SymTypeInfo name -- | type synonym SymType :: name -> Maybe SymFixity -> SymTypeInfo name st_origName :: SymTypeInfo name -> name st_fixity :: SymTypeInfo name -> Maybe SymFixity -- | data type SymData :: name -> Maybe SymFixity -> SymTypeInfo name st_origName :: SymTypeInfo name -> name st_fixity :: SymTypeInfo name -> Maybe SymFixity -- | newtype SymNewType :: name -> Maybe SymFixity -> SymTypeInfo name st_origName :: SymTypeInfo name -> name st_fixity :: SymTypeInfo name -> Maybe SymFixity -- | type family SymTypeFam :: name -> Maybe SymFixity -> SymTypeInfo name st_origName :: SymTypeInfo name -> name st_fixity :: SymTypeInfo name -> Maybe SymFixity -- | data family SymDataFam :: name -> Maybe SymFixity -> SymTypeInfo name st_origName :: SymTypeInfo name -> name st_fixity :: SymTypeInfo name -> Maybe SymFixity -- | type class SymClass :: name -> Maybe SymFixity -> SymTypeInfo name st_origName :: SymTypeInfo name -> name st_fixity :: SymTypeInfo name -> Maybe SymFixity -- | The set of symbols (entities) exported by a single module. Contains -- the sets of value-level and type-level entities. data Symbols Symbols :: (Set (SymValueInfo OrigName)) -> (Set (SymTypeInfo OrigName)) -> Symbols -- | 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 data NameInfo l -- | global value GlobalValue :: (SymValueInfo OrigName) -> NameInfo l -- | global type GlobalType :: (SymTypeInfo OrigName) -> 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 -- | import declaration, and the table of symbols that it -- introduces Import :: Table -> NameInfo l -- | part of an import declaration ImportPart :: Symbols -> NameInfo l -- | export declaration, and the symbols it exports Export :: Symbols -> NameInfo l -- | no annotation None :: NameInfo l -- | scope error ScopeError :: (Error l) -> NameInfo l -- | String representing an unqualified entity name type NameS = String -- | String representing a module name type ModuleNameS = String -- | Possibly qualified name. If the name is not qualified, -- ModuleNameS is the empty string. data GName GName :: ModuleNameS -> NameS -> GName -- | Display a GName ppGName :: GName -> String -- | Qualified name, where ModuleNameS points to the module where -- the name was originally defined. The module part is never empty. -- -- Also contains name and version of the package where it was defined. If -- it's Nothing, then the entity is defined in the "current" -- package. data OrigName OrigName :: Maybe PackageId -> GName -> OrigName origPackage :: OrigName -> Maybe PackageId origGName :: OrigName -> GName -- | Display an OrigName ppOrigName :: OrigName -> String data Error l -- | name is not in scope ENotInScope :: (QName l) -> Error l -- | name is ambiguous EAmbiguous :: (QName l) -> [OrigName] -> 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: -- --
-- import Prelude(Bool(Right)) ---- -- The fields are: -- --