giml-language-0.1.0.0: A purely functional programming language with emphasis on structural typing
Safe HaskellSafe-Inferred
LanguageGHC2021

Language.Giml.Logging

Description

Logging infra for the compiler

Synopsis

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

Instances details
(MonadBase b m, MonadReader env m, HasField "logAction" (LogAction b msg) env) => HasLog msg b m Source # 
Instance details

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

Instances details
Generic (CompileInfo m) Source # 
Instance details

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 # 
Instance details

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 Compile e m = ExceptT e (ReaderT (CompileInfo m) m) Source #

type CompilePhase e env b m = (MonadError e m, HasLog' LogMsg env b m) Source #

data Verbosity Source #

Verbose level from least detailed to most detailed

Constructors

Warning 
General 
Concise 
Detailed 

data Stage Source #

Which stage did the message come from

Instances

Instances details
Show Stage Source # 
Instance details

Defined in Language.Giml.Logging

Methods

showsPrec :: Int -> Stage -> ShowS #

show :: Stage -> String #

showList :: [Stage] -> ShowS #

data LogMsg Source #

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

Instances

Instances details
Show LogMsg Source # 
Instance details

Defined in Language.Giml.Logging

runLog :: LogAction m1 LogMsg -> ReaderT (CompileInfo m1) m2 a -> m2 a Source #

warn :: HasLog' LogMsg env b m => Text -> m () Source #

logGeneral :: HasLog' LogMsg env b m => Text -> m () Source #

logConcise :: HasLog' LogMsg env b m => Text -> m () Source #

logDetailed :: HasLog' LogMsg env b m => Text -> m () Source #

setStage :: HasLog' LogMsg env b m => Stage -> m a -> m a Source #

setRewrite :: HasLog' LogMsg env b m => Text -> m a -> m a Source #

logMsg :: HasLog' msg env b m => msg -> m () Source #

overLogAction :: HasLog' msg env b m => (msg -> msg) -> m a -> m a Source #

data LogAction (m :: Type -> Type) msg #

Polymorphic and very general logging action type.

  • msg type variables is an input for logger. It can be Text 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 either IO or some custom pure monad.

Key design point here is that LogAction is:

Instances

Instances details
Contravariant (LogAction m) 
Instance details

Defined in Colog.Core.Action

Methods

contramap :: (a' -> a) -> LogAction m a -> LogAction m a' #

(>$) :: b -> LogAction m b -> LogAction m a #

UnrepresentableClass => Functor (LogAction m)

⚠️CAUTION⚠️ This instance is for custom error display only.

LogAction is not supposed to have Functor instance by design.

In case it is used by mistake, the user will see the following:

>>> fmap show logStringStdout
...
... 'LogAction' cannot have a 'Functor' instance by design.
      However, you've attempted to use this instance.
...
      Probably you meant 'Contravariant' class instance with the following methods:
        * contramap :: (a -> b) -> LogAction m b -> LogAction m a
        * (>$) :: b -> LogAction m b -> LogAction m a
...

# 207 "srcCologCore/Action.hs"

Since: co-log-core-0.2.1.0

Instance details

Defined in Colog.Core.Action

Methods

fmap :: (a -> b) -> LogAction m a -> LogAction m b #

(<$) :: a -> LogAction m b -> LogAction m a #

Applicative m => Monoid (LogAction m a) 
Instance details

Defined in Colog.Core.Action

Methods

mempty :: LogAction m a #

mappend :: LogAction m a -> LogAction m a -> LogAction m a #

mconcat :: [LogAction m a] -> 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 :: LogAction IO String  -- outputs String to terminal
logToFile   :: LogAction IO String  -- appends String to some file

You can create new LogAction that perform both actions one after another using Semigroup:

logToBoth :: LogAction IO String  -- outputs String to both terminal and some file
logToBoth = logToStdout <> logToFile
Instance details

Defined in Colog.Core.Action

Methods

(<>) :: LogAction m a -> LogAction m a -> LogAction m a #

sconcat :: NonEmpty (LogAction m a) -> LogAction m a #

stimes :: Integral b => b -> LogAction m a -> LogAction m a #

class (Applicative b, Applicative m, Monad b, Monad m) => MonadBase (b :: Type -> Type) (m :: Type -> Type) | m -> b #

Minimal complete definition

liftBase

Instances

Instances details
MonadBase Identity Identity 
Instance details

Defined in Control.Monad.Base

Methods

liftBase :: Identity α -> Identity α #

MonadBase STM STM 
Instance details

Defined in Control.Monad.Base

Methods

liftBase :: STM α -> STM α #

MonadBase IO IO 
Instance details

Defined in Control.Monad.Base

Methods

liftBase :: IO α -> IO α #

MonadBase Maybe Maybe 
Instance details

Defined in Control.Monad.Base

Methods

liftBase :: Maybe α -> Maybe α #

MonadBase [] [] 
Instance details

Defined in Control.Monad.Base

Methods

liftBase :: [α] -> [α] #

MonadBase b m => MonadBase b (ListT m) 
Instance details

Defined in Control.Monad.Base

Methods

liftBase :: b α -> ListT m α #

MonadBase b m => MonadBase b (MaybeT m) 
Instance details

Defined in Control.Monad.Base

Methods

liftBase :: b α -> MaybeT m α #

(Monoid w, MonadBase b m) => MonadBase b (AccumT w m) 
Instance details

Defined in Control.Monad.Base

Methods

liftBase :: b α -> AccumT w m α #

(Error e, MonadBase b m) => MonadBase b (ErrorT e m) 
Instance details

Defined in Control.Monad.Base

Methods

liftBase :: b α -> ErrorT e m α #

MonadBase b m => MonadBase b (ExceptT e m) 
Instance details

Defined in Control.Monad.Base

Methods

liftBase :: b α -> ExceptT e m α #

MonadBase b m => MonadBase b (IdentityT m) 
Instance details

Defined in Control.Monad.Base

Methods

liftBase :: b α -> IdentityT m α #

MonadBase b m => MonadBase b (ReaderT r m) 
Instance details

Defined in Control.Monad.Base

Methods

liftBase :: b α -> ReaderT r m α #

MonadBase b m => MonadBase b (SelectT r m) 
Instance details

Defined in Control.Monad.Base

Methods

liftBase :: b α -> SelectT r m α #

MonadBase b m => MonadBase b (StateT s m) 
Instance details

Defined in Control.Monad.Base

Methods

liftBase :: b α -> StateT s m α #

MonadBase b m => MonadBase b (StateT s m) 
Instance details

Defined in Control.Monad.Base

Methods

liftBase :: b α -> StateT s m α #

(Monoid w, MonadBase b m) => MonadBase b (WriterT w m) 
Instance details

Defined in Control.Monad.Base

Methods

liftBase :: b α -> WriterT w m α #

(Monoid w, MonadBase b m) => MonadBase b (WriterT w m) 
Instance details

Defined in Control.Monad.Base

Methods

liftBase :: b α -> WriterT w m α #

(Monoid w, MonadBase b m) => MonadBase b (WriterT w m) 
Instance details

Defined in Control.Monad.Base

Methods

liftBase :: b α -> WriterT w m α #

MonadBase b m => MonadBase b (ContT r m) 
Instance details

Defined in Control.Monad.Base

Methods

liftBase :: b α -> ContT r m α #

(Monoid w, MonadBase b m) => MonadBase b (RWST r w s m) 
Instance details

Defined in Control.Monad.Base

Methods

liftBase :: b α -> RWST r w s m α #

(Monoid w, MonadBase b m) => MonadBase b (RWST r w s m) 
Instance details

Defined in Control.Monad.Base

Methods

liftBase :: b α -> RWST r w s m α #

(Monoid w, MonadBase b m) => MonadBase b (RWST r w s m) 
Instance details

Defined in Control.Monad.Base

Methods

liftBase :: b α -> RWST r w s m α #

MonadBase (ST s) (ST s) 
Instance details

Defined in Control.Monad.Base

Methods

liftBase :: ST s α -> ST s α #

MonadBase (Either e) (Either e) 
Instance details

Defined in Control.Monad.Base

Methods

liftBase :: Either e α -> Either e α #

MonadBase (ST s) (ST s) 
Instance details

Defined in Control.Monad.Base

Methods

liftBase :: ST s α -> ST s α #

MonadBase ((->) r) ((->) r) 
Instance details

Defined in Control.Monad.Base

Methods

liftBase :: (r -> α) -> r -> α #

liftBase :: MonadBase b m => b α -> m α #

Lift a computation from the base monad