hie-bios-0.14.0: Set up a GHC API session

Safe Haskell | None
Language | Haskell2010

HIE.Bios.Types

Synopsis

- hie_bios_output :: String
- hie_bios_ghc :: String
- hie_bios_ghc_args :: String
- hie_bios_arg :: String
- hie_bios_deps :: String
- data Cradle a = Cradle {
  - cradleRootDir :: FilePath
  - cradleOptsProg :: CradleAction a
  - cradleLogger :: LogAction IO (WithSeverity Log)
  }
- data ActionName a
  - = Stack
  - | Cabal
  - | Bios
  - | Default
  - | Multi
  - | Direct
  - | None
  - | Other a
- data Log
  - = LogAny !Text
  - | LogProcessOutput String
  - | LogCreateProcessRun CreateProcess
  - | LogProcessRun FilePath [FilePath]
  - | LogRequestedCradleLoadStyle !Text !LoadStyle
  - | LogComputedCradleLoadStyle !Text !LoadStyle
  - | LogLoadWithContextUnsupported !Text !(Maybe Text)
- data LoadStyle
  - = LoadFile
  - | LoadWithContext [FilePath]
- data CradleAction a = CradleAction {
  - actionName :: ActionName a
  - runCradle :: FilePath -> LoadStyle -> IO (CradleLoadResult ComponentOptions)
  - runGhcCmd :: [String] -> IO (CradleLoadResult String)
  }
- data CradleLoadResult r
  - = CradleSuccess r
  - | CradleFail CradleError
  - | CradleNone
- cradleLoadResult :: c -> (CradleError -> c) -> (r -> c) -> CradleLoadResult r -> c
- newtype CradleLoadResultT (m :: Type -> Type) a = CradleLoadResultT {
  - runCradleResultT :: m (CradleLoadResult a)
  }
- modCradleError :: Monad m => CradleLoadResultT m a -> (CradleError -> m CradleError) -> CradleLoadResultT m a
- throwCE :: forall (m :: Type -> Type) a. Monad m => CradleError -> CradleLoadResultT m a
- data CradleError = CradleError {
  - cradleErrorDependencies :: [FilePath]
  - cradleErrorExitCode :: ExitCode
  - cradleErrorStderr :: [String]
  }
- data ComponentOptions = ComponentOptions {
  - componentOptions :: [String]
  - componentRoot :: FilePath
  - componentDependencies :: [FilePath]
  }
- prettyCmdSpec :: CmdSpec -> String
- prettyProcessEnv :: CreateProcess -> [String]

# Documentation

hie_bios_output :: String #

Environment variable containing the filepath to which cradle actions write their results to. If the filepath does not exist, cradle actions must create them.

hie_bios_ghc :: String #

Environment variable pointing to the GHC location used by cabal's and stack's GHC wrapper.

If not set, will default to sensible defaults.

hie_bios_ghc_args :: String #

Environment variable with extra arguments passed to the GHC location in cabal's and stack's GHC wrapper.

If not set, assume no extra arguments.

hie_bios_arg :: String #

Environment variable pointing to the source file location that caused the cradle action to be executed.

hie_bios_deps :: String #

Environment variable pointing to a filepath to which dependencies of a cradle can be written to by the cradle action.

data Cradle a #

The environment of a single `Cradle`. A `Cradle` is a unit for the respective build-system.

It contains the root directory of the `Cradle`, the name of the `Cradle` (for debugging purposes), and knows how to set up a GHC session that is able to compile files that are part of this `Cradle`.

A `Cradle` may be a single unit in the "cabal-install" context, or the whole package, comparable to how "stack" works.

Constructors

Cradle |

Fields

- cradleRootDir :: FilePath

  The project root directory.

- cradleOptsProg :: CradleAction a

  The action which needs to be executed to get the correct command line arguments.

- cradleLogger :: LogAction IO (WithSeverity Log)

#### Instances

Instances details

Functor Cradle # |
Instance details Defined in HIE.Bios.Types Methods fmap :: (a -> b) -> Cradle a -> Cradle b # (<$) :: a -> Cradle b -> Cradle a #
Show a => Show (Cradle a) # |
Instance details Defined in HIE.Bios.Types Methods showsPrec :: Int -> Cradle a -> ShowS # show :: Cradle a -> String # showList :: [Cradle a] -> ShowS #

data ActionName a #

Constructors

Stack |
Cabal |
Bios |
Default |
Multi |
Direct |
None |
Other a |

#### Instances

Instances details

Functor ActionName # |
Instance details Defined in HIE.Bios.Types Methods fmap :: (a -> b) -> ActionName a -> ActionName b # (<$) :: a -> ActionName b -> ActionName a #
Show a => Show (ActionName a) # |
Instance details Defined in HIE.Bios.Types Methods showsPrec :: Int -> ActionName a -> ShowS # show :: ActionName a -> String # showList :: [ActionName a] -> ShowS #
Eq a => Eq (ActionName a) # |
Instance details Defined in HIE.Bios.Types Methods (==) :: ActionName a -> ActionName a -> Bool # (/=) :: ActionName a -> ActionName a -> Bool #
Ord a => Ord (ActionName a) # |
Instance details Defined in HIE.Bios.Types Methods compare :: ActionName a -> ActionName a -> Ordering # (<) :: ActionName a -> ActionName a -> Bool # (<=) :: ActionName a -> ActionName a -> Bool # (>) :: ActionName a -> ActionName a -> Bool # (>=) :: ActionName a -> ActionName a -> Bool # max :: ActionName a -> ActionName a -> ActionName a # min :: ActionName a -> ActionName a -> ActionName a #

data Log #

Constructors

LogAny !Text |
LogProcessOutput String |
LogCreateProcessRun CreateProcess |
LogProcessRun FilePath [FilePath] |
LogRequestedCradleLoadStyle !Text !LoadStyle |
LogComputedCradleLoadStyle !Text !LoadStyle |
LogLoadWithContextUnsupported !Text !(Maybe Text) |

#### Instances

Instances details

Show Log # |
Instance details Defined in HIE.Bios.Types Methods showsPrec :: Int -> Log -> ShowS # show :: Log -> String # showList :: [Log] -> ShowS #
Pretty Log # |
Instance details Defined in HIE.Bios.Types Methods pretty :: Log -> Doc ann # prettyList :: [Log] -> Doc ann #

data LoadStyle #

The `LoadStyle` instructs a cradle on how to load a given file target.

Constructors

LoadFile | Instruct the cradle to load the given file target. What this entails depends on the cradle. For example, the `cabal` cradle will configure the whole component the file target belongs to, and produce component options to load the component, which is the minimal unit of code in cabal repl. A 'default' cradle, on the other hand, will only load the given filepath.
LoadWithContext [FilePath] | Give a cradle additional context for loading a file target. The context instructs the cradle to load the file target, while also loading the given filepaths. This is useful for cradles that support loading multiple code units at once, e.g. cabal cradles can use the 'multi-repl' feature to set up a multiple home unit session in GHC.

#### Instances

Instances details

Show LoadStyle # |
Instance details Defined in HIE.Bios.Types Methods showsPrec :: Int -> LoadStyle -> ShowS # show :: LoadStyle -> String # showList :: [LoadStyle] -> ShowS #
Eq LoadStyle # |
Instance details Defined in HIE.Bios.Types Methods (==) :: LoadStyle -> LoadStyle -> Bool # (/=) :: LoadStyle -> LoadStyle -> Bool #
Ord LoadStyle # |
Instance details Defined in HIE.Bios.Types Methods compare :: LoadStyle -> LoadStyle -> Ordering # (<) :: LoadStyle -> LoadStyle -> Bool # (<=) :: LoadStyle -> LoadStyle -> Bool # (>) :: LoadStyle -> LoadStyle -> Bool # (>=) :: LoadStyle -> LoadStyle -> Bool # max :: LoadStyle -> LoadStyle -> LoadStyle # min :: LoadStyle -> LoadStyle -> LoadStyle #

data CradleAction a #

Constructors

CradleAction |

Fields

- actionName :: ActionName a

  Name of the action.

- runCradle :: FilePath -> LoadStyle -> IO (CradleLoadResult ComponentOptions)

  Options to compile the given file with.

- runGhcCmd :: [String] -> IO (CradleLoadResult String)

  Executes the `ghc` binary that is usually used to build the cradle. E.g. for a cabal cradle this should be equivalent to `cabal exec ghc -- args`

#### Instances

Instances details

Functor CradleAction # |
Instance details Defined in HIE.Bios.Types Methods fmap :: (a -> b) -> CradleAction a -> CradleAction b # (<$) :: a -> CradleAction b -> CradleAction a #
Show a => Show (CradleAction a) # |
Instance details Defined in HIE.Bios.Types Methods showsPrec :: Int -> CradleAction a -> ShowS # show :: CradleAction a -> String # showList :: [CradleAction a] -> ShowS #

data CradleLoadResult r #

Result of an attempt to set up a GHC session for a `Cradle`. This is the go-to error handling mechanism. When possible, this should be preferred over throwing exceptions.

Constructors

CradleSuccess r | The cradle succeeded and returned these options.
CradleFail CradleError | We tried to load the cradle and it failed.
CradleNone | No attempt was made to load the cradle.

#### Instances

Instances details

Applicative CradleLoadResult # |

Instance details

Defined in HIE.Bios.Types

Methods

pure :: a -> CradleLoadResult a #

(<*>) :: CradleLoadResult (a -> b) -> CradleLoadResult a -> CradleLoadResult b #

liftA2 :: (a -> b -> c) -> CradleLoadResult a -> CradleLoadResult b -> CradleLoadResult c #

(*>) :: CradleLoadResult a -> CradleLoadResult b -> CradleLoadResult b #

(<*) :: CradleLoadResult a -> CradleLoadResult b -> CradleLoadResult a #

Functor CradleLoadResult # |
Instance details Defined in HIE.Bios.Types Methods fmap :: (a -> b) -> CradleLoadResult a -> CradleLoadResult b # (<$) :: a -> CradleLoadResult b -> CradleLoadResult a #
Monad CradleLoadResult # |
Instance details Defined in HIE.Bios.Types Methods (>>=) :: CradleLoadResult a -> (a -> CradleLoadResult b) -> CradleLoadResult b # (>>) :: CradleLoadResult a -> CradleLoadResult b -> CradleLoadResult b # return :: a -> CradleLoadResult a #
Foldable CradleLoadResult # |

Instance details

Defined in HIE.Bios.Types

Methods

fold :: Monoid m => CradleLoadResult m -> m #

foldMap :: Monoid m => (a -> m) -> CradleLoadResult a -> m #

foldMap' :: Monoid m => (a -> m) -> CradleLoadResult a -> m #

foldr :: (a -> b -> b) -> b -> CradleLoadResult a -> b #

foldr' :: (a -> b -> b) -> b -> CradleLoadResult a -> b #

foldl :: (b -> a -> b) -> b -> CradleLoadResult a -> b #

foldl' :: (b -> a -> b) -> b -> CradleLoadResult a -> b #

foldr1 :: (a -> a -> a) -> CradleLoadResult a -> a #

foldl1 :: (a -> a -> a) -> CradleLoadResult a -> a #

toList :: CradleLoadResult a -> [a] #

null :: CradleLoadResult a -> Bool #

length :: CradleLoadResult a -> Int #

elem :: Eq a => a -> CradleLoadResult a -> Bool #

maximum :: Ord a => CradleLoadResult a -> a #

minimum :: Ord a => CradleLoadResult a -> a #

sum :: Num a => CradleLoadResult a -> a #

product :: Num a => CradleLoadResult a -> a #

Traversable CradleLoadResult # |
Instance details Defined in HIE.Bios.Types Methods traverse :: Applicative f => (a -> f b) -> CradleLoadResult a -> f (CradleLoadResult b) # sequenceA :: Applicative f => CradleLoadResult (f a) -> f (CradleLoadResult a) # mapM :: Monad m => (a -> m b) -> CradleLoadResult a -> m (CradleLoadResult b) # sequence :: Monad m => CradleLoadResult (m a) -> m (CradleLoadResult a) #
Show r => Show (CradleLoadResult r) # |
Instance details Defined in HIE.Bios.Types Methods showsPrec :: Int -> CradleLoadResult r -> ShowS # show :: CradleLoadResult r -> String # showList :: [CradleLoadResult r] -> ShowS #
Eq r => Eq (CradleLoadResult r) # |
Instance details Defined in HIE.Bios.Types Methods (==) :: CradleLoadResult r -> CradleLoadResult r -> Bool # (/=) :: CradleLoadResult r -> CradleLoadResult r -> Bool #

cradleLoadResult :: c -> (CradleError -> c) -> (r -> c) -> CradleLoadResult r -> c #

newtype CradleLoadResultT (m :: Type -> Type) a #

Constructors

CradleLoadResultT |

Fields

- runCradleResultT :: m (CradleLoadResult a)

#### Instances

Instances details

MonadTrans CradleLoadResultT # |
Instance details Defined in HIE.Bios.Types Methods lift :: Monad m => m a -> CradleLoadResultT m a #
MonadIO m => MonadIO (CradleLoadResultT m) # |
Instance details Defined in HIE.Bios.Types Methods liftIO :: IO a -> CradleLoadResultT m a #
(Monad m, Applicative m) => Applicative (CradleLoadResultT m) # |

Instance details

Defined in HIE.Bios.Types

Methods

pure :: a -> CradleLoadResultT m a #

(<*>) :: CradleLoadResultT m (a -> b) -> CradleLoadResultT m a -> CradleLoadResultT m b #

liftA2 :: (a -> b -> c) -> CradleLoadResultT m a -> CradleLoadResultT m b -> CradleLoadResultT m c #

(*>) :: CradleLoadResultT m a -> CradleLoadResultT m b -> CradleLoadResultT m b #

(<*) :: CradleLoadResultT m a -> CradleLoadResultT m b -> CradleLoadResultT m a #

Functor f => Functor (CradleLoadResultT f) # |
Instance details Defined in HIE.Bios.Types Methods fmap :: (a -> b) -> CradleLoadResultT f a -> CradleLoadResultT f b # (<$) :: a -> CradleLoadResultT f b -> CradleLoadResultT f a #
Monad m => Monad (CradleLoadResultT m) # |
Instance details Defined in HIE.Bios.Types Methods (>>=) :: CradleLoadResultT m a -> (a -> CradleLoadResultT m b) -> CradleLoadResultT m b # (>>) :: CradleLoadResultT m a -> CradleLoadResultT m b -> CradleLoadResultT m b # return :: a -> CradleLoadResultT m a #
MonadFail m => MonadFail (CradleLoadResultT m) # |
Instance details Defined in HIE.Bios.Types Methods fail :: String -> CradleLoadResultT m a #

modCradleError :: Monad m => CradleLoadResultT m a -> (CradleError -> m CradleError) -> CradleLoadResultT m a #

throwCE :: forall (m :: Type -> Type) a. Monad m => CradleError -> CradleLoadResultT m a #

data CradleError #

Constructors

CradleError |

Fields

- cradleErrorDependencies :: [FilePath]

  Dependencies of the cradle that failed to load. Can be watched for changes to attempt a reload of the cradle.

- cradleErrorExitCode :: ExitCode

  ExitCode of the cradle loading mechanism.

- cradleErrorStderr :: [String]

  Standard error output that can be shown to users to explain the loading error.

#### Instances

Instances details

Exception CradleError # |
Instance details Defined in HIE.Bios.Types Methods toException :: CradleError -> SomeException # fromException :: SomeException -> Maybe CradleError # displayException :: CradleError -> String # backtraceDesired :: CradleError -> Bool #
Show CradleError # |
Instance details Defined in HIE.Bios.Types Methods showsPrec :: Int -> CradleError -> ShowS # show :: CradleError -> String # showList :: [CradleError] -> ShowS #
Eq CradleError # |
Instance details Defined in HIE.Bios.Types Methods (==) :: CradleError -> CradleError -> Bool # (/=) :: CradleError -> CradleError -> Bool #

data ComponentOptions #

Option information for GHC

Constructors

ComponentOptions |

Fields

- componentOptions :: [String]

  Command line options.

- componentRoot :: FilePath

  Root directory of the component. All `componentOptions` are either absolute, or relative to this directory.

- componentDependencies :: [FilePath]

  Dependencies of a cradle that might change the cradle. Contains both files specified in hie.yaml as well as specified by the build-tool if there is any. FilePaths are expected to be relative to the `cradleRootDir` to which this CradleAction belongs to. Files returned by this action might not actually exist. This is useful, because, sometimes, adding specific files changes the options that a Cradle may return, thus, needs reload as soon as these files are created.

#### Instances

Instances details

Show ComponentOptions # |
Instance details Defined in HIE.Bios.Types Methods showsPrec :: Int -> ComponentOptions -> ShowS # show :: ComponentOptions -> String # showList :: [ComponentOptions] -> ShowS #
Eq ComponentOptions # |
Instance details Defined in HIE.Bios.Types Methods (==) :: ComponentOptions -> ComponentOptions -> Bool # (/=) :: ComponentOptions -> ComponentOptions -> Bool #
Ord ComponentOptions # |

Instance details

Defined in HIE.Bios.Types

Methods

compare :: ComponentOptions -> ComponentOptions -> Ordering #

(<) :: ComponentOptions -> ComponentOptions -> Bool #

(<=) :: ComponentOptions -> ComponentOptions -> Bool #

(>) :: ComponentOptions -> ComponentOptions -> Bool #

(>=) :: ComponentOptions -> ComponentOptions -> Bool #

max :: ComponentOptions -> ComponentOptions -> ComponentOptions #

min :: ComponentOptions -> ComponentOptions -> ComponentOptions #

prettyCmdSpec :: CmdSpec -> String #

Prettify `CmdSpec`, so we can show the command to a user

prettyProcessEnv :: CreateProcess -> [String] #

Pretty print hie-bios's relevant environment variables.