{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE UndecidableInstances #-}
module Navi.Env.Core
(
HasEvents (..),
HasLogEnv (..),
HasLogQueue (..),
HasNoteQueue (..),
Env (..),
)
where
import Navi.Data.NaviLog (LogEnv)
import Navi.Data.NaviNote (NaviNote)
import Navi.Event.Types (AnyEvent)
import Navi.Prelude
class HasEvents env where
getEvents :: env -> NonEmpty AnyEvent
class HasLogEnv env where
getLogEnv :: env -> LogEnv
localLogEnv :: (LogEnv -> LogEnv) -> env -> env
class HasLogQueue env where
getLogQueue :: env -> TBQueue LogStr
class HasNoteQueue env where
getNoteQueue :: env -> TBQueue NaviNote
data Env = MkEnv
{ Env -> NonEmpty AnyEvent
events :: !(NonEmpty AnyEvent),
Env -> LogEnv
logEnv :: !LogEnv,
Env -> TBQueue LogStr
logQueue :: !(TBQueue LogStr),
Env -> TBQueue NaviNote
noteQueue :: !(TBQueue NaviNote)
}
makeFieldLabelsNoPrefix ''Env
instance HasEvents Env where
getEvents :: Env -> NonEmpty AnyEvent
getEvents = forall (k :: OpticKind) (is :: IxList) (s :: OpticKind)
(a :: OpticKind).
Is k A_Getter =>
Optic' k is s a -> s -> a
view forall (a :: OpticKind). IsLabel "events" a => a
#events
{-# INLINEABLE getEvents #-}
instance HasLogEnv Env where
getLogEnv :: Env -> LogEnv
getLogEnv = forall (k :: OpticKind) (is :: IxList) (s :: OpticKind)
(a :: OpticKind).
Is k A_Getter =>
Optic' k is s a -> s -> a
view forall (a :: OpticKind). IsLabel "logEnv" a => a
#logEnv
{-# INLINEABLE getLogEnv #-}
localLogEnv :: (LogEnv -> LogEnv) -> Env -> Env
localLogEnv = forall (k :: OpticKind) (is :: IxList) (s :: OpticKind)
(t :: OpticKind) (a :: OpticKind) (b :: OpticKind).
Is k A_Setter =>
Optic k is s t a b -> (a -> b) -> s -> t
over' forall (a :: OpticKind). IsLabel "logEnv" a => a
#logEnv
{-# INLINEABLE localLogEnv #-}
instance HasLogQueue Env where
getLogQueue :: Env -> TBQueue LogStr
getLogQueue = forall (k :: OpticKind) (is :: IxList) (s :: OpticKind)
(a :: OpticKind).
Is k A_Getter =>
Optic' k is s a -> s -> a
view forall (a :: OpticKind). IsLabel "logQueue" a => a
#logQueue
{-# INLINEABLE getLogQueue #-}
instance HasNoteQueue Env where
getNoteQueue :: Env -> TBQueue NaviNote
getNoteQueue = forall (k :: OpticKind) (is :: IxList) (s :: OpticKind)
(a :: OpticKind).
Is k A_Getter =>
Optic' k is s a -> s -> a
view forall (a :: OpticKind). IsLabel "noteQueue" a => a
#noteQueue
{-# INLINEABLE getNoteQueue #-}