{-# LANGUAGE CPP #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
module Brick.Types.EventM
( EventM(..)
, getVtyContext
)
where
import Control.Monad.Catch (MonadThrow, MonadCatch, MonadMask)
#if !MIN_VERSION_base(4,13,0)
import Control.Monad.Fail (MonadFail)
#endif
import Control.Monad.Reader
import Control.Monad.State.Strict
import Lens.Micro.Mtl
import Lens.Micro.Mtl.Internal
import Brick.Types.Internal
newtype EventM n s a =
EventM { forall n s a.
EventM n s a
-> ReaderT (EventRO n) (StateT s (StateT (EventState n) IO)) a
runEventM :: ReaderT (EventRO n) (StateT s (StateT (EventState n) IO)) a
}
deriving ( forall a b. a -> EventM n s b -> EventM n s a
forall a b. (a -> b) -> EventM n s a -> EventM n s b
forall n s a b. a -> EventM n s b -> EventM n s a
forall n s a b. (a -> b) -> EventM n s a -> EventM n s b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> EventM n s b -> EventM n s a
$c<$ :: forall n s a b. a -> EventM n s b -> EventM n s a
fmap :: forall a b. (a -> b) -> EventM n s a -> EventM n s b
$cfmap :: forall n s a b. (a -> b) -> EventM n s a -> EventM n s b
Functor, forall a. a -> EventM n s a
forall n s. Functor (EventM n s)
forall a b. EventM n s a -> EventM n s b -> EventM n s a
forall a b. EventM n s a -> EventM n s b -> EventM n s b
forall a b. EventM n s (a -> b) -> EventM n s a -> EventM n s b
forall n s a. a -> EventM n s a
forall a b c.
(a -> b -> c) -> EventM n s a -> EventM n s b -> EventM n s c
forall n s a b. EventM n s a -> EventM n s b -> EventM n s a
forall n s a b. EventM n s a -> EventM n s b -> EventM n s b
forall n s a b. EventM n s (a -> b) -> EventM n s a -> EventM n s b
forall n s a b c.
(a -> b -> c) -> EventM n s a -> EventM n s b -> EventM n s c
forall (f :: * -> *).
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. EventM n s a -> EventM n s b -> EventM n s a
$c<* :: forall n s a b. EventM n s a -> EventM n s b -> EventM n s a
*> :: forall a b. EventM n s a -> EventM n s b -> EventM n s b
$c*> :: forall n s a b. EventM n s a -> EventM n s b -> EventM n s b
liftA2 :: forall a b c.
(a -> b -> c) -> EventM n s a -> EventM n s b -> EventM n s c
$cliftA2 :: forall n s a b c.
(a -> b -> c) -> EventM n s a -> EventM n s b -> EventM n s c
<*> :: forall a b. EventM n s (a -> b) -> EventM n s a -> EventM n s b
$c<*> :: forall n s a b. EventM n s (a -> b) -> EventM n s a -> EventM n s b
pure :: forall a. a -> EventM n s a
$cpure :: forall n s a. a -> EventM n s a
Applicative, forall a. a -> EventM n s a
forall n s. Applicative (EventM n s)
forall a b. EventM n s a -> EventM n s b -> EventM n s b
forall a b. EventM n s a -> (a -> EventM n s b) -> EventM n s b
forall n s a. a -> EventM n s a
forall n s a b. EventM n s a -> EventM n s b -> EventM n s b
forall n s a b. EventM n s a -> (a -> EventM n s b) -> EventM n s b
forall (m :: * -> *).
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 -> EventM n s a
$creturn :: forall n s a. a -> EventM n s a
>> :: forall a b. EventM n s a -> EventM n s b -> EventM n s b
$c>> :: forall n s a b. EventM n s a -> EventM n s b -> EventM n s b
>>= :: forall a b. EventM n s a -> (a -> EventM n s b) -> EventM n s b
$c>>= :: forall n s a b. EventM n s a -> (a -> EventM n s b) -> EventM n s b
Monad, forall a. IO a -> EventM n s a
forall n s. Monad (EventM n s)
forall n s a. IO a -> EventM n s a
forall (m :: * -> *).
Monad m -> (forall a. IO a -> m a) -> MonadIO m
liftIO :: forall a. IO a -> EventM n s a
$cliftIO :: forall n s a. IO a -> EventM n s a
MonadIO
, forall n s. Monad (EventM n s)
forall e a. Exception e => e -> EventM n s a
forall n s e a. Exception e => e -> EventM n s a
forall (m :: * -> *).
Monad m -> (forall e a. Exception e => e -> m a) -> MonadThrow m
throwM :: forall e a. Exception e => e -> EventM n s a
$cthrowM :: forall n s e a. Exception e => e -> EventM n s a
MonadThrow, forall n s. MonadThrow (EventM n s)
forall e a.
Exception e =>
EventM n s a -> (e -> EventM n s a) -> EventM n s a
forall n s e a.
Exception e =>
EventM n s a -> (e -> EventM n s a) -> EventM n s a
forall (m :: * -> *).
MonadThrow m
-> (forall e a. Exception e => m a -> (e -> m a) -> m a)
-> MonadCatch m
catch :: forall e a.
Exception e =>
EventM n s a -> (e -> EventM n s a) -> EventM n s a
$ccatch :: forall n s e a.
Exception e =>
EventM n s a -> (e -> EventM n s a) -> EventM n s a
MonadCatch, forall b.
((forall a. EventM n s a -> EventM n s a) -> EventM n s b)
-> EventM n s b
forall n s. MonadCatch (EventM n s)
forall a b c.
EventM n s a
-> (a -> ExitCase b -> EventM n s c)
-> (a -> EventM n s b)
-> EventM n s (b, c)
forall n s b.
((forall a. EventM n s a -> EventM n s a) -> EventM n s b)
-> EventM n s b
forall n s a b c.
EventM n s a
-> (a -> ExitCase b -> EventM n s c)
-> (a -> EventM n s b)
-> EventM n s (b, c)
forall (m :: * -> *).
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.
EventM n s a
-> (a -> ExitCase b -> EventM n s c)
-> (a -> EventM n s b)
-> EventM n s (b, c)
$cgeneralBracket :: forall n s a b c.
EventM n s a
-> (a -> ExitCase b -> EventM n s c)
-> (a -> EventM n s b)
-> EventM n s (b, c)
uninterruptibleMask :: forall b.
((forall a. EventM n s a -> EventM n s a) -> EventM n s b)
-> EventM n s b
$cuninterruptibleMask :: forall n s b.
((forall a. EventM n s a -> EventM n s a) -> EventM n s b)
-> EventM n s b
mask :: forall b.
((forall a. EventM n s a -> EventM n s a) -> EventM n s b)
-> EventM n s b
$cmask :: forall n s b.
((forall a. EventM n s a -> EventM n s a) -> EventM n s b)
-> EventM n s b
MonadMask
#if !MIN_VERSION_base(4,13,0)
, MonadFail
#endif
)
instance MonadState s (EventM n s) where
get :: EventM n s s
get = forall n s a.
ReaderT (EventRO n) (StateT s (StateT (EventState n) IO)) a
-> EventM n s a
EventM forall a b. (a -> b) -> a -> b
$ forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall s (m :: * -> *). MonadState s m => m s
get
put :: s -> EventM n s ()
put = forall n s a.
ReaderT (EventRO n) (StateT s (StateT (EventState n) IO)) a
-> EventM n s a
EventM forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s (m :: * -> *). MonadState s m => s -> m ()
put
getVtyContext :: EventM n s VtyContext
getVtyContext :: forall n s. EventM n s VtyContext
getVtyContext = forall n s a.
ReaderT (EventRO n) (StateT s (StateT (EventState n) IO)) a
-> EventM n s a
EventM forall a b. (a -> b) -> a -> b
$ forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets forall n. EventState n -> VtyContext
vtyContext
type instance Zoomed (EventM n s) = Zoomed (StateT s (StateT (EventState n) IO))
instance Zoom (EventM n s) (EventM n t) s t where
zoom :: forall c.
LensLike' (Zoomed (EventM n s) c) t s
-> EventM n s c -> EventM n t c
zoom LensLike' (Zoomed (EventM n s) c) t s
l (EventM ReaderT (EventRO n) (StateT s (StateT (EventState n) IO)) c
m) = forall n s a.
ReaderT (EventRO n) (StateT s (StateT (EventState n) IO)) a
-> EventM n s a
EventM (forall (m :: * -> *) (n :: * -> *) s t c.
Zoom m n s t =>
LensLike' (Zoomed m c) t s -> m c -> n c
zoom LensLike' (Zoomed (EventM n s) c) t s
l ReaderT (EventRO n) (StateT s (StateT (EventState n) IO)) c
m)