Copyright | (c) 2020 Kowainik |
---|---|
License | MPL-2.0 |
Maintainer | Kowainik <xrom.xkov@gmail.com> |
Safe Haskell | None |
Language | Haskell2010 |
Compatibility module for HIE types from GHC API. Reexports all required API to work with HIE types.
Synopsis
- data ContextInfo
- newtype HieArgs a = HieArgs [(Bool, a)]
- data HieAST a = Node {}
- newtype HieASTs a = HieASTs {
- getAsts :: Map FastString (HieAST a)
- data HieFile = HieFile {}
- data HieType a
- type HieTypeFlat = HieType TypeIndex
- data IEType
- = Import
- | ImportAs
- | ImportHiding
- | Export
- type Identifier = Either ModuleName Name
- data IdentifierDetails a = IdentifierDetails {
- identType :: Maybe a
- identInfo :: Set ContextInfo
- data NodeInfo a = NodeInfo {
- nodeAnnotations :: Set (FastString, FastString)
- nodeType :: [a]
- nodeIdentifiers :: NodeIdentifiers a
- type TypeIndex = Int
- data DeclType
- data HieFileResult
- readHieFile :: NameCache -> FilePath -> IO (HieFileResult, NameCache)
- data NameCache
- initNameCache :: UniqSupply -> [Name] -> NameCache
- mkSplitUniqSupply :: Char -> IO UniqSupply
Main HIE types
data ContextInfo #
Different contexts under which identifiers exist
Use | regular variable |
MatchBind | |
IEThing IEType | import/export |
TyDecl | |
ValBind | Value binding |
PatternBind | Pattern binding This case is tricky because the bound identifier can be used in two
distinct scopes. Consider the following example (with do (b, a, (a -> True)) <- bar foo a The identifier |
ClassTyDecl (Maybe Span) | |
Decl | Declaration |
TyVarBind Scope TyVarScope | Type variable |
RecField RecFieldContext (Maybe Span) | Record field |
Instances
Eq ContextInfo | |
Defined in HieTypes (==) :: ContextInfo -> ContextInfo -> Bool # (/=) :: ContextInfo -> ContextInfo -> Bool # | |
Ord ContextInfo | |
Defined in HieTypes compare :: ContextInfo -> ContextInfo -> Ordering # (<) :: ContextInfo -> ContextInfo -> Bool # (<=) :: ContextInfo -> ContextInfo -> Bool # (>) :: ContextInfo -> ContextInfo -> Bool # (>=) :: ContextInfo -> ContextInfo -> Bool # max :: ContextInfo -> ContextInfo -> ContextInfo # min :: ContextInfo -> ContextInfo -> ContextInfo # | |
Show ContextInfo | |
Defined in HieTypes showsPrec :: Int -> ContextInfo -> ShowS # show :: ContextInfo -> String # showList :: [ContextInfo] -> ShowS # | |
Binary ContextInfo | |
Defined in HieTypes put_ :: BinHandle -> ContextInfo -> IO () # put :: BinHandle -> ContextInfo -> IO (Bin ContextInfo) # get :: BinHandle -> IO ContextInfo # | |
Outputable ContextInfo | |
Defined in HieTypes ppr :: ContextInfo -> SDoc # pprPrec :: Rational -> ContextInfo -> SDoc # |
A list of type arguments along with their respective visibilities (ie. is
this an argument that would return True
for isVisibleArgFlag
?).
Instances
Functor HieArgs | |
Foldable HieArgs | |
Defined in HieTypes fold :: Monoid m => HieArgs m -> m # foldMap :: Monoid m => (a -> m) -> HieArgs a -> m # foldMap' :: Monoid m => (a -> m) -> HieArgs a -> m # foldr :: (a -> b -> b) -> b -> HieArgs a -> b # foldr' :: (a -> b -> b) -> b -> HieArgs a -> b # foldl :: (b -> a -> b) -> b -> HieArgs a -> b # foldl' :: (b -> a -> b) -> b -> HieArgs a -> b # foldr1 :: (a -> a -> a) -> HieArgs a -> a # foldl1 :: (a -> a -> a) -> HieArgs a -> a # elem :: Eq a => a -> HieArgs a -> Bool # maximum :: Ord a => HieArgs a -> a # minimum :: Ord a => HieArgs a -> a # | |
Traversable HieArgs | |
Eq a => Eq (HieArgs a) | |
Show a => Show (HieArgs a) Source # | |
Binary (HieArgs TypeIndex) | |
Instances
Functor HieAST | |
Foldable HieAST | |
Defined in HieTypes fold :: Monoid m => HieAST m -> m # foldMap :: Monoid m => (a -> m) -> HieAST a -> m # foldMap' :: Monoid m => (a -> m) -> HieAST a -> m # foldr :: (a -> b -> b) -> b -> HieAST a -> b # foldr' :: (a -> b -> b) -> b -> HieAST a -> b # foldl :: (b -> a -> b) -> b -> HieAST a -> b # foldl' :: (b -> a -> b) -> b -> HieAST a -> b # foldr1 :: (a -> a -> a) -> HieAST a -> a # foldl1 :: (a -> a -> a) -> HieAST a -> a # elem :: Eq a => a -> HieAST a -> Bool # maximum :: Ord a => HieAST a -> a # minimum :: Ord a => HieAST a -> a # | |
Traversable HieAST | |
Show a => Show (HieAST a) Source # | |
Binary (HieAST TypeIndex) | |
Mapping from filepaths (represented using FastString
) to the
corresponding AST
HieASTs | |
|
Instances
Functor HieASTs | |
Foldable HieASTs | |
Defined in HieTypes fold :: Monoid m => HieASTs m -> m # foldMap :: Monoid m => (a -> m) -> HieASTs a -> m # foldMap' :: Monoid m => (a -> m) -> HieASTs a -> m # foldr :: (a -> b -> b) -> b -> HieASTs a -> b # foldr' :: (a -> b -> b) -> b -> HieASTs a -> b # foldl :: (b -> a -> b) -> b -> HieASTs a -> b # foldl' :: (b -> a -> b) -> b -> HieASTs a -> b # foldr1 :: (a -> a -> a) -> HieASTs a -> a # foldl1 :: (a -> a -> a) -> HieASTs a -> a # elem :: Eq a => a -> HieASTs a -> Bool # maximum :: Ord a => HieASTs a -> a # minimum :: Ord a => HieASTs a -> a # | |
Traversable HieASTs | |
Show a => Show (HieASTs a) Source # | |
Binary (HieASTs TypeIndex) | |
GHC builds up a wealth of information about Haskell source as it compiles it.
.hie
files are a way of persisting some of this information to disk so that
external tools that need to work with haskell source don't need to parse,
typecheck, and rename all over again. These files contain:
a simplified AST
- nodes are annotated with source positions and types
- identifiers are annotated with scope information
- the raw bytes of the initial Haskell source
Besides saving compilation cycles, .hie
files also offer a more stable
interface than the GHC API.
HieFile | |
|
A flattened version of Type
.
See Note [Efficient serialization of redundant type info]
HTyVarTy Name | |
HAppTy a (HieArgs a) | |
HTyConApp IfaceTyCon (HieArgs a) | |
HForAllTy ((Name, a), ArgFlag) a | |
HFunTy a a | |
HQualTy a a | type with constraint: |
HLitTy IfaceTyLit | |
HCastTy a | |
HCoercionTy |
Instances
Functor HieType | |
Foldable HieType | |
Defined in HieTypes fold :: Monoid m => HieType m -> m # foldMap :: Monoid m => (a -> m) -> HieType a -> m # foldMap' :: Monoid m => (a -> m) -> HieType a -> m # foldr :: (a -> b -> b) -> b -> HieType a -> b # foldr' :: (a -> b -> b) -> b -> HieType a -> b # foldl :: (b -> a -> b) -> b -> HieType a -> b # foldl' :: (b -> a -> b) -> b -> HieType a -> b # foldr1 :: (a -> a -> a) -> HieType a -> a # foldl1 :: (a -> a -> a) -> HieType a -> a # elem :: Eq a => a -> HieType a -> Bool # maximum :: Ord a => HieType a -> a # minimum :: Ord a => HieType a -> a # | |
Traversable HieType | |
Eq a => Eq (HieType a) | |
Show a => Show (HieType a) Source # | |
Binary (HieType TypeIndex) | |
type HieTypeFlat = HieType TypeIndex #
Types of imports and exports
type Identifier = Either ModuleName Name #
data IdentifierDetails a #
Information associated with every identifier
We need to include types with identifiers because sometimes multiple identifiers occur in the same span(Overloaded Record Fields and so on)
Instances
The information stored in one AST node.
The type parameter exists to provide flexibility in representation of types (see Note [Efficient serialization of redundant type info]).
NodeInfo | |
|
Instances
Functor NodeInfo | |
Foldable NodeInfo | |
Defined in HieTypes fold :: Monoid m => NodeInfo m -> m # foldMap :: Monoid m => (a -> m) -> NodeInfo a -> m # foldMap' :: Monoid m => (a -> m) -> NodeInfo a -> m # foldr :: (a -> b -> b) -> b -> NodeInfo a -> b # foldr' :: (a -> b -> b) -> b -> NodeInfo a -> b # foldl :: (b -> a -> b) -> b -> NodeInfo a -> b # foldl' :: (b -> a -> b) -> b -> NodeInfo a -> b # foldr1 :: (a -> a -> a) -> NodeInfo a -> a # foldl1 :: (a -> a -> a) -> NodeInfo a -> a # elem :: Eq a => a -> NodeInfo a -> Bool # maximum :: Ord a => NodeInfo a -> a # minimum :: Ord a => NodeInfo a -> a # | |
Traversable NodeInfo | |
Show a => Show (NodeInfo a) Source # | |
Binary (NodeInfo TypeIndex) | |
FamDec | type or data family |
SynDec | type synonym |
DataDec | data declaration |
ConDec | constructor declaration |
PatSynDec | pattern synonym |
ClassDec | class declaration |
InstDec | instance declaration |
Instances
Enum DeclType | |
Eq DeclType | |
Ord DeclType | |
Show DeclType | |
Binary DeclType | |
Binary interface to hie files
data HieFileResult #
readHieFile :: NameCache -> FilePath -> IO (HieFileResult, NameCache) #
Name cache to read HIE files
The NameCache makes sure that there is just one Unique assigned for each original name; i.e. (module-name, occ-name) pair and provides something of a lookup mechanism for those names.
initNameCache :: UniqSupply -> [Name] -> NameCache #
Return a function to atomically update the name cache.
mkSplitUniqSupply :: Char -> IO UniqSupply #
Create a unique supply out of thin air. The character given must be distinct from those of all calls to this function in the compiler for the values generated to be truly unique.