hiedb-0.6.0.1: Generates a references DB from .hie files

Safe Haskell | None
Language | Haskell2010

HieDb.Create

Synopsis

- sCHEMA_VERSION :: Integer
- dB_VERSION :: Integer
- checkVersion :: (HieDb -> IO a) -> HieDb -> IO a
- withHieDb :: FilePath -> (HieDb -> IO a) -> IO a
- withHieDbAndFlags :: LibDir -> FilePath -> (DynFlags -> HieDb -> IO a) -> IO a
- initConn :: HieDb -> IO ()
- addArr :: HieDb -> Array TypeIndex HieTypeFlat -> IO (Array TypeIndex (Maybe Int64))
- addTypeRefs :: HieDb -> FilePath -> HieFile -> Array TypeIndex (Maybe Int64) -> IO ()
- data SkipOptions = SkipOptions {
  - skipRefs :: Bool
  - skipDecls :: Bool
  - skipDefs :: Bool
  - skipExports :: Bool
  - skipImports :: Bool
  - skipTypes :: Bool
  - skipTypeRefs :: Bool
  }
- defaultSkipOptions :: SkipOptions
- addRefsFrom :: (MonadIO m, NameCacheMonad m) => HieDb -> Maybe FilePath -> SkipOptions -> FilePath -> m Bool
- addRefsFromLoaded :: MonadIO m => HieDb -> FilePath -> SourceFile -> Fingerprint -> HieFile -> m ()
- addRefsFromLoadedInternal :: MonadIO m => HieDb -> FilePath -> SourceFile -> Fingerprint -> SkipOptions -> HieFile -> m ()
- addRefsFromLoaded_unsafe :: MonadIO m => HieDb -> FilePath -> SourceFile -> Fingerprint -> SkipOptions -> HieFile -> m ()
- addSrcFile :: HieDb -> FilePath -> FilePath -> Bool -> IO ()
- removeDependencySrcFiles :: HieDb -> IO ()
- deleteFileFromIndex :: HieDb -> FilePath -> IO ()
- deleteMissingRealFiles :: HieDb -> IO ()
- garbageCollectTypeNames :: HieDb -> IO Int
- deleteInternalTables :: Connection -> FilePath -> IO ()

# Documentation

sCHEMA_VERSION :: Integer #

dB_VERSION :: Integer #

checkVersion :: (HieDb -> IO a) -> HieDb -> IO a #

`checkVersion f db` checks the schema version associated with given `db`. If that version is supported by hiedb, it runs the function `f` with the `db`. Otherwise it throws `IncompatibleSchemaVersion` exception.

withHieDb :: FilePath -> (HieDb -> IO a) -> IO a #

Given path to `.hiedb` file, constructs `HieDb` and passes it to given function.

withHieDbAndFlags :: LibDir -> FilePath -> (DynFlags -> HieDb -> IO a) -> IO a #

Given GHC LibDir and path to `.hiedb` file, constructs DynFlags (required for printing info from `.hie` files) and `HieDb` and passes them to given function.

initConn :: HieDb -> IO () #

Initialize database schema for given `HieDb`.

addArr :: HieDb -> Array TypeIndex HieTypeFlat -> IO (Array TypeIndex (Maybe Int64)) #

Add names of types from `.hie` file to `HieDb`. Returns an Array mapping `TypeIndex` to database ID assigned to the corresponding record in DB.

addTypeRefs #

Arguments

:: HieDb |
-> FilePath | Path to `.hie` file
-> HieFile | Data loaded from the `.hie` file
-> Array TypeIndex (Maybe Int64) | Maps TypeIndex to database ID assigned to record in `typenames` table
-> IO () |

Add references to types from given `.hie` file to DB.

data SkipOptions #

Options to skip indexing phases

Constructors

SkipOptions |

Fields

- skipRefs :: Bool
- skipDecls :: Bool
- skipDefs :: Bool
- skipExports :: Bool
- skipImports :: Bool
- skipTypes :: Bool

  Note skip types will also skip type refs since it is dependent

- skipTypeRefs :: Bool

#### Instances

Instances details

Show SkipOptions # |
Instance details Defined in HieDb.Create Methods showsPrec :: Int -> SkipOptions -> ShowS # show :: SkipOptions -> String # showList :: [SkipOptions] -> ShowS #

defaultSkipOptions :: SkipOptions #

addRefsFrom :: (MonadIO m, NameCacheMonad m) => HieDb -> Maybe FilePath -> SkipOptions -> FilePath -> m Bool #

Adds all references from given `.hie` file to `HieDb`. The indexing is skipped if the file was not modified since the last time it was indexed. The boolean returned is true if the file was actually indexed

addRefsFromLoaded #

Arguments

:: MonadIO m |
=> HieDb | HieDb into which we're adding the file
-> FilePath | Path to `.hie` file
-> SourceFile | Path to .hs file from which `.hie` file was created Also tells us if this is a real source file? i.e. does it come from user's project (as opposed to from project's dependency)?
-> Fingerprint | The hash of the `.hie` file
-> HieFile | Data loaded from the `.hie` file
-> m () |

addRefsFromLoadedInternal #

Arguments

:: MonadIO m |
=> HieDb | HieDb into which we're adding the file
-> FilePath | Path to `.hie` file
-> SourceFile | Path to .hs file from which `.hie` file was created Also tells us if this is a real source file? i.e. does it come from user's project (as opposed to from project's dependency)?
-> Fingerprint | The hash of the `.hie` file
-> SkipOptions | Skip indexing certain tables
-> HieFile | Data loaded from the `.hie` file
-> m () |

addRefsFromLoaded_unsafe #

Arguments

:: MonadIO m |
=> HieDb | HieDb into which we're adding the file
-> FilePath | Path to `.hie` file
-> SourceFile | Path to .hs file from which `.hie` file was created Also tells us if this is a real source file? i.e. does it come from user's project (as opposed to from project's dependency)?
-> Fingerprint | The hash of the `.hie` file
-> SkipOptions | Skip indexing certain tables
-> HieFile | Data loaded from the `.hie` file
-> m () |

Like `addRefsFromLoaded` but without: 1) using a transaction 2) cleaning up previous versions of the file

Mostly useful to index a new database from scratch as fast as possible

addSrcFile #

Arguments

:: HieDb |
-> FilePath | Path to `.hie` file
-> FilePath | Path to .hs file to be added to DB
-> Bool | Is this a real source file? I.e. does it come from user's project (as opposed to from project's dependency)?
-> IO () |

Add path to .hs source given path to `.hie` file which has already been indexed. No action is taken if the corresponding `.hie` file has not been indexed yet.

removeDependencySrcFiles :: HieDb -> IO () #

Remove the path to .hs source for all dependency `.hie` files. Useful for resetting the indexed dependencies if the sources have been deleted for some reason.

deleteFileFromIndex :: HieDb -> FilePath -> IO () #

Delete all occurrences of given `.hie` file from the database

deleteMissingRealFiles :: HieDb -> IO () #

Delete all entries associated with modules for which the `modInfoSrcFile` doesn't exist on the disk. Doesn't delete it if there is no associated `modInfoSrcFile`

garbageCollectTypeNames :: HieDb -> IO Int #

Garbage collect typenames with no references - it is a good idea to call this function after a sequence of database updates (inserts or deletes)

deleteInternalTables :: Connection -> FilePath -> IO () #