-- |Description: Internal
module Polysemy.Log.Pure where

import Polysemy.Output (Output, output)

import Polysemy.Log.Data.Log (Log(Log))
import Polysemy.Log.Data.LogMessage (LogMessage)

-- |Interpret 'Log' in terms of 'Output'.
interpretLogOutput ::
  Member (Output LogMessage) r =>
  InterpreterFor Log r
interpretLogOutput :: InterpreterFor Log r
interpretLogOutput =
  (forall (rInitial :: EffectRow) x. Log (Sem rInitial) x -> Sem r x)
-> Sem (Log : r) a -> Sem r a
forall (e :: Effect) (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
    Log msg -> LogMessage -> Sem r ()
forall o (r :: EffectRow).
MemberWithError (Output o) r =>
o -> Sem r ()
output LogMessage
msg

-- |Interpret 'Log' by discarding all messages.
interpretLogNull :: InterpreterFor Log r
interpretLogNull :: Sem (Log : r) a -> Sem r a
interpretLogNull =
  (forall (rInitial :: EffectRow) x. Log (Sem rInitial) x -> Sem r x)
-> Sem (Log : r) a -> Sem r a
forall (e :: Effect) (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
    Log _ -> () -> Sem r ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()