module Navi.Effects.MonadNotify
( MonadNotify (..),
sendNoteQueue,
)
where
import Navi.Data.NaviNote (NaviNote (..))
import Navi.Env.Core (HasNoteQueue (..))
import Navi.Prelude
class Monad m => MonadNotify m where
sendNote :: HasCallStack => NaviNote -> m ()
instance MonadNotify m => MonadNotify (ReaderT e m) where
sendNote :: HasCallStack => NaviNote -> ReaderT e m ()
sendNote = forall (t :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: Type -> Type).
(MonadNotify m, HasCallStack) =>
NaviNote -> m ()
sendNote
{-# INLINEABLE sendNote #-}
sendNoteQueue ::
( HasCallStack,
HasNoteQueue env,
MonadReader env m,
MonadSTM m
) =>
NaviNote ->
m ()
sendNoteQueue :: forall env (m :: Type -> Type).
(HasCallStack, HasNoteQueue env, MonadReader env m, MonadSTM m) =>
NaviNote -> m ()
sendNoteQueue NaviNote
naviNote =
forall r (m :: Type -> Type) a. MonadReader r m => (r -> a) -> m a
asks forall env. HasNoteQueue env => env -> TBQueue NaviNote
getNoteQueue forall (m :: Type -> Type) a b. Monad m => m a -> (a -> m b) -> m b
>>= (forall (m :: Type -> Type) a.
(HasCallStack, MonadSTM m) =>
TBQueue a -> a -> m ()
`writeTBQueueM` NaviNote
naviNote)
{-# INLINEABLE sendNoteQueue #-}