module Ribosome.Host.Interpreter.UserError where

import Polysemy.Log (Severity (Info))

import Ribosome.Host.Effect.UserError (UserError (UserError))

interpretUserErrorInfo :: InterpreterFor UserError r
interpretUserErrorInfo :: forall (r :: [Effect]). InterpreterFor UserError r
interpretUserErrorInfo =
  (forall (rInitial :: [Effect]) x.
 UserError (Sem rInitial) x -> Sem r x)
-> Sem (UserError : r) a -> Sem r a
forall (e :: Effect) (r :: [Effect]) a.
FirstOrder e "interpret" =>
(forall (rInitial :: [Effect]) 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 ->
      Maybe [Text] -> Sem r (Maybe [Text])
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([Text] -> Maybe [Text]
forall a. a -> Maybe a
Just [Text
Item [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