-- |Description: Internal
module Polysemy.Log.Data.LogMetadata where

-- |Internal effect used as an intermediate stage between 'Polysemy.Log.Log' and 'Polysemy.Log.DataLog', for the purpose
-- of isolating the metadata annotation task.
--
-- The type of metadata is arbitrary and chosen in interpreters, but this exposes a 'HasCallStack' dependency since it's
-- the primary purpose.
data LogMetadata msg :: Effect where
  -- |Schedule a message to be annotated and logged.
  Annotated :: HasCallStack => msg -> LogMetadata msg m ()

-- |Schedule a message to be annotated and logged.
annotated ::
  HasCallStack =>
  Member (LogMetadata msg) r =>
  msg ->
  Sem r ()
annotated :: forall msg (r :: EffectRow).
(HasCallStack, Member (LogMetadata msg) r) =>
msg -> Sem r ()
annotated msg
msg =
  LogMetadata msg (Sem r) () -> Sem r ()
forall (e :: Effect) (r :: EffectRow) a.
Member e r =>
e (Sem r) a -> Sem r a
send (msg -> LogMetadata msg (Sem r) ()
forall msg (m :: * -> *).
HasCallStack =>
msg -> LogMetadata msg m ()
Annotated msg
msg)