module Ribosome.Interpreter.UserError where
import Log (Severity (Info))
import Ribosome.Data.PluginName (PluginName)
import Ribosome.Host.Effect.UserError (UserError (UserError))
import Ribosome.PluginName (pluginNamePrefixed)
interpretUserErrorPrefixed ::
Member (Reader PluginName) r =>
InterpreterFor UserError r
interpretUserErrorPrefixed :: forall (r :: EffectRow).
Member (Reader PluginName) r =>
InterpreterFor UserError r
interpretUserErrorPrefixed =
(forall (rInitial :: EffectRow) x.
UserError (Sem rInitial) x -> Sem r x)
-> Sem (UserError : r) a -> Sem r a
forall (e :: (* -> *) -> * -> *) (r :: EffectRow) a.
FirstOrder e "interpret" =>
(forall (rInitial :: EffectRow) x. e (Sem rInitial) x -> Sem r x)
-> Sem (e : r) a -> Sem r a
interpret \case
UserError Text
e Severity
severity | Severity
severity Severity -> Severity -> Bool
forall a. Ord a => a -> a -> Bool
>= Severity
Info ->
[Text] -> Maybe [Text]
forall a. a -> Maybe a
Just ([Text] -> Maybe [Text])
-> (Text -> [Text]) -> Text -> Maybe [Text]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> [Text]
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Text -> Maybe [Text]) -> Sem r Text -> Sem r (Maybe [Text])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> Sem r Text
forall (r :: EffectRow).
Member (Reader PluginName) r =>
Text -> Sem r Text
pluginNamePrefixed Text
e
UserError Text
_ Severity
_ ->
Maybe [Text] -> Sem r (Maybe [Text])
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe [Text]
forall a. Maybe a
Nothing