Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- context :: Member (DataLog LogReport) r => Text -> Sem r a -> Sem r a
- setContext :: Member (DataLog LogReport) r => ReportContext -> Sem r a -> Sem r a
- logReport :: Reportable e => Member (DataLog LogReport) r => e -> Sem r ()
- info :: Member (DataLog LogReport) r => Text -> [Text] -> Sem r ()
- warn :: Member (DataLog LogReport) r => Text -> [Text] -> Sem r ()
- error :: Member (DataLog LogReport) r => Text -> [Text] -> Sem r ()
- reportStop :: forall err r. Reportable err => Member (DataLog LogReport) r => Sem (Stop err ': r) () -> Sem r ()
- resumeLogReport :: forall eff e r. Reportable e => Members [eff !! e, DataLog LogReport] r => Sem (eff ': r) () -> Sem r ()
- pluginLogReports :: Members [Scratch !! RpcError, Settings !! SettingError, Rpc !! RpcError, Stop Report] r => InterpretersFor [Scratch, Settings, Rpc] r
- storedReports :: forall (r :: EffectRow). Member Reports r => Sem r (Map ReportContext [StoredReport])
- storeReport :: forall (r :: EffectRow). Member Reports r => ReportContext -> Report -> Sem r ()
- data Reports (a :: Type -> Type) b where
- StoreReport :: forall (a :: Type -> Type). ReportContext -> Report -> Reports a ()
- StoredReports :: forall (a :: Type -> Type). Reports a (Map ReportContext [StoredReport])
- module Ribosome.Host.Interpreter.Reports
- data LogReport = LogReport Report Bool Bool ReportContext
- data Report where
- newtype ReportContext = ReportContext [Text]
- class Reportable e where
Documentation
context :: Member (DataLog LogReport) r => Text -> Sem r a -> Sem r a Source #
Add a segment to the current Report
logging context.
setContext :: Member (DataLog LogReport) r => ReportContext -> Sem r a -> Sem r a Source #
Set the current Report
logging context.
logReport :: Reportable e => Member (DataLog LogReport) r => e -> Sem r () Source #
Convert a value to Report
via Reportable
and send it to the log.
reportStop :: forall err r. Reportable err => Member (DataLog LogReport) r => Sem (Stop err ': r) () -> Sem r () Source #
resumeLogReport :: forall eff e r. Reportable e => Members [eff !! e, DataLog LogReport] r => Sem (eff ': r) () -> Sem r () Source #
Resume an effect by converting the error to a Report
and logging it, continuing execution for a unit action.
pluginLogReports :: Members [Scratch !! RpcError, Settings !! SettingError, Rpc !! RpcError, Stop Report] r => InterpretersFor [Scratch, Settings, Rpc] r Source #
Resume all plugin effects.
storedReports :: forall (r :: EffectRow). Member Reports r => Sem r (Map ReportContext [StoredReport]) #
Get all reports.
storeReport :: forall (r :: EffectRow). Member Reports r => ReportContext -> Report -> Sem r () #
Add a report to the store.
data Reports (a :: Type -> Type) b where #
This internal effect stores all errors in memory that have been created through the Report
system.
StoreReport :: forall (a :: Type -> Type). ReportContext -> Report -> Reports a () | Add a report to the store. |
StoredReports :: forall (a :: Type -> Type). Reports a (Map ReportContext [StoredReport]) | Get all reports. |
The type used by request handlers and expected by the RPC dispatcher.
Instances
IsString LogReport | |
Defined in Ribosome.Host.Data.Report fromString :: String -> LogReport # | |
Generic LogReport | |
Show LogReport | |
type Rep LogReport | |
Defined in Ribosome.Host.Data.Report type Rep LogReport = D1 ('MetaData "LogReport" "Ribosome.Host.Data.Report" "ribosome-host-0.9.9.9-4n86eC1033RAA2pmC2T1m9" 'False) (C1 ('MetaCons "LogReport" 'PrefixI 'True) ((S1 ('MetaSel ('Just "report") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Report) :*: S1 ('MetaSel ('Just "echo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)) :*: (S1 ('MetaSel ('Just "store") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool) :*: S1 ('MetaSel ('Just "context") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ReportContext)))) |
An report with different messages intended to be sent to Neovim and the log, respectively.
Used by request handlers and expected by the RPC dispatcher.
Also contains the Severity
of the report, or minimum log level, which determines whether the report should be
logged and echoed in Neovim, and what kind of highlighting should be used in Neovim (red for errors, orange for
warnings, none for infomrational errors).
The log message may span multiple lines.
Instances
IsString Report | |
Defined in Ribosome.Host.Data.Report fromString :: String -> Report # | |
Show Report | |
Reportable Report | |
Defined in Ribosome.Host.Data.Report | |
MsgpackEncode a => HandlerCodec (Handler r a) r | |
Defined in Ribosome.Host.Handler.Codec handlerCodec :: Handler r a -> RpcHandlerFun r # |
newtype ReportContext #
The provenance of a report, for use in logs.
Instances
class Reportable e where #
The class of types that are convertible to a Report
.
This is used to create a uniform format for handlers, since control flow is passed on to the internal machinery when
they return.
If an error would be thrown that is not caught by the request dispatcher, the entire plugin would stop, so all Stop
and Resumable
effects need to be converted to Report
before returning (see Errors).
The combinators associated with this class make this task a little less arduous:
data NumbersError = InvalidNumber instance Reportable NumbersError where toReport InvalidNumber = Report "Invalid number!" ["The user entered an invalid number"] Warn count :: Int -> Sem r Int count i = resumeReport @Rpc $ mapReport @NumbersError do when (i == 0) (stop InvalidNumber) nvimGetVar ("number_" <> show i)
Here resumeReport
converts a potential RpcError
from nvimGetVar
to Report
(e.g. if the variable
is not set), while mapReport
uses the instance
to convert the call to Reportable
NumbersError
stop
.
Instances
Reportable Void | |
Defined in Ribosome.Host.Data.Report | |
Reportable PersistError Source # | |
Defined in Ribosome.Data.PersistError toReport :: PersistError -> Report # | |
Reportable PersistPathError Source # | |
Defined in Ribosome.Data.PersistPathError toReport :: PersistPathError -> Report # | |
Reportable SettingError Source # | |
Defined in Ribosome.Data.SettingError toReport :: SettingError -> Report # | |
Reportable DecodeError | |
Defined in Ribosome.Host.Class.Msgpack.Error toReport :: DecodeError -> Report # | |
Reportable Report | |
Defined in Ribosome.Host.Data.Report | |
Reportable RpcError | |
Defined in Ribosome.Host.Data.RpcError |