{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE UndecidableInstances #-}
module Navi.NaviT
( NaviT (..),
runNaviT,
)
where
import DBus.Notify qualified as DBusN
import Effects.LoggerNamespace
( MonadLoggerNamespace (..),
addNamespace,
defaultLogFormatter,
formatLog,
)
import Effects.System.Terminal (MonadTerminal (..))
import Effects.Time (MonadTime (..))
import Navi.Effects.MonadNotify (MonadNotify (..))
import Navi.Effects.MonadSystemInfo (MonadSystemInfo (..))
import Navi.Env.Core
( HasLogEnv (..),
HasLogQueue (getLogQueue),
)
import Navi.Env.DBus (DBusEnv, HasDBusClient (..), naviToDBus)
import Navi.Env.NotifySend (NotifySendEnv, naviToNotifySend)
import Navi.Prelude
import System.Process qualified as Proc
type NaviT :: Type -> (Type -> Type) -> Type -> Type
newtype NaviT e m a = MkNaviT (ReaderT e m a)
deriving
( forall a b. a -> NaviT e m b -> NaviT e m a
forall a b. (a -> b) -> NaviT e m a -> NaviT e m b
forall e (m :: Type -> Type) a b.
Functor m =>
a -> NaviT e m b -> NaviT e m a
forall e (m :: Type -> Type) a b.
Functor m =>
(a -> b) -> NaviT e m a -> NaviT e m b
forall (f :: Type -> Type).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> NaviT e m b -> NaviT e m a
$c<$ :: forall e (m :: Type -> Type) a b.
Functor m =>
a -> NaviT e m b -> NaviT e m a
fmap :: forall a b. (a -> b) -> NaviT e m a -> NaviT e m b
$cfmap :: forall e (m :: Type -> Type) a b.
Functor m =>
(a -> b) -> NaviT e m a -> NaviT e m b
Functor,
forall a. a -> NaviT e m a
forall a b. NaviT e m a -> NaviT e m b -> NaviT e m a
forall a b. NaviT e m a -> NaviT e m b -> NaviT e m b
forall a b. NaviT e m (a -> b) -> NaviT e m a -> NaviT e m b
forall a b c.
(a -> b -> c) -> NaviT e m a -> NaviT e m b -> NaviT e m c
forall {e} {m :: Type -> Type}.
Applicative m =>
Functor (NaviT e m)
forall e (m :: Type -> Type) a. Applicative m => a -> NaviT e m a
forall e (m :: Type -> Type) a b.
Applicative m =>
NaviT e m a -> NaviT e m b -> NaviT e m a
forall e (m :: Type -> Type) a b.
Applicative m =>
NaviT e m a -> NaviT e m b -> NaviT e m b
forall e (m :: Type -> Type) a b.
Applicative m =>
NaviT e m (a -> b) -> NaviT e m a -> NaviT e m b
forall e (m :: Type -> Type) a b c.
Applicative m =>
(a -> b -> c) -> NaviT e m a -> NaviT e m b -> NaviT e m c
forall (f :: Type -> Type).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
<* :: forall a b. NaviT e m a -> NaviT e m b -> NaviT e m a
$c<* :: forall e (m :: Type -> Type) a b.
Applicative m =>
NaviT e m a -> NaviT e m b -> NaviT e m a
*> :: forall a b. NaviT e m a -> NaviT e m b -> NaviT e m b
$c*> :: forall e (m :: Type -> Type) a b.
Applicative m =>
NaviT e m a -> NaviT e m b -> NaviT e m b
liftA2 :: forall a b c.
(a -> b -> c) -> NaviT e m a -> NaviT e m b -> NaviT e m c
$cliftA2 :: forall e (m :: Type -> Type) a b c.
Applicative m =>
(a -> b -> c) -> NaviT e m a -> NaviT e m b -> NaviT e m c
<*> :: forall a b. NaviT e m (a -> b) -> NaviT e m a -> NaviT e m b
$c<*> :: forall e (m :: Type -> Type) a b.
Applicative m =>
NaviT e m (a -> b) -> NaviT e m a -> NaviT e m b
pure :: forall a. a -> NaviT e m a
$cpure :: forall e (m :: Type -> Type) a. Applicative m => a -> NaviT e m a
Applicative,
forall a. a -> NaviT e m a
forall a b. NaviT e m a -> NaviT e m b -> NaviT e m b
forall a b. NaviT e m a -> (a -> NaviT e m b) -> NaviT e m b
forall {e} {m :: Type -> Type}. Monad m => Applicative (NaviT e m)
forall e (m :: Type -> Type) a. Monad m => a -> NaviT e m a
forall e (m :: Type -> Type) a b.
Monad m =>
NaviT e m a -> NaviT e m b -> NaviT e m b
forall e (m :: Type -> Type) a b.
Monad m =>
NaviT e m a -> (a -> NaviT e m b) -> NaviT e m b
forall (m :: Type -> Type).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: forall a. a -> NaviT e m a
$creturn :: forall e (m :: Type -> Type) a. Monad m => a -> NaviT e m a
>> :: forall a b. NaviT e m a -> NaviT e m b -> NaviT e m b
$c>> :: forall e (m :: Type -> Type) a b.
Monad m =>
NaviT e m a -> NaviT e m b -> NaviT e m b
>>= :: forall a b. NaviT e m a -> (a -> NaviT e m b) -> NaviT e m b
$c>>= :: forall e (m :: Type -> Type) a b.
Monad m =>
NaviT e m a -> (a -> NaviT e m b) -> NaviT e m b
Monad,
forall a. HasCallStack => Int -> NaviT e m a -> NaviT e m (Async a)
forall a.
HasCallStack =>
Int
-> ((forall b. NaviT e m b -> NaviT e m b) -> NaviT e m a)
-> NaviT e m (Async a)
forall a. HasCallStack => NaviT e m a -> NaviT e m (Async a)
forall a.
HasCallStack =>
(SomeException -> Bool) -> Async a -> NaviT e m ()
forall a.
HasCallStack =>
((forall b. NaviT e m b -> NaviT e m b) -> NaviT e m a)
-> NaviT e m (Async a)
forall a b.
HasCallStack =>
Int -> NaviT e m a -> (Async a -> NaviT e m b) -> NaviT e m b
forall a b.
HasCallStack =>
Int
-> ((forall b. NaviT e m b -> NaviT e m b) -> NaviT e m a)
-> (Async a -> NaviT e m b)
-> NaviT e m b
forall a b.
HasCallStack =>
NaviT e m a -> NaviT e m b -> NaviT e m (Either a b)
forall a b.
HasCallStack =>
NaviT e m a -> NaviT e m b -> NaviT e m ()
forall a b.
HasCallStack =>
NaviT e m a -> NaviT e m b -> NaviT e m (a, b)
forall a b.
HasCallStack =>
NaviT e m a -> (Async a -> NaviT e m b) -> NaviT e m b
forall a b.
HasCallStack =>
(SomeException -> Bool) -> Async a -> Async b -> NaviT e m ()
forall a b.
HasCallStack =>
((forall b. NaviT e m b -> NaviT e m b) -> NaviT e m a)
-> (Async a -> NaviT e m b) -> NaviT e m b
forall {e} {m :: Type -> Type}. MonadAsync m => Monad (NaviT e m)
forall e (m :: Type -> Type) a.
(MonadAsync m, HasCallStack) =>
Int -> NaviT e m a -> NaviT e m (Async a)
forall e (m :: Type -> Type) a.
(MonadAsync m, HasCallStack) =>
Int
-> ((forall b. NaviT e m b -> NaviT e m b) -> NaviT e m a)
-> NaviT e m (Async a)
forall e (m :: Type -> Type) a.
(MonadAsync m, HasCallStack) =>
NaviT e m a -> NaviT e m (Async a)
forall e (m :: Type -> Type) a.
(MonadAsync m, HasCallStack) =>
(SomeException -> Bool) -> Async a -> NaviT e m ()
forall e (m :: Type -> Type) a.
(MonadAsync m, HasCallStack) =>
((forall b. NaviT e m b -> NaviT e m b) -> NaviT e m a)
-> NaviT e m (Async a)
forall e (m :: Type -> Type) a b.
(MonadAsync m, HasCallStack) =>
Int -> NaviT e m a -> (Async a -> NaviT e m b) -> NaviT e m b
forall e (m :: Type -> Type) a b.
(MonadAsync m, HasCallStack) =>
Int
-> ((forall b. NaviT e m b -> NaviT e m b) -> NaviT e m a)
-> (Async a -> NaviT e m b)
-> NaviT e m b
forall e (m :: Type -> Type) a b.
(MonadAsync m, HasCallStack) =>
NaviT e m a -> NaviT e m b -> NaviT e m (Either a b)
forall e (m :: Type -> Type) a b.
(MonadAsync m, HasCallStack) =>
NaviT e m a -> NaviT e m b -> NaviT e m ()
forall e (m :: Type -> Type) a b.
(MonadAsync m, HasCallStack) =>
NaviT e m a -> NaviT e m b -> NaviT e m (a, b)
forall e (m :: Type -> Type) a b.
(MonadAsync m, HasCallStack) =>
NaviT e m a -> (Async a -> NaviT e m b) -> NaviT e m b
forall e (m :: Type -> Type) a b.
(MonadAsync m, HasCallStack) =>
(SomeException -> Bool) -> Async a -> Async b -> NaviT e m ()
forall e (m :: Type -> Type) a b.
(MonadAsync m, HasCallStack) =>
((forall b. NaviT e m b -> NaviT e m b) -> NaviT e m a)
-> (Async a -> NaviT e m b) -> NaviT e m b
forall (m :: Type -> Type).
Monad m
-> (forall a. HasCallStack => m a -> m (Async a))
-> (forall a. HasCallStack => m a -> m (Async a))
-> (forall a. HasCallStack => Int -> m a -> m (Async a))
-> (forall a.
HasCallStack =>
((forall b. m b -> m b) -> m a) -> m (Async a))
-> (forall a.
HasCallStack =>
Int -> ((forall b. m b -> m b) -> m a) -> m (Async a))
-> (forall a b. HasCallStack => m a -> (Async a -> m b) -> m b)
-> (forall a b. HasCallStack => m a -> (Async a -> m b) -> m b)
-> (forall a b.
HasCallStack =>
Int -> m a -> (Async a -> m b) -> m b)
-> (forall a b.
HasCallStack =>
((forall b. m b -> m b) -> m a) -> (Async a -> m b) -> m b)
-> (forall a b.
HasCallStack =>
Int -> ((forall b. m b -> m b) -> m a) -> (Async a -> m b) -> m b)
-> (forall a.
HasCallStack =>
(SomeException -> Bool) -> Async a -> m ())
-> (forall a b.
HasCallStack =>
(SomeException -> Bool) -> Async a -> Async b -> m ())
-> (forall a b. HasCallStack => m a -> m b -> m (Either a b))
-> (forall a b. HasCallStack => m a -> m b -> m (a, b))
-> (forall a b. HasCallStack => m a -> m b -> m ())
-> MonadAsync m
concurrently_ :: forall a b.
HasCallStack =>
NaviT e m a -> NaviT e m b -> NaviT e m ()
$cconcurrently_ :: forall e (m :: Type -> Type) a b.
(MonadAsync m, HasCallStack) =>
NaviT e m a -> NaviT e m b -> NaviT e m ()
concurrently :: forall a b.
HasCallStack =>
NaviT e m a -> NaviT e m b -> NaviT e m (a, b)
$cconcurrently :: forall e (m :: Type -> Type) a b.
(MonadAsync m, HasCallStack) =>
NaviT e m a -> NaviT e m b -> NaviT e m (a, b)
race :: forall a b.
HasCallStack =>
NaviT e m a -> NaviT e m b -> NaviT e m (Either a b)
$crace :: forall e (m :: Type -> Type) a b.
(MonadAsync m, HasCallStack) =>
NaviT e m a -> NaviT e m b -> NaviT e m (Either a b)
link2Only :: forall a b.
HasCallStack =>
(SomeException -> Bool) -> Async a -> Async b -> NaviT e m ()
$clink2Only :: forall e (m :: Type -> Type) a b.
(MonadAsync m, HasCallStack) =>
(SomeException -> Bool) -> Async a -> Async b -> NaviT e m ()
linkOnly :: forall a.
HasCallStack =>
(SomeException -> Bool) -> Async a -> NaviT e m ()
$clinkOnly :: forall e (m :: Type -> Type) a.
(MonadAsync m, HasCallStack) =>
(SomeException -> Bool) -> Async a -> NaviT e m ()
withAsyncOnWithUnmask :: forall a b.
HasCallStack =>
Int
-> ((forall b. NaviT e m b -> NaviT e m b) -> NaviT e m a)
-> (Async a -> NaviT e m b)
-> NaviT e m b
$cwithAsyncOnWithUnmask :: forall e (m :: Type -> Type) a b.
(MonadAsync m, HasCallStack) =>
Int
-> ((forall b. NaviT e m b -> NaviT e m b) -> NaviT e m a)
-> (Async a -> NaviT e m b)
-> NaviT e m b
withAsyncWithUnmask :: forall a b.
HasCallStack =>
((forall b. NaviT e m b -> NaviT e m b) -> NaviT e m a)
-> (Async a -> NaviT e m b) -> NaviT e m b
$cwithAsyncWithUnmask :: forall e (m :: Type -> Type) a b.
(MonadAsync m, HasCallStack) =>
((forall b. NaviT e m b -> NaviT e m b) -> NaviT e m a)
-> (Async a -> NaviT e m b) -> NaviT e m b
withAsyncOn :: forall a b.
HasCallStack =>
Int -> NaviT e m a -> (Async a -> NaviT e m b) -> NaviT e m b
$cwithAsyncOn :: forall e (m :: Type -> Type) a b.
(MonadAsync m, HasCallStack) =>
Int -> NaviT e m a -> (Async a -> NaviT e m b) -> NaviT e m b
withAsyncBound :: forall a b.
HasCallStack =>
NaviT e m a -> (Async a -> NaviT e m b) -> NaviT e m b
$cwithAsyncBound :: forall e (m :: Type -> Type) a b.
(MonadAsync m, HasCallStack) =>
NaviT e m a -> (Async a -> NaviT e m b) -> NaviT e m b
withAsync :: forall a b.
HasCallStack =>
NaviT e m a -> (Async a -> NaviT e m b) -> NaviT e m b
$cwithAsync :: forall e (m :: Type -> Type) a b.
(MonadAsync m, HasCallStack) =>
NaviT e m a -> (Async a -> NaviT e m b) -> NaviT e m b
asyncOnWithUnmask :: forall a.
HasCallStack =>
Int
-> ((forall b. NaviT e m b -> NaviT e m b) -> NaviT e m a)
-> NaviT e m (Async a)
$casyncOnWithUnmask :: forall e (m :: Type -> Type) a.
(MonadAsync m, HasCallStack) =>
Int
-> ((forall b. NaviT e m b -> NaviT e m b) -> NaviT e m a)
-> NaviT e m (Async a)
asyncWithUnmask :: forall a.
HasCallStack =>
((forall b. NaviT e m b -> NaviT e m b) -> NaviT e m a)
-> NaviT e m (Async a)
$casyncWithUnmask :: forall e (m :: Type -> Type) a.
(MonadAsync m, HasCallStack) =>
((forall b. NaviT e m b -> NaviT e m b) -> NaviT e m a)
-> NaviT e m (Async a)
asyncOn :: forall a. HasCallStack => Int -> NaviT e m a -> NaviT e m (Async a)
$casyncOn :: forall e (m :: Type -> Type) a.
(MonadAsync m, HasCallStack) =>
Int -> NaviT e m a -> NaviT e m (Async a)
asyncBound :: forall a. HasCallStack => NaviT e m a -> NaviT e m (Async a)
$casyncBound :: forall e (m :: Type -> Type) a.
(MonadAsync m, HasCallStack) =>
NaviT e m a -> NaviT e m (Async a)
async :: forall a. HasCallStack => NaviT e m a -> NaviT e m (Async a)
$casync :: forall e (m :: Type -> Type) a.
(MonadAsync m, HasCallStack) =>
NaviT e m a -> NaviT e m (Async a)
MonadAsync,
forall e a.
Exception e =>
NaviT e m a -> (e -> NaviT e m a) -> NaviT e m a
forall {e} {m :: Type -> Type}.
MonadCatch m =>
MonadThrow (NaviT e m)
forall e (m :: Type -> Type) e a.
(MonadCatch m, Exception e) =>
NaviT e m a -> (e -> NaviT e m a) -> NaviT e m a
forall (m :: Type -> Type).
MonadThrow m
-> (forall e a. Exception e => m a -> (e -> m a) -> m a)
-> MonadCatch m
catch :: forall e a.
Exception e =>
NaviT e m a -> (e -> NaviT e m a) -> NaviT e m a
$ccatch :: forall e (m :: Type -> Type) e a.
(MonadCatch m, Exception e) =>
NaviT e m a -> (e -> NaviT e m a) -> NaviT e m a
MonadCatch,
HasCallStack => Path -> NaviT e m ByteString
forall {e} {m :: Type -> Type}.
MonadFileReader m =>
Monad (NaviT e m)
forall e (m :: Type -> Type).
(MonadFileReader m, HasCallStack) =>
Path -> NaviT e m ByteString
forall (m :: Type -> Type).
Monad m
-> (HasCallStack => Path -> m ByteString) -> MonadFileReader m
readBinaryFile :: HasCallStack => Path -> NaviT e m ByteString
$creadBinaryFile :: forall e (m :: Type -> Type).
(MonadFileReader m, HasCallStack) =>
Path -> NaviT e m ByteString
MonadFileReader,
HasCallStack => Path -> IOMode -> NaviT e m Handle
HasCallStack => Handle -> NaviT e m Integer
HasCallStack => Handle -> NaviT e m ()
HasCallStack => Handle -> Bool -> NaviT e m ()
HasCallStack => Handle -> Integer -> NaviT e m ()
HasCallStack => Handle -> ByteString -> NaviT e m ()
HasCallStack => Handle -> ByteString -> NaviT e m ByteString
HasCallStack => Handle -> BufferMode -> NaviT e m ()
HasCallStack => Handle -> SeekMode -> Integer -> NaviT e m ()
forall a.
HasCallStack =>
Path -> IOMode -> (Handle -> NaviT e m a) -> NaviT e m a
forall {e} {m :: Type -> Type}.
MonadHandleWriter m =>
Monad (NaviT e m)
forall e (m :: Type -> Type).
(MonadHandleWriter m, HasCallStack) =>
Path -> IOMode -> NaviT e m Handle
forall e (m :: Type -> Type).
(MonadHandleWriter m, HasCallStack) =>
Handle -> NaviT e m Integer
forall e (m :: Type -> Type).
(MonadHandleWriter m, HasCallStack) =>
Handle -> NaviT e m ()
forall e (m :: Type -> Type).
(MonadHandleWriter m, HasCallStack) =>
Handle -> Bool -> NaviT e m ()
forall e (m :: Type -> Type).
(MonadHandleWriter m, HasCallStack) =>
Handle -> Integer -> NaviT e m ()
forall e (m :: Type -> Type).
(MonadHandleWriter m, HasCallStack) =>
Handle -> ByteString -> NaviT e m ()
forall e (m :: Type -> Type).
(MonadHandleWriter m, HasCallStack) =>
Handle -> ByteString -> NaviT e m ByteString
forall e (m :: Type -> Type).
(MonadHandleWriter m, HasCallStack) =>
Handle -> BufferMode -> NaviT e m ()
forall e (m :: Type -> Type).
(MonadHandleWriter m, HasCallStack) =>
Handle -> SeekMode -> Integer -> NaviT e m ()
forall e (m :: Type -> Type) a.
(MonadHandleWriter m, HasCallStack) =>
Path -> IOMode -> (Handle -> NaviT e m a) -> NaviT e m a
forall (m :: Type -> Type).
Monad m
-> (HasCallStack => Path -> IOMode -> m Handle)
-> (forall a.
HasCallStack =>
Path -> IOMode -> (Handle -> m a) -> m a)
-> (HasCallStack => Handle -> m ())
-> (HasCallStack => Handle -> m ())
-> (HasCallStack => Handle -> Integer -> m ())
-> (HasCallStack => Handle -> BufferMode -> m ())
-> (HasCallStack => Handle -> SeekMode -> Integer -> m ())
-> (HasCallStack => Handle -> m Integer)
-> (HasCallStack => Handle -> Bool -> m ())
-> (HasCallStack => Handle -> ByteString -> m ())
-> (HasCallStack => Handle -> ByteString -> m ByteString)
-> MonadHandleWriter m
hPutNonBlocking :: HasCallStack => Handle -> ByteString -> NaviT e m ByteString
$chPutNonBlocking :: forall e (m :: Type -> Type).
(MonadHandleWriter m, HasCallStack) =>
Handle -> ByteString -> NaviT e m ByteString
hPut :: HasCallStack => Handle -> ByteString -> NaviT e m ()
$chPut :: forall e (m :: Type -> Type).
(MonadHandleWriter m, HasCallStack) =>
Handle -> ByteString -> NaviT e m ()
hSetEcho :: HasCallStack => Handle -> Bool -> NaviT e m ()
$chSetEcho :: forall e (m :: Type -> Type).
(MonadHandleWriter m, HasCallStack) =>
Handle -> Bool -> NaviT e m ()
hTell :: HasCallStack => Handle -> NaviT e m Integer
$chTell :: forall e (m :: Type -> Type).
(MonadHandleWriter m, HasCallStack) =>
Handle -> NaviT e m Integer
hSeek :: HasCallStack => Handle -> SeekMode -> Integer -> NaviT e m ()
$chSeek :: forall e (m :: Type -> Type).
(MonadHandleWriter m, HasCallStack) =>
Handle -> SeekMode -> Integer -> NaviT e m ()
hSetBuffering :: HasCallStack => Handle -> BufferMode -> NaviT e m ()
$chSetBuffering :: forall e (m :: Type -> Type).
(MonadHandleWriter m, HasCallStack) =>
Handle -> BufferMode -> NaviT e m ()
hSetFileSize :: HasCallStack => Handle -> Integer -> NaviT e m ()
$chSetFileSize :: forall e (m :: Type -> Type).
(MonadHandleWriter m, HasCallStack) =>
Handle -> Integer -> NaviT e m ()
hFlush :: HasCallStack => Handle -> NaviT e m ()
$chFlush :: forall e (m :: Type -> Type).
(MonadHandleWriter m, HasCallStack) =>
Handle -> NaviT e m ()
hClose :: HasCallStack => Handle -> NaviT e m ()
$chClose :: forall e (m :: Type -> Type).
(MonadHandleWriter m, HasCallStack) =>
Handle -> NaviT e m ()
withBinaryFile :: forall a.
HasCallStack =>
Path -> IOMode -> (Handle -> NaviT e m a) -> NaviT e m a
$cwithBinaryFile :: forall e (m :: Type -> Type) a.
(MonadHandleWriter m, HasCallStack) =>
Path -> IOMode -> (Handle -> NaviT e m a) -> NaviT e m a
openBinaryFile :: HasCallStack => Path -> IOMode -> NaviT e m Handle
$copenBinaryFile :: forall e (m :: Type -> Type).
(MonadHandleWriter m, HasCallStack) =>
Path -> IOMode -> NaviT e m Handle
MonadHandleWriter,
forall a. IO a -> NaviT e m a
forall {e} {m :: Type -> Type}. MonadIO m => Monad (NaviT e m)
forall e (m :: Type -> Type) a. MonadIO m => IO a -> NaviT e m a
forall (m :: Type -> Type).
Monad m -> (forall a. IO a -> m a) -> MonadIO m
liftIO :: forall a. IO a -> NaviT e m a
$cliftIO :: forall e (m :: Type -> Type) a. MonadIO m => IO a -> NaviT e m a
MonadIO,
forall a. HasCallStack => a -> NaviT e m (IORef a)
forall a. HasCallStack => IORef a -> NaviT e m a
forall a. HasCallStack => IORef a -> a -> NaviT e m ()
forall a. HasCallStack => IORef a -> (a -> a) -> NaviT e m ()
forall a b. HasCallStack => IORef a -> (a -> (a, b)) -> NaviT e m b
forall {e} {m :: Type -> Type}. MonadIORef m => Monad (NaviT e m)
forall e (m :: Type -> Type) a.
(MonadIORef m, HasCallStack) =>
a -> NaviT e m (IORef a)
forall e (m :: Type -> Type) a.
(MonadIORef m, HasCallStack) =>
IORef a -> NaviT e m a
forall e (m :: Type -> Type) a.
(MonadIORef m, HasCallStack) =>
IORef a -> a -> NaviT e m ()
forall e (m :: Type -> Type) a.
(MonadIORef m, HasCallStack) =>
IORef a -> (a -> a) -> NaviT e m ()
forall e (m :: Type -> Type) a b.
(MonadIORef m, HasCallStack) =>
IORef a -> (a -> (a, b)) -> NaviT e m b
forall (m :: Type -> Type).
Monad m
-> (forall a. HasCallStack => a -> m (IORef a))
-> (forall a. HasCallStack => IORef a -> m a)
-> (forall a. HasCallStack => IORef a -> a -> m ())
-> (forall a. HasCallStack => IORef a -> a -> m ())
-> (forall a. HasCallStack => IORef a -> (a -> a) -> m ())
-> (forall a b. HasCallStack => IORef a -> (a -> (a, b)) -> m b)
-> MonadIORef m
atomicModifyIORef' :: forall a b. HasCallStack => IORef a -> (a -> (a, b)) -> NaviT e m b
$catomicModifyIORef' :: forall e (m :: Type -> Type) a b.
(MonadIORef m, HasCallStack) =>
IORef a -> (a -> (a, b)) -> NaviT e m b
modifyIORef' :: forall a. HasCallStack => IORef a -> (a -> a) -> NaviT e m ()
$cmodifyIORef' :: forall e (m :: Type -> Type) a.
(MonadIORef m, HasCallStack) =>
IORef a -> (a -> a) -> NaviT e m ()
atomicWriteIORef :: forall a. HasCallStack => IORef a -> a -> NaviT e m ()
$catomicWriteIORef :: forall e (m :: Type -> Type) a.
(MonadIORef m, HasCallStack) =>
IORef a -> a -> NaviT e m ()
writeIORef :: forall a. HasCallStack => IORef a -> a -> NaviT e m ()
$cwriteIORef :: forall e (m :: Type -> Type) a.
(MonadIORef m, HasCallStack) =>
IORef a -> a -> NaviT e m ()
readIORef :: forall a. HasCallStack => IORef a -> NaviT e m a
$creadIORef :: forall e (m :: Type -> Type) a.
(MonadIORef m, HasCallStack) =>
IORef a -> NaviT e m a
newIORef :: forall a. HasCallStack => a -> NaviT e m (IORef a)
$cnewIORef :: forall e (m :: Type -> Type) a.
(MonadIORef m, HasCallStack) =>
a -> NaviT e m (IORef a)
MonadIORef,
forall b.
((forall a. NaviT e m a -> NaviT e m a) -> NaviT e m b)
-> NaviT e m b
forall a b c.
NaviT e m a
-> (a -> ExitCase b -> NaviT e m c)
-> (a -> NaviT e m b)
-> NaviT e m (b, c)
forall {e} {m :: Type -> Type}.
MonadMask m =>
MonadCatch (NaviT e m)
forall e (m :: Type -> Type) b.
MonadMask m =>
((forall a. NaviT e m a -> NaviT e m a) -> NaviT e m b)
-> NaviT e m b
forall e (m :: Type -> Type) a b c.
MonadMask m =>
NaviT e m a
-> (a -> ExitCase b -> NaviT e m c)
-> (a -> NaviT e m b)
-> NaviT e m (b, c)
forall (m :: Type -> Type).
MonadCatch m
-> (forall b. ((forall a. m a -> m a) -> m b) -> m b)
-> (forall b. ((forall a. m a -> m a) -> m b) -> m b)
-> (forall a b c.
m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c))
-> MonadMask m
generalBracket :: forall a b c.
NaviT e m a
-> (a -> ExitCase b -> NaviT e m c)
-> (a -> NaviT e m b)
-> NaviT e m (b, c)
$cgeneralBracket :: forall e (m :: Type -> Type) a b c.
MonadMask m =>
NaviT e m a
-> (a -> ExitCase b -> NaviT e m c)
-> (a -> NaviT e m b)
-> NaviT e m (b, c)
uninterruptibleMask :: forall b.
((forall a. NaviT e m a -> NaviT e m a) -> NaviT e m b)
-> NaviT e m b
$cuninterruptibleMask :: forall e (m :: Type -> Type) b.
MonadMask m =>
((forall a. NaviT e m a -> NaviT e m a) -> NaviT e m b)
-> NaviT e m b
mask :: forall b.
((forall a. NaviT e m a -> NaviT e m a) -> NaviT e m b)
-> NaviT e m b
$cmask :: forall e (m :: Type -> Type) b.
MonadMask m =>
((forall a. NaviT e m a -> NaviT e m a) -> NaviT e m b)
-> NaviT e m b
MonadMask,
MonadReader e,
forall a. HasCallStack => STM a -> NaviT e m a
forall {e} {m :: Type -> Type}. MonadSTM m => Monad (NaviT e m)
forall e (m :: Type -> Type) a.
(MonadSTM m, HasCallStack) =>
STM a -> NaviT e m a
forall (m :: Type -> Type).
Monad m -> (forall a. HasCallStack => STM a -> m a) -> MonadSTM m
atomically :: forall a. HasCallStack => STM a -> NaviT e m a
$catomically :: forall e (m :: Type -> Type) a.
(MonadSTM m, HasCallStack) =>
STM a -> NaviT e m a
MonadSTM,
HasCallStack => NaviT e m Int
HasCallStack => Int -> NaviT e m ()
HasCallStack => ThreadId -> NaviT e m (Int, Bool)
forall e.
(Exception e, HasCallStack) =>
ThreadId -> e -> NaviT e m ()
forall {e} {m :: Type -> Type}. MonadThread m => Monad (NaviT e m)
forall e (m :: Type -> Type).
(MonadThread m, HasCallStack) =>
NaviT e m Int
forall e (m :: Type -> Type).
(MonadThread m, HasCallStack) =>
Int -> NaviT e m ()
forall e (m :: Type -> Type).
(MonadThread m, HasCallStack) =>
ThreadId -> NaviT e m (Int, Bool)
forall e (m :: Type -> Type) e.
(MonadThread m, Exception e, HasCallStack) =>
ThreadId -> e -> NaviT e m ()
forall (m :: Type -> Type).
Monad m
-> (HasCallStack => Int -> m ())
-> (forall e. (Exception e, HasCallStack) => ThreadId -> e -> m ())
-> (HasCallStack => m Int)
-> (HasCallStack => Int -> m ())
-> (HasCallStack => ThreadId -> m (Int, Bool))
-> MonadThread m
threadCapability :: HasCallStack => ThreadId -> NaviT e m (Int, Bool)
$cthreadCapability :: forall e (m :: Type -> Type).
(MonadThread m, HasCallStack) =>
ThreadId -> NaviT e m (Int, Bool)
setNumCapabilities :: HasCallStack => Int -> NaviT e m ()
$csetNumCapabilities :: forall e (m :: Type -> Type).
(MonadThread m, HasCallStack) =>
Int -> NaviT e m ()
getNumCapabilities :: HasCallStack => NaviT e m Int
$cgetNumCapabilities :: forall e (m :: Type -> Type).
(MonadThread m, HasCallStack) =>
NaviT e m Int
throwTo :: forall e.
(Exception e, HasCallStack) =>
ThreadId -> e -> NaviT e m ()
$cthrowTo :: forall e (m :: Type -> Type) e.
(MonadThread m, Exception e, HasCallStack) =>
ThreadId -> e -> NaviT e m ()
threadDelay :: HasCallStack => Int -> NaviT e m ()
$cthreadDelay :: forall e (m :: Type -> Type).
(MonadThread m, HasCallStack) =>
Int -> NaviT e m ()
MonadThread,
forall e a. Exception e => e -> NaviT e m a
forall {e} {m :: Type -> Type}. MonadThrow m => Monad (NaviT e m)
forall e (m :: Type -> Type) e a.
(MonadThrow m, Exception e) =>
e -> NaviT e m a
forall (m :: Type -> Type).
Monad m -> (forall e a. Exception e => e -> m a) -> MonadThrow m
throwM :: forall e a. Exception e => e -> NaviT e m a
$cthrowM :: forall e (m :: Type -> Type) e a.
(MonadThrow m, Exception e) =>
e -> NaviT e m a
MonadThrow
)
via (ReaderT e m)
deriving (forall e (m :: Type -> Type) a. Monad m => m a -> NaviT e m a
forall (m :: Type -> Type) a. Monad m => m a -> NaviT e m a
forall (t :: (Type -> Type) -> Type -> Type).
(forall (m :: Type -> Type) a. Monad m => m a -> t m a)
-> MonadTrans t
lift :: forall (m :: Type -> Type) a. Monad m => m a -> NaviT e m a
$clift :: forall e (m :: Type -> Type) a. Monad m => m a -> NaviT e m a
MonadTrans) via (ReaderT e)
instance MonadTerminal (NaviT env IO) where
getChar :: HasCallStack => NaviT env IO Char
getChar = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall (m :: Type -> Type).
(MonadTerminal m, HasCallStack) =>
m Char
getChar
getLine :: HasCallStack => NaviT env IO Path
getLine = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall (m :: Type -> Type).
(MonadTerminal m, HasCallStack) =>
m Path
getLine
getContents' :: HasCallStack => NaviT env IO Path
getContents' = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall (m :: Type -> Type).
(MonadTerminal m, HasCallStack) =>
m Path
getContents'
getTerminalSize :: HasCallStack => NaviT env IO (Window Natural)
getTerminalSize = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall (m :: Type -> Type).
(MonadTerminal m, HasCallStack) =>
m (Window Natural)
getTerminalSize
putBinary :: HasCallStack => ByteString -> NaviT env IO ()
putBinary = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: Type -> Type).
(MonadTerminal m, HasCallStack) =>
ByteString -> m ()
putBinary
putStr :: HasCallStack => Path -> NaviT env IO ()
putStr = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: Type -> Type).
(MonadTerminal m, HasCallStack) =>
Path -> m ()
putStr
putStrLn :: HasCallStack => Path -> NaviT env IO ()
putStrLn = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: Type -> Type).
(MonadTerminal m, HasCallStack) =>
Path -> m ()
putStrLn
instance MonadTime (NaviT env IO) where
getSystemZonedTime :: HasCallStack => NaviT env IO ZonedTime
getSystemZonedTime = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall (m :: Type -> Type).
(MonadTime m, HasCallStack) =>
m ZonedTime
getSystemZonedTime
getMonotonicTime :: HasCallStack => NaviT env IO Double
getMonotonicTime = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall (m :: Type -> Type). (MonadTime m, HasCallStack) => m Double
getMonotonicTime
instance MonadSystemInfo (NaviT env IO) where
query :: forall result.
HasCallStack =>
ServiceType result -> NaviT env IO result
query = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: Type -> Type) result.
(MonadSystemInfo m, HasCallStack) =>
ServiceType result -> m result
query
{-# INLINEABLE query #-}
instance MonadNotify (NaviT DBusEnv IO) where
sendNote :: HasCallStack => NaviNote -> NaviT DBusEnv IO ()
sendNote NaviNote
naviNote = forall (m :: Type -> Type) a.
MonadLoggerNamespace m =>
Text -> m a -> m a
addNamespace Text
"dbus" forall a b. (a -> b) -> a -> b
$ do
$(logDebug) (forall a. Show a => a -> Text
showt Note
note)
Client
client <- forall r (m :: Type -> Type) a. MonadReader r m => (r -> a) -> m a
asks forall env. HasDBusClient env => env -> Client
getClient
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ forall (m :: Type -> Type) a.
(HasCallStack, MonadCatch m) =>
m a -> m a
addCS forall a b. (a -> b) -> a -> b
$ Client -> Note -> IO ()
sendDbus Client
client Note
note
where
note :: Note
note = NaviNote -> Note
naviToDBus NaviNote
naviNote
sendDbus :: Client -> Note -> IO ()
sendDbus Client
c = forall (f :: Type -> Type) a. Functor f => f a -> f ()
void forall b c a. (b -> c) -> (a -> b) -> a -> c
. Client -> Note -> IO Notification
DBusN.notify Client
c
{-# INLINEABLE sendNote #-}
instance MonadNotify (NaviT NotifySendEnv IO) where
sendNote :: HasCallStack => NaviNote -> NaviT NotifySendEnv IO ()
sendNote NaviNote
naviNote = forall (m :: Type -> Type) a.
MonadLoggerNamespace m =>
Text -> m a -> m a
addNamespace Text
"notify-send" forall a b. (a -> b) -> a -> b
$ do
$(logDebug) Text
noteTxt
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ forall (m :: Type -> Type) a.
(HasCallStack, MonadCatch m) =>
m a -> m a
addCS forall a b. (a -> b) -> a -> b
$ forall (f :: Type -> Type) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ CreateProcess -> Path -> IO Path
Proc.readCreateProcess CreateProcess
cp Path
"notify-send"
where
noteTxt :: Text
noteTxt = NaviNote -> Text
naviToNotifySend NaviNote
naviNote
cp :: CreateProcess
cp = Path -> CreateProcess
Proc.shell forall a b. (a -> b) -> a -> b
$ Text -> Path
unpack Text
noteTxt
{-# INLINEABLE sendNote #-}
instance
( HasLogEnv env,
HasLogQueue env
) =>
MonadLogger (NaviT env IO)
where
monadLoggerLog :: forall msg.
ToLogStr msg =>
Loc -> Text -> LogLevel -> msg -> NaviT env IO ()
monadLoggerLog Loc
loc Text
_src LogLevel
lvl msg
msg = do
TBQueue LogStr
logQueue <- forall r (m :: Type -> Type) a. MonadReader r m => (r -> a) -> m a
asks forall env. HasLogQueue env => env -> TBQueue LogStr
getLogQueue
LogLevel
logLevel <- forall r (m :: Type -> Type) a. MonadReader r m => (r -> a) -> m a
asks (forall k (is :: IxList) s a.
Is k A_Getter =>
Optic' k is s a -> s -> a
view forall a. IsLabel "logLevel" a => a
#logLevel forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall env. HasLogEnv env => env -> LogEnv
getLogEnv)
forall (f :: Type -> Type). Applicative f => Bool -> f () -> f ()
when (LogLevel
logLevel forall a. Ord a => a -> a -> Bool
<= LogLevel
lvl) forall a b. (a -> b) -> a -> b
$ do
LogStr
formatted <- forall (m :: Type -> Type) msg.
(HasCallStack, MonadLoggerNamespace m, MonadTime m,
ToLogStr msg) =>
LogFormatter -> LogLevel -> msg -> m LogStr
formatLog (Loc -> LogFormatter
defaultLogFormatter Loc
loc) LogLevel
lvl msg
msg
forall (m :: Type -> Type) a.
(HasCallStack, MonadSTM m) =>
TBQueue a -> a -> m ()
writeTBQueueM TBQueue LogStr
logQueue LogStr
formatted
instance
( HasLogEnv env,
HasLogQueue env
) =>
MonadLoggerNamespace (NaviT env IO)
where
getNamespace :: HasCallStack => NaviT env IO Namespace
getNamespace = forall r (m :: Type -> Type) a. MonadReader r m => (r -> a) -> m a
asks (forall k (is :: IxList) s a.
Is k A_Getter =>
Optic' k is s a -> s -> a
view forall a. IsLabel "logNamespace" a => a
#logNamespace forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall env. HasLogEnv env => env -> LogEnv
getLogEnv)
localNamespace :: forall a.
HasCallStack =>
(Namespace -> Namespace) -> NaviT env IO a -> NaviT env IO a
localNamespace Namespace -> Namespace
f = forall r (m :: Type -> Type) a.
MonadReader r m =>
(r -> r) -> m a -> m a
local (forall env. HasLogEnv env => (LogEnv -> LogEnv) -> env -> env
localLogEnv (forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> (a -> b) -> s -> t
over' forall a. IsLabel "logNamespace" a => a
#logNamespace Namespace -> Namespace
f))
runNaviT :: NaviT env m a -> env -> m a
runNaviT :: forall env (m :: Type -> Type) a. NaviT env m a -> env -> m a
runNaviT (MkNaviT ReaderT env m a
rdr) = forall r (m :: Type -> Type) a. ReaderT r m a -> r -> m a
runReaderT ReaderT env m a
rdr
{-# INLINEABLE runNaviT #-}