Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Language.Giml.Logging
Description
Logging infra for the compiler
Synopsis
- type HasLog' msg env b m = (MonadBase b m, MonadReader env m, HasField "logAction" (LogAction b msg) env, HasLog msg b m)
- class HasLog msg b m | m -> b where
- getLogAction :: MonadBase b m => m (LogAction b msg)
- setLogAction :: MonadBase b m => LogAction b msg -> m a -> m a
- data CompileInfo m = CompileInfo {}
- type Compile e m = ExceptT e (ReaderT (CompileInfo m) m)
- type CompilePhase e env b m = (MonadError e m, HasLog' LogMsg env b m)
- data Verbosity
- data Stage
- data LogMsg = LogMsg {
- _lmFile :: FilePath
- _lmStage :: Stage
- _lmRewrite :: Text
- _lmVerbosity :: Verbosity
- _lmMessage :: Text
- runWithoutLogger :: ExceptT e (ReaderT (CompileInfo Identity) Identity) a -> Either e a
- runWithoutLoggerEnv :: ExceptT e Identity a -> Either e a
- runIOLogger :: Verbosity -> FilePath -> ExceptT e (ReaderT (CompileInfo IO) IO) a -> IO (Either e a)
- runIOLoggerWithoutLogging :: ExceptT e (ReaderT (CompileInfo IO) IO) a -> IO (Either e a)
- runIOLoggerWithoutEnv :: ExceptT e IO a -> IO (Either e a)
- runLog :: LogAction m1 LogMsg -> ReaderT (CompileInfo m1) m2 a -> m2 a
- withLogAction :: MonadBase b m => LogAction b LogMsg -> ReaderT (CompileInfo b) m a -> m a
- warn :: HasLog' LogMsg env b m => Text -> m ()
- logGeneral :: HasLog' LogMsg env b m => Text -> m ()
- logConcise :: HasLog' LogMsg env b m => Text -> m ()
- logDetailed :: HasLog' LogMsg env b m => Text -> m ()
- setStage :: HasLog' LogMsg env b m => Stage -> m a -> m a
- setRewrite :: HasLog' LogMsg env b m => Text -> m a -> m a
- logMsg :: HasLog' msg env b m => msg -> m ()
- overLogAction :: HasLog' msg env b m => (msg -> msg) -> m a -> m a
- mkCompileInfoPure :: CompileInfo Identity
- mkCompileInfoIONoLogging :: CompileInfo IO
- mkCompileInfoIO :: Verbosity -> FilePath -> CompileInfo IO
- logStdErr :: Verbosity -> LogAction IO LogMsg
- noLoggingIO :: LogAction IO LogMsg
- noLogging :: LogAction Identity LogMsg
- emptyLogMsg :: LogMsg
- data LogAction (m :: Type -> Type) msg
- class (Applicative b, Applicative m, Monad b, Monad m) => MonadBase (b :: Type -> Type) (m :: Type -> Type) | m -> b
- liftBase :: MonadBase b m => b α -> m α
Documentation
type HasLog' msg env b m = (MonadBase b m, MonadReader env m, HasField "logAction" (LogAction b msg) env, HasLog msg b m) Source #
class HasLog msg b m | m -> b where Source #
Methods
getLogAction :: MonadBase b m => m (LogAction b msg) Source #
setLogAction :: MonadBase b m => LogAction b msg -> m a -> m a Source #
Instances
(MonadBase b m, MonadReader env m, HasField "logAction" (LogAction b msg) env) => HasLog msg b m Source # | |
Defined in Language.Giml.Logging Methods getLogAction :: m (LogAction b msg) Source # setLogAction :: MonadBase b m => LogAction b msg -> m a -> m a Source # |
data CompileInfo m Source #
Constructors
CompileInfo | |
Instances
Generic (CompileInfo m) Source # | |
Defined in Language.Giml.Logging Associated Types type Rep (CompileInfo m) :: Type -> Type # Methods from :: CompileInfo m -> Rep (CompileInfo m) x # to :: Rep (CompileInfo m) x -> CompileInfo m # | |
type Rep (CompileInfo m) Source # | |
Defined in Language.Giml.Logging type Rep (CompileInfo m) = D1 ('MetaData "CompileInfo" "Language.Giml.Logging" "giml-language-0.1.0.0-D00xD3NNyCIERJGkwuGtlB" 'False) (C1 ('MetaCons "CompileInfo" 'PrefixI 'True) (S1 ('MetaSel ('Just "logAction") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (LogAction m LogMsg)))) |
type CompilePhase e env b m = (MonadError e m, HasLog' LogMsg env b m) Source #
Verbose level from least detailed to most detailed
Instances
Read Verbosity Source # | |
Show Verbosity Source # | |
Eq Verbosity Source # | |
Ord Verbosity Source # | |
Which stage did the message come from
Constructors
Parsing | |
PreInfer | |
TypeInference | |
PostInfer | |
Compilation Text |
The type of a message we wish to log.
- Stage (pre infer, post infer, etc.)
- Specific rewrite/process (parsing, grouping definitions, elaboration, constraint solving)
- Verbosity level (only constraints generated, each constraint, etc.)
- The message in the log
Constructors
LogMsg | |
Fields
|
runWithoutLogger :: ExceptT e (ReaderT (CompileInfo Identity) Identity) a -> Either e a Source #
runIOLogger :: Verbosity -> FilePath -> ExceptT e (ReaderT (CompileInfo IO) IO) a -> IO (Either e a) Source #
runIOLoggerWithoutLogging :: ExceptT e (ReaderT (CompileInfo IO) IO) a -> IO (Either e a) Source #
withLogAction :: MonadBase b m => LogAction b LogMsg -> ReaderT (CompileInfo b) m a -> m a Source #
overLogAction :: HasLog' msg env b m => (msg -> msg) -> m a -> m a Source #
mkCompileInfoIO :: Verbosity -> FilePath -> CompileInfo IO Source #
emptyLogMsg :: LogMsg Source #
data LogAction (m :: Type -> Type) msg #
Polymorphic and very general logging action type.
msg
type variables is an input for logger. It can beText
or custom logging messsage with different fields that you want to format in future.m
type variable is for monadic action inside which logging is happening. It can be eitherIO
or some custom pure monad.
Key design point here is that LogAction
is:
Instances
Contravariant (LogAction m) | |
UnrepresentableClass => Functor (LogAction m) | ⚠️CAUTION⚠️ This instance is for custom error display only.
In case it is used by mistake, the user will see the following:
# 207 "srcCologCore/Action.hs" Since: co-log-core-0.2.1.0 |
Applicative m => Monoid (LogAction m a) | |
Applicative m => Semigroup (LogAction m a) | This instance allows you to join multiple logging actions into single one. For example, if you have two actions like these: logToStdout :: You can create new logToBoth :: |
class (Applicative b, Applicative m, Monad b, Monad m) => MonadBase (b :: Type -> Type) (m :: Type -> Type) | m -> b #
Minimal complete definition