| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Control.Eff.Concurrent.SingleThreaded
Description
Concurrent, communicating processes, executed using a single-threaded
scheduler, with support for IO and Logs.
This module re-exports most of the library.
There are several scheduler implementations to choose from.
This module re-exports the impure parts of Control.Eff.Concurrent.Process.SingleThreadedScheduler.
To use another scheduler implementation, don't import this module, but instead import one of:
Since: 0.25.0
Synopsis
- newtype Facility = Facility {
- fromFacility :: Int
- data Severity
- data SdParameter = MkSdParameter !Text !Text
- data StructuredDataElement = SdElement {
- _sdElementId :: !Text
- _sdElementParameters :: ![SdParameter]
- data LogMessage = MkLogMessage {}
- emergencySeverity :: Severity
- alertSeverity :: Severity
- criticalSeverity :: Severity
- errorSeverity :: Severity
- warningSeverity :: Severity
- noticeSeverity :: Severity
- informationalSeverity :: Severity
- debugSeverity :: Severity
- kernelMessages :: Facility
- userLevelMessages :: Facility
- mailSystem :: Facility
- systemDaemons :: Facility
- securityAuthorizationMessages4 :: Facility
- linePrinterSubsystem :: Facility
- networkNewsSubsystem :: Facility
- uucpSubsystem :: Facility
- clockDaemon :: Facility
- securityAuthorizationMessages10 :: Facility
- ftpDaemon :: Facility
- ntpSubsystem :: Facility
- logAuditFacility :: Facility
- logAlertFacility :: Facility
- clockDaemon2 :: Facility
- local0 :: Facility
- local1 :: Facility
- local2 :: Facility
- local3 :: Facility
- local4 :: Facility
- local5 :: Facility
- local6 :: Facility
- local7 :: Facility
- sdElementId :: Functor f => (Text -> f Text) -> StructuredDataElement -> f StructuredDataElement
- sdElementParameters :: Functor f => ([SdParameter] -> f [SdParameter]) -> StructuredDataElement -> f StructuredDataElement
- type LogPredicate = LogMessage -> Bool
- class ToLogMessage a where
- toLogMessage :: a -> LogMessage
- lmAppName :: Functor f => (Maybe Text -> f (Maybe Text)) -> LogMessage -> f LogMessage
- lmFacility :: Functor f => (Facility -> f Facility) -> LogMessage -> f LogMessage
- lmHostname :: Functor f => (Maybe Text -> f (Maybe Text)) -> LogMessage -> f LogMessage
- lmMessage :: Functor f => (Text -> f Text) -> LogMessage -> f LogMessage
- lmMessageId :: Functor f => (Maybe Text -> f (Maybe Text)) -> LogMessage -> f LogMessage
- lmProcessId :: Functor f => (Maybe Text -> f (Maybe Text)) -> LogMessage -> f LogMessage
- lmSeverity :: Functor f => (Severity -> f Severity) -> LogMessage -> f LogMessage
- lmSrcLoc :: Functor f => (Maybe SrcLoc -> f (Maybe SrcLoc)) -> LogMessage -> f LogMessage
- lmStructuredData :: Functor f => ([StructuredDataElement] -> f [StructuredDataElement]) -> LogMessage -> f LogMessage
- lmThreadId :: Functor f => (Maybe ThreadId -> f (Maybe ThreadId)) -> LogMessage -> f LogMessage
- lmTimestamp :: Functor f => (Maybe UTCTime -> f (Maybe UTCTime)) -> LogMessage -> f LogMessage
- setCallStack :: CallStack -> LogMessage -> LogMessage
- prefixLogMessagesWith :: Text -> LogMessage -> LogMessage
- setLogMessageTimestamp :: LogMessage -> IO LogMessage
- setLogMessageThreadId :: LogMessage -> IO LogMessage
- setLogMessageHostname :: LogMessage -> IO LogMessage
- errorMessage :: HasCallStack => Text -> LogMessage
- infoMessage :: HasCallStack => Text -> LogMessage
- debugMessage :: HasCallStack => Text -> LogMessage
- errorMessageIO :: (HasCallStack, MonadIO m) => Text -> m LogMessage
- infoMessageIO :: (HasCallStack, MonadIO m) => Text -> m LogMessage
- debugMessageIO :: (HasCallStack, MonadIO m) => Text -> m LogMessage
- allLogMessages :: LogPredicate
- noLogMessages :: LogPredicate
- lmSeverityIs :: Severity -> LogPredicate
- lmSeverityIsAtLeast :: Severity -> LogPredicate
- lmMessageStartsWith :: Text -> LogPredicate
- discriminateByAppName :: Text -> LogPredicate -> LogPredicate -> LogPredicate
- data LogMessageTimeRenderer
- type LogMessageRenderer a = LogMessage -> a
- mkLogMessageTimeRenderer :: String -> LogMessageTimeRenderer
- suppressTimestamp :: LogMessageTimeRenderer
- rfc3164Timestamp :: LogMessageTimeRenderer
- rfc5424Timestamp :: LogMessageTimeRenderer
- rfc5424NoZTimestamp :: LogMessageTimeRenderer
- renderLogMessageBody :: LogMessageRenderer Text
- renderLogMessageBodyNoLocation :: LogMessageRenderer Text
- renderLogMessageBodyFixWidth :: LogMessageRenderer Text
- renderMaybeLogMessageLens :: Text -> Getter LogMessage (Maybe Text) -> LogMessageRenderer Text
- renderLogMessageSrcLoc :: LogMessageRenderer (Maybe Text)
- renderSyslogSeverityAndFacility :: LogMessageRenderer Text
- renderLogMessageSyslog :: LogMessageRenderer Text
- renderLogMessageConsoleLog :: LogMessageRenderer Text
- renderRFC3164 :: LogMessageRenderer Text
- renderRFC3164WithRFC5424Timestamps :: LogMessageRenderer Text
- renderRFC3164WithTimestamp :: LogMessageTimeRenderer -> LogMessageRenderer Text
- renderRFC5424 :: LogMessageRenderer Text
- renderRFC5424NoLocation :: LogMessageRenderer Text
- renderRFC5424Header :: LogMessageRenderer Text
- newtype PureLogWriter a = MkPureLogWriter {
- runPureLogWriter :: Identity a
- class HandleLogWriter (writerEff :: Type -> Type) e where
- handleLogWriterEffect :: writerEff () -> Eff e ()
- liftWriteLogMessage :: SetMember LogWriterReader (LogWriterReader writerEff) e => LogMessage -> Eff e ()
- data LogWriterReader h v
- newtype LogWriter writerM = MkLogWriter {
- runLogWriter :: LogMessage -> writerM ()
- runLogWriterReader :: LogWriter h -> Eff (LogWriterReader h ': e) a -> Eff e a
- askLogWriter :: SetMember LogWriterReader (LogWriterReader h) e => Eff e (LogWriter h)
- localLogWriterReader :: forall h e a. SetMember LogWriterReader (LogWriterReader h) e => (LogWriter h -> LogWriter h) -> Eff e a -> Eff e a
- noOpLogWriter :: Applicative m => LogWriter m
- filteringLogWriter :: Monad e => LogPredicate -> LogWriter e -> LogWriter e
- mappingLogWriter :: (LogMessage -> LogMessage) -> LogWriter e -> LogWriter e
- mappingLogWriterM :: Monad e => (LogMessage -> e LogMessage) -> LogWriter e -> LogWriter e
- type LogIo e = (LogsTo IO e, Lifted IO e)
- type LogsTo h e = (Member Logs e, HandleLogWriter h e, SetMember LogWriterReader (LogWriterReader h) e)
- data Logs v
- withLogging :: forall h e a. (Applicative h, LogsTo h (Logs ': (LogWriterReader h ': e))) => LogWriter h -> Eff (Logs ': (LogWriterReader h ': e)) a -> Eff e a
- withSomeLogging :: forall h e a. (Applicative h, LogsTo h (Logs ': (LogWriterReader h ': e))) => Eff (Logs ': (LogWriterReader h ': e)) a -> Eff e a
- runLogs :: forall h e b. LogsTo h (Logs ': e) => LogPredicate -> Eff (Logs ': e) b -> Eff e b
- logMsg :: forall e. (HasCallStack, Member Logs e) => LogMessage -> Eff e ()
- logWithSeverity :: forall e. (HasCallStack, Member Logs e) => Severity -> Text -> Eff e ()
- logWithSeverity' :: forall e. (HasCallStack, Member Logs e) => Severity -> String -> Eff e ()
- logEmergency :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e ()
- logAlert :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e ()
- logCritical :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e ()
- logError :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e ()
- logWarning :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e ()
- logNotice :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e ()
- logInfo :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e ()
- logDebug :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e ()
- logEmergency' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e ()
- logAlert' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e ()
- logCritical' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e ()
- logError' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e ()
- logWarning' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e ()
- logNotice' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e ()
- logInfo' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e ()
- logDebug' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e ()
- askLogPredicate :: forall e. Member Logs e => Eff e LogPredicate
- setLogPredicate :: forall r b. (Member Logs r, HasCallStack) => LogPredicate -> Eff r b -> Eff r b
- modifyLogPredicate :: forall e b. (Member Logs e, HasCallStack) => (LogPredicate -> LogPredicate) -> Eff e b -> Eff e b
- includeLogMessages :: forall e a. Member Logs e => LogPredicate -> Eff e a -> Eff e a
- excludeLogMessages :: forall e a. Member Logs e => LogPredicate -> Eff e a -> Eff e a
- respondToLogMessage :: forall r b. Member Logs r => (LogMessage -> Eff r ()) -> Eff r b -> Eff r b
- interceptLogMessages :: forall r b. Member Logs r => (LogMessage -> Eff r LogMessage) -> Eff r b -> Eff r b
- modifyLogWriter :: forall h e a. LogsTo h e => (LogWriter h -> LogWriter h) -> Eff e a -> Eff e a
- setLogWriter :: forall h e a. LogsTo h e => LogWriter h -> Eff e a -> Eff e a
- censorLogs :: LogsTo h e => (LogMessage -> LogMessage) -> Eff e a -> Eff e a
- censorLogsM :: (LogsTo h e, Monad h) => (LogMessage -> h LogMessage) -> Eff e a -> Eff e a
- addLogWriter :: forall h e a. (HasCallStack, LogsTo h e, Monad h) => LogWriter h -> Eff e a -> Eff e a
- newtype ProcessId = ProcessId {}
- data ProcessDown = ProcessDown {}
- data MonitorReference = MonitorReference {}
- data SomeExitReason where
- SomeExitReason :: Interrupt x -> SomeExitReason
- type Interrupts = Exc (Interrupt Recoverable)
- type SafeProcesses r = Process r ': r
- type Processes e = Interrupts ': SafeProcesses e
- type RecoverableInterrupt = Interrupt Recoverable
- data Interrupt (t :: ExitRecovery) where
- NormalExitRequested :: Interrupt Recoverable
- OtherProcessNotRunning :: ProcessId -> Interrupt Recoverable
- TimeoutInterrupt :: String -> Interrupt Recoverable
- LinkedProcessCrashed :: ProcessId -> Interrupt Recoverable
- ErrorInterrupt :: String -> Interrupt Recoverable
- ExitNormally :: Interrupt NoRecovery
- ExitUnhandledError :: Text -> Interrupt NoRecovery
- ExitProcessCancelled :: Interrupt NoRecovery
- data ExitSeverity
- = NormalExit
- | Crash
- data ExitRecovery
- data ProcessState
- = ProcessBooting
- | ProcessIdle
- | ProcessBusy
- | ProcessBusyUpdatingDetails
- | ProcessBusySending
- | ProcessBusySendingShutdown
- | ProcessBusySendingInterrupt
- | ProcessBusyReceiving
- | ProcessBusyLinking
- | ProcessBusyUnlinking
- | ProcessBusyMonitoring
- | ProcessBusyDemonitoring
- | ProcessInterrupted
- | ProcessShuttingDown
- data MessageSelector a
- data ResumeProcess v where
- Interrupted :: Interrupt Recoverable -> ResumeProcess v
- ResumeWith :: a -> ResumeProcess a
- newtype Serializer message = MkSerializer {
- runSerializer :: message -> StrictDynamic
- data StrictDynamic
- data Process (r :: [Type -> Type]) b where
- FlushMessages :: Process r (ResumeProcess [StrictDynamic])
- YieldProcess :: Process r (ResumeProcess ())
- SelfPid :: Process r (ResumeProcess ProcessId)
- Spawn :: ProcessTitle -> Eff (Process r ': r) () -> Process r (ResumeProcess ProcessId)
- SpawnLink :: ProcessTitle -> Eff (Process r ': r) () -> Process r (ResumeProcess ProcessId)
- Shutdown :: Interrupt NoRecovery -> Process r a
- SendShutdown :: ProcessId -> Interrupt NoRecovery -> Process r (ResumeProcess ())
- SendInterrupt :: ProcessId -> Interrupt Recoverable -> Process r (ResumeProcess ())
- SendMessage :: ProcessId -> StrictDynamic -> Process r (ResumeProcess ())
- ReceiveSelectedMessage :: forall r a. MessageSelector a -> Process r (ResumeProcess a)
- MakeReference :: Process r (ResumeProcess Int)
- Monitor :: ProcessId -> Process r (ResumeProcess MonitorReference)
- Demonitor :: MonitorReference -> Process r (ResumeProcess ())
- Link :: ProcessId -> Process r (ResumeProcess ())
- Unlink :: ProcessId -> Process r (ResumeProcess ())
- UpdateProcessDetails :: ProcessDetails -> Process r (ResumeProcess ())
- GetProcessState :: ProcessId -> Process r (ResumeProcess (Maybe (ProcessTitle, ProcessDetails, ProcessState)))
- toStrictDynamic :: (Typeable a, NFData a) => a -> StrictDynamic
- fromStrictDynamic :: Typeable a => StrictDynamic -> Maybe a
- unwrapStrictDynamic :: StrictDynamic -> Dynamic
- selectMessage :: Typeable t => MessageSelector t
- filterMessage :: Typeable a => (a -> Bool) -> MessageSelector a
- selectMessageWith :: Typeable a => (a -> Maybe b) -> MessageSelector b
- selectDynamicMessage :: (StrictDynamic -> Maybe a) -> MessageSelector a
- selectAnyMessage :: MessageSelector StrictDynamic
- toExitRecovery :: Interrupt r -> ExitRecovery
- toExitSeverity :: Interrupt e -> ExitSeverity
- interruptToExit :: Interrupt Recoverable -> Interrupt NoRecovery
- isProcessDownInterrupt :: Maybe ProcessId -> Interrupt r -> Bool
- provideInterruptsShutdown :: forall e a. Eff (Processes e) a -> Eff (SafeProcesses e) a
- handleInterrupts :: (HasCallStack, Member Interrupts r) => (Interrupt Recoverable -> Eff r a) -> Eff r a -> Eff r a
- tryUninterrupted :: (HasCallStack, Member Interrupts r) => Eff r a -> Eff r (Either (Interrupt Recoverable) a)
- logInterrupts :: forall r. (Member Logs r, HasCallStack, Member Interrupts r) => Eff r () -> Eff r ()
- exitOnInterrupt :: (HasCallStack, Member Interrupts r, SetMember Process (Process q) r) => Eff r a -> Eff r a
- provideInterrupts :: HasCallStack => Eff (Interrupts ': r) a -> Eff r (Either (Interrupt Recoverable) a)
- mergeEitherInterruptAndExitReason :: Either (Interrupt Recoverable) (Interrupt NoRecovery) -> Interrupt NoRecovery
- interrupt :: (HasCallStack, Member Interrupts r) => Interrupt Recoverable -> Eff r a
- isCrash :: Interrupt x -> Bool
- isRecoverable :: Interrupt x -> Bool
- fromSomeExitReason :: SomeExitReason -> Either (Interrupt NoRecovery) (Interrupt Recoverable)
- toCrashReason :: Interrupt x -> Maybe Text
- logProcessExit :: forall e x. (Member Logs e, HasCallStack) => Interrupt x -> Eff e ()
- executeAndResume :: forall q r v. (SetMember Process (Process q) r, HasCallStack) => Process q (ResumeProcess v) -> Eff r (Either (Interrupt Recoverable) v)
- executeAndResumeOrExit :: forall r q v. (SetMember Process (Process q) r, HasCallStack) => Process q (ResumeProcess v) -> Eff r v
- executeAndResumeOrThrow :: forall q r v. (SetMember Process (Process q) r, HasCallStack, Member Interrupts r) => Process q (ResumeProcess v) -> Eff r v
- yieldProcess :: forall r q. (SetMember Process (Process q) r, HasCallStack, Member Interrupts r) => Eff r ()
- sendMessage :: forall r q o. (SetMember Process (Process q) r, HasCallStack, Member Interrupts r, Typeable o, NFData o) => ProcessId -> o -> Eff r ()
- sendAnyMessage :: forall r q. (SetMember Process (Process q) r, HasCallStack, Member Interrupts r) => ProcessId -> StrictDynamic -> Eff r ()
- sendShutdown :: forall r q. (SetMember Process (Process q) r, HasCallStack, Member Interrupts r) => ProcessId -> Interrupt NoRecovery -> Eff r ()
- sendInterrupt :: forall r q. (SetMember Process (Process q) r, HasCallStack, Member Interrupts r) => ProcessId -> Interrupt Recoverable -> Eff r ()
- spawn :: forall r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => ProcessTitle -> Eff (Processes q) () -> Eff r ProcessId
- spawn_ :: forall r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => ProcessTitle -> Eff (Processes q) () -> Eff r ()
- spawnLink :: forall r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => ProcessTitle -> Eff (Processes q) () -> Eff r ProcessId
- spawnRaw :: forall r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => ProcessTitle -> Eff (SafeProcesses q) () -> Eff r ProcessId
- spawnRaw_ :: forall r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => ProcessTitle -> Eff (SafeProcesses q) () -> Eff r ()
- isProcessAlive :: forall r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => ProcessId -> Eff r Bool
- getProcessState :: forall r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => ProcessId -> Eff r (Maybe (ProcessTitle, ProcessDetails, ProcessState))
- updateProcessDetails :: forall r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => ProcessDetails -> Eff r ()
- receiveAnyMessage :: forall r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => Eff r StrictDynamic
- receiveSelectedMessage :: forall r q a. (HasCallStack, Show a, SetMember Process (Process q) r, Member Interrupts r) => MessageSelector a -> Eff r a
- receiveMessage :: forall a r q. (HasCallStack, Typeable a, NFData a, Show a, SetMember Process (Process q) r, Member Interrupts r) => Eff r a
- flushMessages :: forall r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => Eff r [StrictDynamic]
- receiveSelectedLoop :: forall r q a endOfLoopResult. (SetMember Process (Process q) r, HasCallStack) => MessageSelector a -> (Either (Interrupt Recoverable) a -> Eff r (Maybe endOfLoopResult)) -> Eff r endOfLoopResult
- receiveAnyLoop :: forall r q endOfLoopResult. (SetMember Process (Process q) r, HasCallStack) => (Either (Interrupt Recoverable) StrictDynamic -> Eff r (Maybe endOfLoopResult)) -> Eff r endOfLoopResult
- receiveLoop :: forall r q a endOfLoopResult. (SetMember Process (Process q) r, HasCallStack, NFData a, Typeable a) => (Either (Interrupt Recoverable) a -> Eff r (Maybe endOfLoopResult)) -> Eff r endOfLoopResult
- self :: (HasCallStack, SetMember Process (Process q) r) => Eff r ProcessId
- makeReference :: (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => Eff r Int
- monitor :: forall r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => ProcessId -> Eff r MonitorReference
- demonitor :: forall r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => MonitorReference -> Eff r ()
- withMonitor :: (HasCallStack, Member Interrupts r, SetMember Process (Process q) r, Member Interrupts r) => ProcessId -> (MonitorReference -> Eff r a) -> Eff r a
- receiveWithMonitor :: (HasCallStack, Member Interrupts r, SetMember Process (Process q) r, Member Interrupts r, Typeable a, Show a) => ProcessId -> MessageSelector a -> Eff r (Either ProcessDown a)
- becauseProcessIsDown :: ProcessDown -> Interrupt Recoverable
- selectProcessDown :: MonitorReference -> MessageSelector ProcessDown
- linkProcess :: forall r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => ProcessId -> Eff r ()
- unlinkProcess :: forall r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => ProcessId -> Eff r ()
- exitBecause :: forall r q a. (HasCallStack, SetMember Process (Process q) r) => Interrupt NoRecovery -> Eff r a
- exitNormally :: forall r q a. (HasCallStack, SetMember Process (Process q) r) => Eff r a
- exitWithError :: forall r q a. (HasCallStack, SetMember Process (Process q) r) => String -> Eff r a
- fromProcessId :: Iso' ProcessId Int
- newtype Endpoint protocol = Endpoint {}
- type family ProtocolReply (s :: Synchronicity) where ...
- data Synchronicity
- type TangiblePdu p r = (Typeable p, Typeable r, Tangible (Pdu p r))
- type Tangible i = (NFData i, Typeable i, Show i)
- data family Pdu (protocol :: Type) (reply :: Synchronicity)
- class EmbedProtocol protocol embeddedProtocol where
- fromEndpoint :: forall protocol protocol. Iso (Endpoint protocol) (Endpoint protocol) ProcessId ProcessId
- proxyAsEndpoint :: proxy protocol -> ProcessId -> Endpoint protocol
- asEndpoint :: forall protocol. ProcessId -> Endpoint protocol
- data TimerElapsed
- data TimerReference
- data Timeout
- receiveAfter :: forall a r q. (Lifted IO q, HasCallStack, SetMember Process (Process q) r, Member Interrupts r, Typeable a, NFData a, Show a) => Timeout -> Eff r (Maybe a)
- receiveSelectedAfter :: forall a r q. (Lifted IO q, HasCallStack, SetMember Process (Process q) r, Member Interrupts r, Show a) => MessageSelector a -> Timeout -> Eff r (Either TimerElapsed a)
- receiveSelectedWithMonitorAfter :: forall a r q. (Lifted IO q, HasCallStack, SetMember Process (Process q) r, Member Interrupts r, Show a) => ProcessId -> MessageSelector a -> Timeout -> Eff r (Either (Either ProcessDown TimerElapsed) a)
- selectTimerElapsed :: TimerReference -> MessageSelector TimerElapsed
- sendAfter :: forall r q message. (Lifted IO q, HasCallStack, SetMember Process (Process q) r, Member Interrupts r, Typeable message, NFData message) => ProcessId -> Timeout -> (TimerReference -> message) -> Eff r TimerReference
- startTimer :: forall r q. (Lifted IO q, HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => Timeout -> Eff r TimerReference
- cancelTimer :: forall r q. (Lifted IO q, HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => TimerReference -> Eff r ()
- type EndpointReader o = Reader (Endpoint o)
- type ServesProtocol o r q = (Typeable o, SetMember Process (Process q) r, Member (EndpointReader o) r)
- cast :: forall o' o r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r, TangiblePdu o' Asynchronous, TangiblePdu o Asynchronous, EmbedProtocol o' o) => Endpoint o' -> Pdu o Asynchronous -> Eff r ()
- call :: forall result protocol' protocol r q. (SetMember Process (Process q) r, Member Interrupts r, TangiblePdu protocol' (Synchronous result), TangiblePdu protocol (Synchronous result), EmbedProtocol protocol' protocol, Tangible result, HasCallStack) => Endpoint protocol' -> Pdu protocol (Synchronous result) -> Eff r result
- callWithTimeout :: forall result protocol' protocol r q. (SetMember Process (Process q) r, Member Interrupts r, TangiblePdu protocol' (Synchronous result), TangiblePdu protocol (Synchronous result), EmbedProtocol protocol' protocol, Tangible result, Member Logs r, Lifted IO q, Lifted IO r, HasCallStack) => Endpoint protocol' -> Pdu protocol (Synchronous result) -> Timeout -> Eff r result
- runEndpointReader :: HasCallStack => Endpoint o -> Eff (EndpointReader o ': r) a -> Eff r a
- askEndpoint :: Member (EndpointReader o) e => Eff e (Endpoint o)
- callEndpointReader :: forall reply o r q. (ServesProtocol o r q, HasCallStack, Tangible reply, TangiblePdu o (Synchronous reply), Member Interrupts r) => Pdu o (Synchronous reply) -> Eff r reply
- castEndpointReader :: forall o r q. (ServesProtocol o r q, HasCallStack, Member Interrupts r, TangiblePdu o Asynchronous) => Pdu o Asynchronous -> Eff r ()
- type ObserverState o = State (Observers o)
- data Observers o
- data ObserverRegistry o
- data Observer o where
- Observer :: (Tangible o, TangiblePdu p Asynchronous, Tangible (Endpoint p), Typeable p) => (o -> Maybe (Pdu p Asynchronous)) -> Endpoint p -> Observer o
- registerObserver :: (SetMember Process (Process q) r, HasCallStack, Member Interrupts r, TangibleObserver o, EmbedProtocol x (ObserverRegistry o), TangiblePdu x Asynchronous) => Observer o -> Endpoint x -> Eff r ()
- forgetObserver :: (SetMember Process (Process q) r, HasCallStack, Member Interrupts r, Typeable o, NFData o, EmbedProtocol x (ObserverRegistry o), TangiblePdu x Asynchronous) => Observer o -> Endpoint x -> Eff r ()
- handleObservations :: (HasCallStack, Typeable o, SetMember Process (Process q) r, NFData (Observer o)) => (o -> Eff r ()) -> Pdu (Observer o) Asynchronous -> Eff r ()
- toObserver :: TangibleObserver o => Endpoint (Observer o) -> Observer o
- toObserverFor :: (TangibleObserver o, Typeable a, TangiblePdu a Asynchronous) => (o -> Pdu a Asynchronous) -> Endpoint a -> Observer o
- handleObserverRegistration :: forall o q r. (HasCallStack, Typeable o, SetMember Process (Process q) r, Member (ObserverState o) r, Member Logs r) => Pdu (ObserverRegistry o) Asynchronous -> Eff r ()
- manageObservers :: Eff (ObserverState o ': r) a -> Eff r a
- emptyObservers :: Observers o
- observed :: forall o r q. (SetMember Process (Process q) r, Member (ObserverState o) r, Member Interrupts r, TangibleObserver o) => o -> Eff r ()
- type ObservationQueueReader a = Reader (ObservationQueue a)
- data ObservationQueue a
- readObservationQueue :: forall o r. (Member (ObservationQueueReader o) r, HasCallStack, MonadIO (Eff r), Typeable o, Member Logs r) => Eff r o
- tryReadObservationQueue :: forall o r. (Member (ObservationQueueReader o) r, HasCallStack, MonadIO (Eff r), Typeable o, Member Logs r) => Eff r (Maybe o)
- flushObservationQueue :: forall o r. (Member (ObservationQueueReader o) r, HasCallStack, MonadIO (Eff r), Typeable o, Member Logs r) => Eff r [o]
- withObservationQueue :: forall o b e len. (HasCallStack, Typeable o, Show o, Member Logs e, Lifted IO e, Integral len, Member Interrupts e) => len -> Eff (ObservationQueueReader o ': e) b -> Eff e b
- spawnLinkObservationQueueWriter :: forall o q h. (TangibleObserver o, TangiblePdu (Observer o) Asynchronous, Member Logs q, Lifted IO q, LogsTo h (Processes q), HasCallStack) => ObservationQueue o -> Eff (Processes q) (Observer o)
- type CaptureLogWriter = Writer LogMessage
- newtype CaptureLogs a = MkCaptureLogs {
- unCaptureLogs :: Eff '[CaptureLogWriter] a
- captureLogWriter :: LogWriter CaptureLogs
- runCaptureLogWriter :: Eff (CaptureLogWriter ': e) a -> Eff e (a, [LogMessage])
- type LoggingAndIo = '[Logs, LogWriterReader IO, Lift IO]
- mkLogWriterIO :: HasCallStack => (LogMessage -> IO ()) -> LogWriter IO
- ioHandleLogWriter :: HasCallStack => Handle -> LogWriter IO
- withIoLogging :: SetMember Lift (Lift IO) e => LogWriter IO -> Text -> Facility -> LogPredicate -> Eff (Logs ': (LogWriterReader IO ': e)) a -> Eff e a
- defaultIoLogWriter :: Text -> Facility -> LogWriter IO -> LogWriter IO
- printLogMessage :: LogMessage -> IO ()
- withFileLogging :: (Lifted IO e, MonadBaseControl IO (Eff e)) => FilePath -> Text -> Facility -> LogPredicate -> Eff (Logs ': (LogWriterReader IO ': e)) a -> Eff e a
- withFileLogWriter :: (Lifted IO e, LogsTo IO e, MonadBaseControl IO (Eff e)) => FilePath -> Eff e b -> Eff e b
- withTraceLogging :: Lifted IO e => Text -> Facility -> LogPredicate -> Eff (Logs ': (LogWriterReader IO ': e)) a -> Eff e a
- withTraceLogWriter :: forall h e a. (Monad h, LogsTo h e) => Eff e a -> Eff e a
- debugTraceLogWriter :: forall h. Monad h => LogMessageRenderer Text -> LogWriter h
- withConsoleLogging :: Lifted IO e => Text -> Facility -> LogPredicate -> Eff (Logs ': (LogWriterReader IO ': e)) a -> Eff e a
- withConsoleLogWriter :: (LogsTo IO e, Lifted IO e) => Eff e a -> Eff e a
- consoleLogWriter :: LogWriter IO
- stdoutLogWriter :: LogMessageRenderer Text -> LogWriter IO
- withAsyncLogging :: (Lifted IO e, MonadBaseControl IO (Eff e), Integral len) => LogWriter IO -> len -> Text -> Facility -> LogPredicate -> Eff (Logs ': (LogWriterReader IO ': e)) a -> Eff e a
- withAsyncLogWriter :: (LogsTo IO e, Lifted IO e, MonadBaseControl IO (Eff e), Integral len) => len -> Eff e a -> Eff e a
- withUDPLogging :: (HasCallStack, MonadBaseControl IO (Eff e), Lifted IO e) => (LogMessage -> Text) -> String -> String -> Text -> Facility -> LogPredicate -> Eff (Logs ': (LogWriterReader IO ': e)) a -> Eff e a
- withUDPLogWriter :: (Lifted IO e, LogsTo IO e, MonadBaseControl IO (Eff e), HasCallStack) => (LogMessage -> Text) -> String -> String -> Eff e b -> Eff e b
- withUnixSocketLogging :: (HasCallStack, MonadBaseControl IO (Eff e), Lifted IO e) => LogMessageRenderer Text -> FilePath -> Text -> Facility -> LogPredicate -> Eff (Logs ': (LogWriterReader IO ': e)) a -> Eff e a
- withUnixSocketLogWriter :: (Lifted IO e, LogsTo IO e, MonadBaseControl IO (Eff e), HasCallStack) => LogMessageRenderer Text -> FilePath -> Eff e b -> Eff e b
- foreverCheap :: Monad m => m a -> m ()
- replicateCheapM_ :: Monad m => Int -> m a -> m ()
- schedule :: HasCallStack => LogWriter IO -> Eff Effects a -> IO (Either (Interrupt NoRecovery) a)
- defaultMain :: HasCallStack => Eff EffectsIo () -> IO ()
- defaultMainWithLogWriter :: HasCallStack => LogWriter IO -> Eff EffectsIo () -> IO ()
- type Effects = EffectsIo
- type SafeEffects = SafeEffectsIo
- type BaseEffects = BaseEffectsIo
- type HasBaseEffects e = HasBaseEffectsIo e
Generic functions and type for Processes and Messages
An rfc 5424 facility
Constructors
| Facility | |
Fields
| |
Instances
| Eq Facility Source # | |
| Ord Facility Source # | |
Defined in Control.Eff.Log.Message | |
| Show Facility Source # | |
| Generic Facility Source # | |
| Default Facility Source # | |
Defined in Control.Eff.Log.Message | |
| NFData Facility Source # | |
Defined in Control.Eff.Log.Message | |
| type Rep Facility Source # | |
Defined in Control.Eff.Log.Message | |
An rfc 5424 severity
Instances
| Eq Severity Source # | |
| Ord Severity Source # | |
Defined in Control.Eff.Log.Message | |
| Show Severity Source # | |
| Generic Severity Source # | |
| Default Severity Source # | |
Defined in Control.Eff.Log.Message | |
| NFData Severity Source # | |
Defined in Control.Eff.Log.Message | |
| type Rep Severity Source # | |
Defined in Control.Eff.Log.Message | |
data SdParameter Source #
Component of an RFC-5424 StructuredDataElement
Constructors
| MkSdParameter !Text !Text |
Instances
data StructuredDataElement Source #
RFC-5424 defines how structured data can be included in a log message.
Constructors
| SdElement | |
Fields
| |
Instances
data LogMessage Source #
A message data type inspired by the RFC-5424 Syslog Protocol
Constructors
| MkLogMessage | |
Fields
| |
Instances
emergencySeverity :: Severity Source #
Smart constructor for the RFC-5424 emergency LogMessage Severity.
This corresponds to the severity value 0.
See lmSeverity.
alertSeverity :: Severity Source #
Smart constructor for the RFC-5424 alert LogMessage Severity.
This corresponds to the severity value 1.
See lmSeverity.
criticalSeverity :: Severity Source #
Smart constructor for the RFC-5424 critical LogMessage Severity.
This corresponds to the severity value 2.
See lmSeverity.
errorSeverity :: Severity Source #
Smart constructor for the RFC-5424 error LogMessage Severity.
This corresponds to the severity value 3.
See lmSeverity.
warningSeverity :: Severity Source #
Smart constructor for the RFC-5424 warning LogMessage Severity.
This corresponds to the severity value 4.
See lmSeverity.
noticeSeverity :: Severity Source #
Smart constructor for the RFC-5424 notice LogMessage Severity.
This corresponds to the severity value 5.
See lmSeverity.
informationalSeverity :: Severity Source #
Smart constructor for the RFC-5424 informational LogMessage Severity.
This corresponds to the severity value 6.
See lmSeverity.
debugSeverity :: Severity Source #
Smart constructor for the RFC-5424 debug LogMessage Severity.
This corresponds to the severity value 7.
See lmSeverity.
kernelMessages :: Facility Source #
Smart constructor for the RFC-5424 LogMessage facility kernelMessages.
See lmFacility.
userLevelMessages :: Facility Source #
Smart constructor for the RFC-5424 LogMessage facility userLevelMessages.
See lmFacility.
mailSystem :: Facility Source #
Smart constructor for the RFC-5424 LogMessage facility mailSystem.
See lmFacility.
systemDaemons :: Facility Source #
Smart constructor for the RFC-5424 LogMessage facility systemDaemons.
See lmFacility.
securityAuthorizationMessages4 :: Facility Source #
Smart constructor for the RFC-5424 LogMessage facility securityAuthorizationMessages4.
See lmFacility.
linePrinterSubsystem :: Facility Source #
Smart constructor for the RFC-5424 LogMessage facility linePrinterSubsystem.
See lmFacility.
networkNewsSubsystem :: Facility Source #
Smart constructor for the RFC-5424 LogMessage facility networkNewsSubsystem.
See lmFacility.
uucpSubsystem :: Facility Source #
Smart constructor for the RFC-5424 LogMessage facility uucpSubsystem.
See lmFacility.
clockDaemon :: Facility Source #
Smart constructor for the RFC-5424 LogMessage facility clockDaemon.
See lmFacility.
securityAuthorizationMessages10 :: Facility Source #
Smart constructor for the RFC-5424 LogMessage facility securityAuthorizationMessages10.
See lmFacility.
ftpDaemon :: Facility Source #
Smart constructor for the RFC-5424 LogMessage facility ftpDaemon.
See lmFacility.
ntpSubsystem :: Facility Source #
Smart constructor for the RFC-5424 LogMessage facility ntpSubsystem.
See lmFacility.
logAuditFacility :: Facility Source #
Smart constructor for the RFC-5424 LogMessage facility logAuditFacility.
See lmFacility.
logAlertFacility :: Facility Source #
Smart constructor for the RFC-5424 LogMessage facility logAlertFacility.
See lmFacility.
clockDaemon2 :: Facility Source #
Smart constructor for the RFC-5424 LogMessage facility clockDaemon2.
See lmFacility.
Smart constructor for the RFC-5424 LogMessage facility local0.
See lmFacility.
Smart constructor for the RFC-5424 LogMessage facility local1.
See lmFacility.
Smart constructor for the RFC-5424 LogMessage facility local2.
See lmFacility.
Smart constructor for the RFC-5424 LogMessage facility local3.
See lmFacility.
Smart constructor for the RFC-5424 LogMessage facility local4.
See lmFacility.
Smart constructor for the RFC-5424 LogMessage facility local5.
See lmFacility.
Smart constructor for the RFC-5424 LogMessage facility local6.
See lmFacility.
Smart constructor for the RFC-5424 LogMessage facility local7.
See lmFacility.
sdElementId :: Functor f => (Text -> f Text) -> StructuredDataElement -> f StructuredDataElement Source #
A lens for the key or ID of a group of RFC 5424 key-value pairs.
sdElementParameters :: Functor f => ([SdParameter] -> f [SdParameter]) -> StructuredDataElement -> f StructuredDataElement Source #
A lens for SdParameters
type LogPredicate = LogMessage -> Bool Source #
The filter predicate for message that shall be logged.
See Control.Eff.Log
class ToLogMessage a where Source #
Things that can become a LogMessage
Instances
| ToLogMessage Text Source # | |
Defined in Control.Eff.Log.Message Methods toLogMessage :: Text -> LogMessage Source # | |
| ToLogMessage LogMessage Source # | |
Defined in Control.Eff.Log.Message Methods toLogMessage :: LogMessage -> LogMessage Source # | |
lmAppName :: Functor f => (Maybe Text -> f (Maybe Text)) -> LogMessage -> f LogMessage Source #
A lens for the RFC 5424 application name of a LogMessage
One useful pattern for using this field, is to implement log filters that allow info and debug message from the application itself while only allowing warning and error messages from third party libraries:
debugLogsForAppName myAppName lm = view lmAppName lm == Just myAppName || lmSeverityIsAtLeast warningSeverity lm
This concept is also implemented in discriminateByAppName.
lmFacility :: Functor f => (Facility -> f Facility) -> LogMessage -> f LogMessage Source #
A lens for the Facility of a LogMessage
lmHostname :: Functor f => (Maybe Text -> f (Maybe Text)) -> LogMessage -> f LogMessage Source #
A lens for the hostname of a LogMessage
The function setLogMessageHostname can be used to set the field.
lmMessage :: Functor f => (Text -> f Text) -> LogMessage -> f LogMessage Source #
A lens for the user defined textual message of a LogMessage
lmMessageId :: Functor f => (Maybe Text -> f (Maybe Text)) -> LogMessage -> f LogMessage Source #
A lens for a user defined message id of a LogMessage
lmProcessId :: Functor f => (Maybe Text -> f (Maybe Text)) -> LogMessage -> f LogMessage Source #
A lens for a user defined of process id of a LogMessage
lmSeverity :: Functor f => (Severity -> f Severity) -> LogMessage -> f LogMessage Source #
A lens for the Severity of a LogMessage
lmSrcLoc :: Functor f => (Maybe SrcLoc -> f (Maybe SrcLoc)) -> LogMessage -> f LogMessage Source #
A lens for the SrcLoc of a LogMessage
lmStructuredData :: Functor f => ([StructuredDataElement] -> f [StructuredDataElement]) -> LogMessage -> f LogMessage Source #
A lens for the StructuredDataElement of a LogMessage
lmThreadId :: Functor f => (Maybe ThreadId -> f (Maybe ThreadId)) -> LogMessage -> f LogMessage Source #
A lens for the ThreadId of a LogMessage
The function setLogMessageThreadId can be used to set the field.
lmTimestamp :: Functor f => (Maybe UTCTime -> f (Maybe UTCTime)) -> LogMessage -> f LogMessage Source #
A lens for the UTC time of a LogMessage
The function setLogMessageTimestamp can be used to set the field.
setCallStack :: CallStack -> LogMessage -> LogMessage Source #
Put the source location of the given callstack in lmSrcLoc
prefixLogMessagesWith :: Text -> LogMessage -> LogMessage Source #
Prefix the lmMessage.
setLogMessageTimestamp :: LogMessage -> IO LogMessage Source #
An IO action that sets the current UTC time in lmTimestamp.
setLogMessageThreadId :: LogMessage -> IO LogMessage Source #
An IO action appends the the ThreadId of the calling process (see myThreadId)
to lmMessage.
setLogMessageHostname :: LogMessage -> IO LogMessage Source #
An IO action that sets the current hosts fully qualified hostname in lmHostname.
errorMessage :: HasCallStack => Text -> LogMessage Source #
Construct a LogMessage with errorSeverity
infoMessage :: HasCallStack => Text -> LogMessage Source #
Construct a LogMessage with informationalSeverity
debugMessage :: HasCallStack => Text -> LogMessage Source #
Construct a LogMessage with debugSeverity
errorMessageIO :: (HasCallStack, MonadIO m) => Text -> m LogMessage Source #
Construct a LogMessage with errorSeverity
infoMessageIO :: (HasCallStack, MonadIO m) => Text -> m LogMessage Source #
Construct a LogMessage with informationalSeverity
debugMessageIO :: (HasCallStack, MonadIO m) => Text -> m LogMessage Source #
Construct a LogMessage with debugSeverity
allLogMessages :: LogPredicate Source #
All messages.
See Control.Eff.Log.Message for more predicates.
noLogMessages :: LogPredicate Source #
No messages.
See Control.Eff.Log.Message for more predicates.
lmSeverityIs :: Severity -> LogPredicate Source #
Match LogMessages that have exactly the given severity.
See lmSeverityIsAtLeast.
See Control.Eff.Log.Message for more predicates.
lmSeverityIsAtLeast :: Severity -> LogPredicate Source #
Match LogMessages that have the given severity or worse.
See lmSeverityIs.
See Control.Eff.Log.Message for more predicates.
lmMessageStartsWith :: Text -> LogPredicate Source #
Match LogMessages whose lmMessage starts with the given string.
See Control.Eff.Log.Message for more predicates.
discriminateByAppName :: Text -> LogPredicate -> LogPredicate -> LogPredicate Source #
Apply a LogPredicate based on the lmAppName and delegate
to one of two LogPredicates.
One useful application for this is to allow info and debug message from one application, e.g. the current application itself, while at the same time allowing only warning and error messages from third party libraries.
See Control.Eff.Log.Message for more predicates.
data LogMessageTimeRenderer Source #
A rendering function for the lmTimestamp field.
type LogMessageRenderer a = LogMessage -> a Source #
LogMessage rendering function
mkLogMessageTimeRenderer Source #
Arguments
| :: String | The format string that is passed to |
| -> LogMessageTimeRenderer |
Make a LogMessageTimeRenderer using formatTime in the defaultLocale.
suppressTimestamp :: LogMessageTimeRenderer Source #
Don't render the time stamp
rfc3164Timestamp :: LogMessageTimeRenderer Source #
Render the time stamp using "%h %d %H:%M:%S"
rfc5424Timestamp :: LogMessageTimeRenderer Source #
Render the time stamp to iso8601DateFormat (Just "%H:%M:%S%6QZ")
rfc5424NoZTimestamp :: LogMessageTimeRenderer Source #
Render the time stamp like rfc5424Timestamp does, but omit the terminal Z character.
renderLogMessageBody :: LogMessageRenderer Text Source #
Print the thread id, the message and the source file location, seperated by simple white space.
renderLogMessageBodyNoLocation :: LogMessageRenderer Text Source #
Print the thread id, the message and the source file location, seperated by simple white space.
renderLogMessageBodyFixWidth :: LogMessageRenderer Text Source #
Print the body of a LogMessage with fix size fields (60) for the message itself
and 30 characters for the location
renderMaybeLogMessageLens :: Text -> Getter LogMessage (Maybe Text) -> LogMessageRenderer Text Source #
Render a field of a LogMessage using the corresponsing lens.
renderLogMessageSrcLoc :: LogMessageRenderer (Maybe Text) Source #
Render the source location as: at filepath:linenumber.
renderSyslogSeverityAndFacility :: LogMessageRenderer Text Source #
Render the severity and facility as described in RFC-3164
Render e.g. as <192>.
Useful as header for syslog compatible log output.
renderLogMessageSyslog :: LogMessageRenderer Text Source #
Render the LogMessage to contain the severity, message, message-id, pid.
Omit hostname, PID and timestamp.
Render the header using renderSyslogSeverity
Useful for logging to devlog
renderLogMessageConsoleLog :: LogMessageRenderer Text Source #
Render a LogMessage human readable, for console logging
renderRFC3164 :: LogMessageRenderer Text Source #
Render a LogMessage according to the rules in the RFC-3164.
renderRFC3164WithRFC5424Timestamps :: LogMessageRenderer Text Source #
Render a LogMessage according to the rules in the RFC-3164 but use
RFC5424 time stamps.
renderRFC3164WithTimestamp :: LogMessageTimeRenderer -> LogMessageRenderer Text Source #
Render a LogMessage according to the rules in the RFC-3164 but use the custom
LogMessageTimeRenderer.
renderRFC5424 :: LogMessageRenderer Text Source #
Render a LogMessage according to the rules in the RFC-5424.
Equivalent to .renderRFC5424Header <> const " " <> renderLogMessageBody
Since: 0.21.0
renderRFC5424NoLocation :: LogMessageRenderer Text Source #
Render a LogMessage according to the rules in the RFC-5424, like renderRFC5424 but
suppress the source location information.
Equivalent to .renderRFC5424Header <> const " " <> renderLogMessageBodyNoLocation
Since: 0.21.0
renderRFC5424Header :: LogMessageRenderer Text Source #
Render the header and strucuted data of a LogMessage according to the rules in the RFC-5424, but do not
render the lmMessage.
Since: 0.22.0
newtype PureLogWriter a Source #
A phantom type for the HandleLogWriter class for pure LogWriters
Constructors
| MkPureLogWriter | |
Fields
| |
Instances
class HandleLogWriter (writerEff :: Type -> Type) e where Source #
The instances of this class are the monads that define (side-) effect(s) of writting logs.
Minimal complete definition
Methods
handleLogWriterEffect :: writerEff () -> Eff e () Source #
liftWriteLogMessage :: SetMember LogWriterReader (LogWriterReader writerEff) e => LogMessage -> Eff e () Source #
Write a message using the LogWriter found in the environment.
The semantics of this function are a combination of runLogWriter and handleLogWriterEffect,
with the LogWriter read from a LogWriterReader.
Instances
| Lifted IO e => HandleLogWriter IO e Source # | |
Defined in Control.Eff.Log.Writer Methods handleLogWriterEffect :: IO () -> Eff e () Source # liftWriteLogMessage :: LogMessage -> Eff e () Source # | |
| HandleLogWriter PureLogWriter e Source # | |
Defined in Control.Eff.Log.Writer Methods handleLogWriterEffect :: PureLogWriter () -> Eff e () Source # liftWriteLogMessage :: LogMessage -> Eff e () Source # | |
| Member CaptureLogWriter e => HandleLogWriter CaptureLogs e Source # | A The |
Defined in Control.Eff.LogWriter.Capture Methods handleLogWriterEffect :: CaptureLogs () -> Eff e () Source # liftWriteLogMessage :: LogMessage -> Eff e () Source # | |
data LogWriterReader h v Source #
A Reader specialized for LogWriters
The existing Reader couldn't be used together with SetMember, so this
lazy reader was written, specialized to reading LogWriter.
Instances
newtype LogWriter writerM Source #
A function that takes a log message and returns an effect that logs the message.
Constructors
| MkLogWriter | |
Fields
| |
Instances
| Applicative w => Default (LogWriter w) Source # | |
Defined in Control.Eff.Log.Writer | |
| Handle (LogWriterReader h) e a (LogWriter h -> k) Source # | |
Defined in Control.Eff.Log.Writer Methods handle :: (Eff e a -> LogWriter h -> k) -> Arrs e v a -> LogWriterReader h v -> LogWriter h -> k # handle_relay :: (e ~ (LogWriterReader h ': r'), Relay (LogWriter h -> k) r') => (a -> LogWriter h -> k) -> (Eff e a -> LogWriter h -> k) -> Eff e a -> LogWriter h -> k # respond_relay :: (a -> LogWriter h -> k) -> (Eff e a -> LogWriter h -> k) -> Eff e a -> LogWriter h -> k # | |
runLogWriterReader :: LogWriter h -> Eff (LogWriterReader h ': e) a -> Eff e a Source #
Provide the LogWriter
Exposed for custom extensions, if in doubt use withLogging.
askLogWriter :: SetMember LogWriterReader (LogWriterReader h) e => Eff e (LogWriter h) Source #
Get the current LogWriter.
localLogWriterReader :: forall h e a. SetMember LogWriterReader (LogWriterReader h) e => (LogWriter h -> LogWriter h) -> Eff e a -> Eff e a Source #
Modify the current LogWriter.
noOpLogWriter :: Applicative m => LogWriter m Source #
filteringLogWriter :: Monad e => LogPredicate -> LogWriter e -> LogWriter e Source #
A LogWriter that applies a predicate to the LogMessage and delegates to
to the given writer of the predicate is satisfied.
mappingLogWriter :: (LogMessage -> LogMessage) -> LogWriter e -> LogWriter e Source #
A LogWriter that applies a function to the LogMessage and delegates the result to
to the given writer.
mappingLogWriterM :: Monad e => (LogMessage -> e LogMessage) -> LogWriter e -> LogWriter e Source #
Like mappingLogWriter allow the function that changes the LogMessage to have effects.
type LogsTo h e = (Member Logs e, HandleLogWriter h e, SetMember LogWriterReader (LogWriterReader h) e) Source #
A constraint alias for effects that requires a LogWriterReader, as well as that the
contained LogWriterReader has a HandleLogWriter instance.
The requirements of this constraint are provided by:
withIoLoggingwithLoggingwithSomeLogging
This effect sends LogMessages and is a reader for a LogPredicate.
Logs are sent via logMsg;
for more information about log predicates, see Control.Eff.Log
This effect is handled via withLogging.
Instances
| Handle Logs e a (LogPredicate -> k) Source # | |
Defined in Control.Eff.Log.Handler Methods handle :: (Eff e a -> LogPredicate -> k) -> Arrs e v a -> Logs v -> LogPredicate -> k # handle_relay :: (e ~ (Logs ': r'), Relay (LogPredicate -> k) r') => (a -> LogPredicate -> k) -> (Eff e a -> LogPredicate -> k) -> Eff e a -> LogPredicate -> k # respond_relay :: (a -> LogPredicate -> k) -> (Eff e a -> LogPredicate -> k) -> Eff e a -> LogPredicate -> k # | |
| (MonadBase m m, LiftedBase m e, LogsTo m (Logs ': e)) => MonadBaseControl m (Eff (Logs ': e)) Source # | This instance allows lifting the |
| (LiftedBase m e, MonadThrow (Eff e)) => MonadThrow (Eff (Logs ': e)) Source # | |
| (Applicative m, LiftedBase m e, MonadCatch (Eff e), LogsTo m (Logs ': e)) => MonadCatch (Eff (Logs ': e)) Source # | |
| (Applicative m, LiftedBase m e, MonadMask (Eff e), LogsTo m (Logs ': e)) => MonadMask (Eff (Logs ': e)) Source # | |
Defined in Control.Eff.Log.Handler Methods mask :: ((forall a. Eff (Logs ': e) a -> Eff (Logs ': e) a) -> Eff (Logs ': e) b) -> Eff (Logs ': e) b # uninterruptibleMask :: ((forall a. Eff (Logs ': e) a -> Eff (Logs ': e) a) -> Eff (Logs ': e) b) -> Eff (Logs ': e) b # generalBracket :: Eff (Logs ': e) a -> (a -> ExitCase b -> Eff (Logs ': e) c) -> (a -> Eff (Logs ': e) b) -> Eff (Logs ': e) (b, c) # | |
| type StM (Eff (Logs ': e)) a Source # | |
withLogging :: forall h e a. (Applicative h, LogsTo h (Logs ': (LogWriterReader h ': e))) => LogWriter h -> Eff (Logs ': (LogWriterReader h ': e)) a -> Eff e a Source #
Handle the Logs and LogWriterReader effects.
It installs the given LogWriter, which determines the underlying
LogWriter type parameter.
Example:
exampleWithLogging :: IO ()
exampleWithLogging =
runLift
$ withLogging consoleLogWriter
$ logDebug "Oh, hi there"withSomeLogging :: forall h e a. (Applicative h, LogsTo h (Logs ': (LogWriterReader h ': e))) => Eff (Logs ': (LogWriterReader h ': e)) a -> Eff e a Source #
Handles the Logs and LogWriterReader effects.
By default it uses the noOpLogWriter, but using setLogWriter the
LogWriter can be replaced.
This is like withLogging applied to noOpLogWriter
Example:
exampleWithSomeLogging :: ()
exampleWithSomeLogging =
run
$ withSomeLogging @PureLogWriter
$ logDebug "Oh, hi there"runLogs :: forall h e b. LogsTo h (Logs ': e) => LogPredicate -> Eff (Logs ': e) b -> Eff e b Source #
Raw handling of the Logs effect.
Exposed for custom extensions, if in doubt use withLogging.
logMsg :: forall e. (HasCallStack, Member Logs e) => LogMessage -> Eff e () Source #
Log a message.
All logging goes through this function.
This function is the only place where the LogPredicate is applied.
Also, LogMessages are evaluated using deepseq, after they pass the LogPredicate.
logWithSeverity :: forall e. (HasCallStack, Member Logs e) => Severity -> Text -> Eff e () Source #
Log a Text as LogMessage with a given Severity.
logWithSeverity' :: forall e. (HasCallStack, Member Logs e) => Severity -> String -> Eff e () Source #
Log a Text as LogMessage with a given Severity.
logEmergency :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e () Source #
Log a String as emergencySeverity.
logAlert :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e () Source #
Log a message with alertSeverity.
logCritical :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e () Source #
Log a criticalSeverity message.
logError :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e () Source #
Log a errorSeverity message.
logWarning :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e () Source #
Log a warningSeverity message.
logNotice :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e () Source #
Log a noticeSeverity message.
logInfo :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e () Source #
Log a informationalSeverity message.
logDebug :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e () Source #
Log a debugSeverity message.
logEmergency' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e () Source #
Log a String as emergencySeverity.
logAlert' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e () Source #
Log a message with alertSeverity.
logCritical' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e () Source #
Log a criticalSeverity message.
logError' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e () Source #
Log a errorSeverity message.
logWarning' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e () Source #
Log a warningSeverity message.
logNotice' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e () Source #
Log a noticeSeverity message.
logInfo' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e () Source #
Log a informationalSeverity message.
logDebug' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e () Source #
Log a debugSeverity message.
askLogPredicate :: forall e. Member Logs e => Eff e LogPredicate Source #
Get the current Logs filter/transformer function.
See Control.Eff.Log
setLogPredicate :: forall r b. (Member Logs r, HasCallStack) => LogPredicate -> Eff r b -> Eff r b Source #
Keep only those messages, for which a predicate holds.
E.g. to keep only messages which begin with OMG:
exampleLogPredicate :: IO Int
exampleLogPredicate =
runLift
$ withLogging consoleLogWriter
$ do logMsg "test"
setLogPredicate (\ msg -> case view lmMessage msg of
'O':'M':'G':_ -> True
_ -> False)
(do logMsg "this message will not be logged"
logMsg "OMG logged"
return 42)In order to also delegate to the previous predicate, use modifyLogPredicate
See Control.Eff.Log
modifyLogPredicate :: forall e b. (Member Logs e, HasCallStack) => (LogPredicate -> LogPredicate) -> Eff e b -> Eff e b Source #
Change the LogPredicate.
Other than setLogPredicate this function allows to include the previous predicate, too.
For to discard all messages currently no satisfying the predicate and also all messages that are to long:
modifyLogPredicate (previousPredicate msg -> previousPredicate msg && length (lmMessage msg) < 29 )
(do logMsg "this message will not be logged"
logMsg "this message might be logged")
See Control.Eff.Log
includeLogMessages :: forall e a. Member Logs e => LogPredicate -> Eff e a -> Eff e a Source #
Include LogMessages that match a LogPredicate.
excludeLogMessages p allows log message to be logged if p m
Although it is enough if the previous predicate holds.
See excludeLogMessages and modifyLogPredicate.
See Control.Eff.Log
excludeLogMessages :: forall e a. Member Logs e => LogPredicate -> Eff e a -> Eff e a Source #
Exclude LogMessages that match a LogPredicate.
excludeLogMessages p discards logs if p m
Also the previous predicate must also hold for a
message to be logged.
See excludeLogMessages and modifyLogPredicate.
See Control.Eff.Log
respondToLogMessage :: forall r b. Member Logs r => (LogMessage -> Eff r ()) -> Eff r b -> Eff r b Source #
Consume log messages.
Exposed for custom extensions, if in doubt use withLogging.
Respond to all LogMessages logged from the given action,
up to any MonadBaseControl liftings.
Note that all logging is done through logMsg and that means
only messages passing the LogPredicate are received.
The LogMessages are consumed once they are passed to the
given callback function, previous respondToLogMessage invocations
further up in the call stack will not get the messages anymore.
Use interceptLogMessages if the messages shall be passed
any previous handler.
NOTE: The effects of this function are lost when using
MonadBaseControl, MonadMask, MonadCatch and MonadThrow.
In contrast the functions based on modifying the LogWriter,
such as addLogWriter or censorLogs, are save to use in combination
with the aforementioned liftings.
interceptLogMessages :: forall r b. Member Logs r => (LogMessage -> Eff r LogMessage) -> Eff r b -> Eff r b Source #
Change the LogMessages using an effectful function.
Exposed for custom extensions, if in doubt use withLogging.
This differs from respondToLogMessage in that the intercepted messages will be
written either way, albeit in altered form.
NOTE: The effects of this function are lost when using
MonadBaseControl, MonadMask, MonadCatch and MonadThrow.
In contrast the functions based on modifying the LogWriter,
such as addLogWriter or censorLogs, are save to use in combination
with the aforementioned liftings.
modifyLogWriter :: forall h e a. LogsTo h e => (LogWriter h -> LogWriter h) -> Eff e a -> Eff e a Source #
Change the current LogWriter.
setLogWriter :: forall h e a. LogsTo h e => LogWriter h -> Eff e a -> Eff e a Source #
Replace the current LogWriter.
To add an additional log message consumer use addLogWriter
censorLogs :: LogsTo h e => (LogMessage -> LogMessage) -> Eff e a -> Eff e a Source #
Modify the the LogMessages written in the given sub-expression.
Note: This is equivalent to modifyLogWriter . mappingLogWriter
censorLogsM :: (LogsTo h e, Monad h) => (LogMessage -> h LogMessage) -> Eff e a -> Eff e a Source #
Modify the the LogMessages written in the given sub-expression, as in censorLogs
but with a effectful function.
Note: This is equivalent to modifyLogWriter . mappingLogWriterM
addLogWriter :: forall h e a. (HasCallStack, LogsTo h e, Monad h) => LogWriter h -> Eff e a -> Eff e a Source #
Combine the effects of a given LogWriter and the existing one.
import Data.Text as T
import Data.Text.IO as T
exampleAddLogWriter :: IO ()
exampleAddLogWriter = go >>= T.putStrLn
where go = fmap (unlines . map renderLogMessageConsoleLog . snd)
$ runLift
$ runCaptureLogWriter
$ withLogging captureLogWriter
$ addLogWriter (mappingLogWriter (lmMessage %~ ("CAPTURED "++)) captureLogWriter)
$ addLogWriter (filteringLogWriter severeMessages (mappingLogWriter (lmMessage %~ ("TRACED "++)) debugTraceLogWriter))
$ do
logEmergency "test emergencySeverity 1"
logCritical "test criticalSeverity 2"
logAlert "test alertSeverity 3"
logError "test errorSeverity 4"
logWarning "test warningSeverity 5"
logInfo "test informationalSeverity 6"
logDebug "test debugSeverity 7"
severeMessages = view (lmSeverity . to (<= errorSeverity))
Each process is identified by a single process id, that stays constant throughout the life cycle of a process. Also, message sending relies on these values to address messages to processes.
Constructors
| ProcessId | |
Fields | |
Instances
data ProcessDown Source #
A monitored process exited. This message is sent to a process by the scheduler, when a process that was monitored died.
Since: 0.12.0
Constructors
| ProcessDown | |
Fields | |
Instances
data MonitorReference Source #
A value that contains a unique reference of a process monitoring.
Since: 0.12.0
Constructors
| MonitorReference | |
Fields | |
Instances
data SomeExitReason where Source #
An existential wrapper around Interrupt
Constructors
| SomeExitReason :: Interrupt x -> SomeExitReason |
Instances
| Eq SomeExitReason Source # | |
Defined in Control.Eff.Concurrent.Process Methods (==) :: SomeExitReason -> SomeExitReason -> Bool # (/=) :: SomeExitReason -> SomeExitReason -> Bool # | |
| Ord SomeExitReason Source # | |
Defined in Control.Eff.Concurrent.Process Methods compare :: SomeExitReason -> SomeExitReason -> Ordering # (<) :: SomeExitReason -> SomeExitReason -> Bool # (<=) :: SomeExitReason -> SomeExitReason -> Bool # (>) :: SomeExitReason -> SomeExitReason -> Bool # (>=) :: SomeExitReason -> SomeExitReason -> Bool # max :: SomeExitReason -> SomeExitReason -> SomeExitReason # min :: SomeExitReason -> SomeExitReason -> SomeExitReason # | |
| Show SomeExitReason Source # | |
Defined in Control.Eff.Concurrent.Process Methods showsPrec :: Int -> SomeExitReason -> ShowS # show :: SomeExitReason -> String # showList :: [SomeExitReason] -> ShowS # | |
| NFData SomeExitReason Source # | |
Defined in Control.Eff.Concurrent.Process Methods rnf :: SomeExitReason -> () # | |
type Interrupts = Exc (Interrupt Recoverable) Source #
Exceptions containing Interrupts.
See handleInterrupts, exitOnInterrupt or provideInterrupts
type SafeProcesses r = Process r ': r Source #
Cons Process onto a list of effects. This is called SafeProcesses because
the the actions cannot be interrupted in.
type Processes e = Interrupts ': SafeProcesses e Source #
This adds a layer of the Interrupts effect on top of Processes
type RecoverableInterrupt = Interrupt Recoverable Source #
Interrupts which are Recoverable.
data Interrupt (t :: ExitRecovery) where Source #
A sum-type with reasons for why a process operation, such as receiving messages, is interrupted in the scheduling loop.
This includes errors, that can occur when scheduling messages.
Since: 0.23.0
Constructors
| NormalExitRequested :: Interrupt Recoverable | A process has finished a unit of work and might exit or work on
something else. This is primarily used for interrupting infinite
server loops, allowing for additional cleanup work before
exiting (e.g. with Since: 0.13.2 |
| OtherProcessNotRunning :: ProcessId -> Interrupt Recoverable | A process that should be running was not running. |
| TimeoutInterrupt :: String -> Interrupt Recoverable | A |
| LinkedProcessCrashed :: ProcessId -> Interrupt Recoverable | A linked process is down |
| ErrorInterrupt :: String -> Interrupt Recoverable | An exit reason that has an error message and is |
| ExitNormally :: Interrupt NoRecovery | A process function returned or exited without any error. |
| ExitUnhandledError :: Text -> Interrupt NoRecovery | An error causes the process to exit immediately.
For example an unexpected runtime exception was thrown, i.e. an exception
derived from |
| ExitProcessCancelled :: Interrupt NoRecovery | A process shall exit immediately, without any cleanup was cancelled (e.g. killed, in |
Instances
data ExitSeverity Source #
This value indicates whether a process exited in way consistent with the planned behaviour or not.
Constructors
| NormalExit | |
| Crash |
Instances
| Eq ExitSeverity Source # | |
Defined in Control.Eff.Concurrent.Process | |
| Ord ExitSeverity Source # | |
Defined in Control.Eff.Concurrent.Process Methods compare :: ExitSeverity -> ExitSeverity -> Ordering # (<) :: ExitSeverity -> ExitSeverity -> Bool # (<=) :: ExitSeverity -> ExitSeverity -> Bool # (>) :: ExitSeverity -> ExitSeverity -> Bool # (>=) :: ExitSeverity -> ExitSeverity -> Bool # max :: ExitSeverity -> ExitSeverity -> ExitSeverity # min :: ExitSeverity -> ExitSeverity -> ExitSeverity # | |
| Show ExitSeverity Source # | |
Defined in Control.Eff.Concurrent.Process Methods showsPrec :: Int -> ExitSeverity -> ShowS # show :: ExitSeverity -> String # showList :: [ExitSeverity] -> ShowS # | |
| Generic ExitSeverity Source # | |
Defined in Control.Eff.Concurrent.Process Associated Types type Rep ExitSeverity :: Type -> Type # | |
| NFData ExitSeverity Source # | |
Defined in Control.Eff.Concurrent.Process Methods rnf :: ExitSeverity -> () # | |
| type Rep ExitSeverity Source # | |
Defined in Control.Eff.Concurrent.Process | |
data ExitRecovery Source #
This kind is used to indicate if a Interrupt can be treated like
a short interrupt which can be handled or ignored.
Constructors
| Recoverable | |
| NoRecovery |
Instances
| Eq ExitRecovery Source # | |
Defined in Control.Eff.Concurrent.Process | |
| Ord ExitRecovery Source # | |
Defined in Control.Eff.Concurrent.Process Methods compare :: ExitRecovery -> ExitRecovery -> Ordering # (<) :: ExitRecovery -> ExitRecovery -> Bool # (<=) :: ExitRecovery -> ExitRecovery -> Bool # (>) :: ExitRecovery -> ExitRecovery -> Bool # (>=) :: ExitRecovery -> ExitRecovery -> Bool # max :: ExitRecovery -> ExitRecovery -> ExitRecovery # min :: ExitRecovery -> ExitRecovery -> ExitRecovery # | |
| Show ExitRecovery Source # | |
Defined in Control.Eff.Concurrent.Process Methods showsPrec :: Int -> ExitRecovery -> ShowS # show :: ExitRecovery -> String # showList :: [ExitRecovery] -> ShowS # | |
| Generic ExitRecovery Source # | |
Defined in Control.Eff.Concurrent.Process Associated Types type Rep ExitRecovery :: Type -> Type # | |
| NFData ExitRecovery Source # | |
Defined in Control.Eff.Concurrent.Process Methods rnf :: ExitRecovery -> () # | |
| type Rep ExitRecovery Source # | |
Defined in Control.Eff.Concurrent.Process | |
data ProcessState Source #
The state that a Process is currently in.
Constructors
| ProcessBooting | The process has just been started but not scheduled yet. |
| ProcessIdle | The process yielded it's time slice |
| ProcessBusy | The process is busy with non-blocking |
| ProcessBusyUpdatingDetails | The process is busy with |
| ProcessBusySending | The process is busy with sending a message |
| ProcessBusySendingShutdown | The process is busy with killing |
| ProcessBusySendingInterrupt | The process is busy with killing |
| ProcessBusyReceiving | The process blocked by a |
| ProcessBusyLinking | The process blocked by a |
| ProcessBusyUnlinking | The process blocked by a |
| ProcessBusyMonitoring | The process blocked by a |
| ProcessBusyDemonitoring | The process blocked by a |
| ProcessInterrupted | The process was interrupted |
| ProcessShuttingDown | The process was shutdown or crashed |
Instances
data MessageSelector a Source #
A function that decided if the next message will be received by
ReceiveSelectedMessage. It conveniently is an instance of
Alternative so the message selector can be combined:
>
> selectInt :: MessageSelector Int
> selectInt = selectMessage
>
> selectString :: MessageSelector String
> selectString = selectMessage
>
> selectIntOrString :: MessageSelector (Either Int String)
> selectIntOrString =
> Left $ selectTimeout| Right $ selectString
Instances
data ResumeProcess v where Source #
Every Process action returns it's actual result wrapped in this type. It
will allow to signal errors as well as pass on normal results such as
incoming messages.
Constructors
| Interrupted :: Interrupt Recoverable -> ResumeProcess v | The current operation of the process was interrupted with a
|
| ResumeWith :: a -> ResumeProcess a | The process may resume to do work, using the given result. |
Instances
newtype Serializer message Source #
Serialize a message into a StrictDynamic value to be sent via sendAnyMessage.
This indirection allows, among other things, the composition of
Servers.
Since: 0.24.1
Constructors
| MkSerializer | |
Fields
| |
Instances
| Contravariant Serializer Source # | |
Defined in Control.Eff.Concurrent.Process Methods contramap :: (a -> b) -> Serializer b -> Serializer a # (>$) :: b -> Serializer b -> Serializer a # | |
data StrictDynamic Source #
Data flows between Processes via these messages.
This is just a newtype wrapper around Dynamic.
The reason this type exists is to force construction through the code in this
module, which always evaluates a message to normal form before
sending it to another process.
Since: 0.22.0
Instances
| Show StrictDynamic Source # | |
Defined in Control.Eff.Concurrent.Process Methods showsPrec :: Int -> StrictDynamic -> ShowS # show :: StrictDynamic -> String # showList :: [StrictDynamic] -> ShowS # | |
| NFData StrictDynamic Source # | |
Defined in Control.Eff.Concurrent.Process Methods rnf :: StrictDynamic -> () # | |
data Process (r :: [Type -> Type]) b where Source #
The process effect is the basis for message passing concurrency. This effect describes an interface for concurrent, communicating isolated processes identified uniquely by a process-id.
Processes can raise exceptions that can be caught, exit gracefully or with an error, or be killed by other processes, with the option of ignoring the shutdown request.
Process Scheduling is implemented in different modules. All scheduler implementations should follow some basic rules:
- fair scheduling
- sending a message does not block
- receiving a message does block
- spawning a child blocks only a very moment
- a newly spawned process shall be scheduled before the parent process after
- the spawnRaw
- when the first process exists, all process should be killed immediately
Constructors
| FlushMessages :: Process r (ResumeProcess [StrictDynamic]) | Remove all messages from the process' message queue |
| YieldProcess :: Process r (ResumeProcess ()) | In cooperative schedulers, this will give processing time to the scheduler. Every other operation implicitly serves the same purpose. Since: 0.12.0 |
| SelfPid :: Process r (ResumeProcess ProcessId) | Return the current |
| Spawn :: ProcessTitle -> Eff (Process r ': r) () -> Process r (ResumeProcess ProcessId) | Start a new process, the new process will execute an effect, the function
will return immediately with a |
| SpawnLink :: ProcessTitle -> Eff (Process r ': r) () -> Process r (ResumeProcess ProcessId) | Start a new process, and Since: 0.12.0 |
| Shutdown :: Interrupt NoRecovery -> Process r a | Shutdown the process; irregardless of the exit reason, this function never returns, |
| SendShutdown :: ProcessId -> Interrupt NoRecovery -> Process r (ResumeProcess ()) | Shutdown another process immediately, the other process has no way of handling this! |
| SendInterrupt :: ProcessId -> Interrupt Recoverable -> Process r (ResumeProcess ()) | Request that another a process interrupts. The targeted process is interrupted
and gets an |
| SendMessage :: ProcessId -> StrictDynamic -> Process r (ResumeProcess ()) | Send a message to a process addressed by the |
| ReceiveSelectedMessage :: forall r a. MessageSelector a -> Process r (ResumeProcess a) | Receive a message that matches a criteria.
This should block until an a message was received. The message is returned
as a |
| MakeReference :: Process r (ResumeProcess Int) | Generate a unique |
| Monitor :: ProcessId -> Process r (ResumeProcess MonitorReference) | Monitor another process. When the monitored process exits a
Since: 0.12.0 |
| Demonitor :: MonitorReference -> Process r (ResumeProcess ()) | Remove a monitor. Since: 0.12.0 |
| Link :: ProcessId -> Process r (ResumeProcess ()) | Connect the calling process to another process, such that
if one of the processes crashes (i.e. Since: 0.12.0 |
| Unlink :: ProcessId -> Process r (ResumeProcess ()) | Unlink the calling process from the other process. Since: 0.12.0 |
| UpdateProcessDetails :: ProcessDetails -> Process r (ResumeProcess ()) | Update the |
| GetProcessState :: ProcessId -> Process r (ResumeProcess (Maybe (ProcessTitle, ProcessDetails, ProcessState))) | Get the |
Instances
toStrictDynamic :: (Typeable a, NFData a) => a -> StrictDynamic Source #
Deeply evaluate the given value and wrap it into a StrictDynamic.
Since: 0.22.0
fromStrictDynamic :: Typeable a => StrictDynamic -> Maybe a Source #
Convert a StrictDynamic back to a value.
Since: 0.22.0
unwrapStrictDynamic :: StrictDynamic -> Dynamic Source #
Convert a StrictDynamic back to an unwrapped Dynamic.
Since: 0.22.0
selectMessage :: Typeable t => MessageSelector t Source #
Create a message selector for a value that can be obtained by fromStrictDynamic.
Since: 0.9.1
filterMessage :: Typeable a => (a -> Bool) -> MessageSelector a Source #
Create a message selector from a predicate.
Since: 0.9.1
selectMessageWith :: Typeable a => (a -> Maybe b) -> MessageSelector b Source #
Select a message of type a and apply the given function to it.
If the function returns Just The ReceiveSelectedMessage function will
return the result (sans Maybe).
Since: 0.9.1
selectDynamicMessage :: (StrictDynamic -> Maybe a) -> MessageSelector a Source #
Create a message selector.
Since: 0.9.1
selectAnyMessage :: MessageSelector StrictDynamic Source #
Create a message selector that will match every message. This is lazy
because the result is not forceed.
Since: 0.9.1
toExitRecovery :: Interrupt r -> ExitRecovery Source #
Get the ExitRecovery
toExitSeverity :: Interrupt e -> ExitSeverity Source #
Get the ExitSeverity of a Interrupt.
interruptToExit :: Interrupt Recoverable -> Interrupt NoRecovery Source #
Return either ExitNormally or interruptToExit from a Recoverable Interrupt;
If the Interrupt is NormalExitRequested then return ExitNormally
isProcessDownInterrupt :: Maybe ProcessId -> Interrupt r -> Bool Source #
A predicate for linked process crashes.
provideInterruptsShutdown :: forall e a. Eff (Processes e) a -> Eff (SafeProcesses e) a Source #
Handle all Interrupts of an Processes by
wrapping them up in interruptToExit and then do a process Shutdown.
handleInterrupts :: (HasCallStack, Member Interrupts r) => (Interrupt Recoverable -> Eff r a) -> Eff r a -> Eff r a Source #
Handle Interrupts arising during process operations, e.g.
when a linked process crashes while we wait in a receiveSelectedMessage
via a call to interrupt.
tryUninterrupted :: (HasCallStack, Member Interrupts r) => Eff r a -> Eff r (Either (Interrupt Recoverable) a) Source #
Like handleInterrupts, but instead of passing the Interrupt
to a handler function, Either is returned.
Since: 0.13.2
logInterrupts :: forall r. (Member Logs r, HasCallStack, Member Interrupts r) => Eff r () -> Eff r () Source #
Handle interrupts by logging them with logProcessExit and otherwise
ignoring them.
exitOnInterrupt :: (HasCallStack, Member Interrupts r, SetMember Process (Process q) r) => Eff r a -> Eff r a Source #
Handle Interrupts arising during process operations, e.g.
when a linked process crashes while we wait in a receiveSelectedMessage
via a call to interrupt.
provideInterrupts :: HasCallStack => Eff (Interrupts ': r) a -> Eff r (Either (Interrupt Recoverable) a) Source #
Handle Interrupts arising during process operations, e.g.
when a linked process crashes while we wait in a receiveSelectedMessage
via a call to interrupt.
mergeEitherInterruptAndExitReason :: Either (Interrupt Recoverable) (Interrupt NoRecovery) -> Interrupt NoRecovery Source #
Wrap all (left) Interrupts into interruptToExit and
return the (right) NoRecovery Interrupts as is.
interrupt :: (HasCallStack, Member Interrupts r) => Interrupt Recoverable -> Eff r a Source #
Throw an Interrupt, can be handled by handleInterrupts or
exitOnInterrupt or provideInterrupts.
isCrash :: Interrupt x -> Bool Source #
A predicate for crashes. A crash happens when a process exits
with an Interrupt other than ExitNormally
isRecoverable :: Interrupt x -> Bool Source #
A predicate for recoverable exit reasons. This predicate defines the
exit reasons which functions such as executeAndResume
fromSomeExitReason :: SomeExitReason -> Either (Interrupt NoRecovery) (Interrupt Recoverable) Source #
Partition a SomeExitReason back into either a NoRecovery
or a Recoverable Interrupt
toCrashReason :: Interrupt x -> Maybe Text Source #
Print a Interrupt to Just a formatted String when isCrash
is True.
This can be useful in combination with view patterns, e.g.:
logCrash :: Interrupt -> Eff e () logCrash (toCrashReason -> Just reason) = logError reason logCrash _ = return ()
Though this can be improved to:
logCrash = traverse_ logError . toCrashReason
logProcessExit :: forall e x. (Member Logs e, HasCallStack) => Interrupt x -> Eff e () Source #
Log the Interrupts
executeAndResume :: forall q r v. (SetMember Process (Process q) r, HasCallStack) => Process q (ResumeProcess v) -> Eff r (Either (Interrupt Recoverable) v) Source #
Execute a and action and return the result;
if the process is interrupted by an error or exception, or an explicit
shutdown from another process, or through a crash of a linked process, i.e.
whenever the exit reason satisfies isRecoverable, return the exit reason.
executeAndResumeOrExit :: forall r q v. (SetMember Process (Process q) r, HasCallStack) => Process q (ResumeProcess v) -> Eff r v Source #
Execute a Process action and resume the process, exit
the process when an Interrupts was raised. Use executeAndResume to catch
interrupts.
executeAndResumeOrThrow :: forall q r v. (SetMember Process (Process q) r, HasCallStack, Member Interrupts r) => Process q (ResumeProcess v) -> Eff r v Source #
Execute a Process action and resume the process, exit
the process when an Interrupts was raised. Use executeAndResume to catch
interrupts.
yieldProcess :: forall r q. (SetMember Process (Process q) r, HasCallStack, Member Interrupts r) => Eff r () Source #
Use executeAndResumeOrExit to execute YieldProcess. Refer to YieldProcess
for more information.
sendMessage :: forall r q o. (SetMember Process (Process q) r, HasCallStack, Member Interrupts r, Typeable o, NFData o) => ProcessId -> o -> Eff r () Source #
Send a message to a process addressed by the ProcessId.
See SendMessage.
The message will be reduced to normal form (rnf) by/in the caller process.
sendAnyMessage :: forall r q. (SetMember Process (Process q) r, HasCallStack, Member Interrupts r) => ProcessId -> StrictDynamic -> Eff r () Source #
Send a Dynamic value to a process addressed by the ProcessId.
See SendMessage.
sendShutdown :: forall r q. (SetMember Process (Process q) r, HasCallStack, Member Interrupts r) => ProcessId -> Interrupt NoRecovery -> Eff r () Source #
Exit a process addressed by the ProcessId. The process will exit,
it might do some cleanup, but is ultimately unrecoverable.
See SendShutdown.
sendInterrupt :: forall r q. (SetMember Process (Process q) r, HasCallStack, Member Interrupts r) => ProcessId -> Interrupt Recoverable -> Eff r () Source #
Interrupts a process addressed by the ProcessId. The process might exit,
or it may continue.
| Like sendInterrupt, but also return True iff the process to exit exists.
spawn :: forall r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => ProcessTitle -> Eff (Processes q) () -> Eff r ProcessId Source #
Start a new process, the new process will execute an effect, the function
will return immediately with a ProcessId. If the new process is
interrupted, the process will Shutdown with the Interrupt
wrapped in interruptToExit. For specific use cases it might be better to use
spawnRaw.
spawn_ :: forall r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => ProcessTitle -> Eff (Processes q) () -> Eff r () Source #
Like spawn but return ().
spawnLink :: forall r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => ProcessTitle -> Eff (Processes q) () -> Eff r ProcessId Source #
Start a new process, and immediately link to it.
Since: 0.12.0
spawnRaw :: forall r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => ProcessTitle -> Eff (SafeProcesses q) () -> Eff r ProcessId Source #
Start a new process, the new process will execute an effect, the function
will return immediately with a ProcessId. The spawned process has only the
raw SafeProcesses effects. For non-library code spawn might be better
suited.
spawnRaw_ :: forall r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => ProcessTitle -> Eff (SafeProcesses q) () -> Eff r () Source #
Like spawnRaw but return ().
isProcessAlive :: forall r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => ProcessId -> Eff r Bool Source #
Return True if the process is alive.
Since: 0.12.0
getProcessState :: forall r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => ProcessId -> Eff r (Maybe (ProcessTitle, ProcessDetails, ProcessState)) Source #
Return the ProcessTitle, ProcessDetails and ProcessState,
for the given process, if the process is alive.
Since: 0.24.1
updateProcessDetails :: forall r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => ProcessDetails -> Eff r () Source #
Replace the ProcessDetails of the process.
Since: 0.24.1
receiveAnyMessage :: forall r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => Eff r StrictDynamic Source #
Block until a message was received.
See ReceiveSelectedMessage for more documentation.
receiveSelectedMessage :: forall r q a. (HasCallStack, Show a, SetMember Process (Process q) r, Member Interrupts r) => MessageSelector a -> Eff r a Source #
Block until a message was received, that is not Nothing after applying
a callback to it.
See ReceiveSelectedMessage for more documentation.
receiveMessage :: forall a r q. (HasCallStack, Typeable a, NFData a, Show a, SetMember Process (Process q) r, Member Interrupts r) => Eff r a Source #
Receive and cast the message to some Typeable instance.
See ReceiveSelectedMessage for more documentation.
This will wait for a message of the return type using receiveSelectedMessage
flushMessages :: forall r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => Eff r [StrictDynamic] Source #
Remove and return all messages currently enqueued in the process message queue.
Since: 0.12.0
receiveSelectedLoop :: forall r q a endOfLoopResult. (SetMember Process (Process q) r, HasCallStack) => MessageSelector a -> (Either (Interrupt Recoverable) a -> Eff r (Maybe endOfLoopResult)) -> Eff r endOfLoopResult Source #
Enter a loop to receive messages and pass them to a callback, until the
function returns Just a result.
Only the messages of the given type will be received.
If the process is interrupted by an exception of by a SendShutdown from
another process, with an exit reason that satisfies isRecoverable, then
the callback will be invoked with , otherwise the
process will be exited with the same reason using Left InterruptexitBecause.
See also ReceiveSelectedMessage for more documentation.
receiveAnyLoop :: forall r q endOfLoopResult. (SetMember Process (Process q) r, HasCallStack) => (Either (Interrupt Recoverable) StrictDynamic -> Eff r (Maybe endOfLoopResult)) -> Eff r endOfLoopResult Source #
Like receiveSelectedLoop but not selective.
See also selectAnyMessage, receiveSelectedLoop.
receiveLoop :: forall r q a endOfLoopResult. (SetMember Process (Process q) r, HasCallStack, NFData a, Typeable a) => (Either (Interrupt Recoverable) a -> Eff r (Maybe endOfLoopResult)) -> Eff r endOfLoopResult Source #
Like receiveSelectedLoop but refined to casting to a specific Typeable
using selectMessage.
self :: (HasCallStack, SetMember Process (Process q) r) => Eff r ProcessId Source #
Returns the ProcessId of the current process.
makeReference :: (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => Eff r Int Source #
Generate a unique Int for the current process.
monitor :: forall r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => ProcessId -> Eff r MonitorReference Source #
Monitor another process. When the monitored process exits a
ProcessDown is sent to the calling process.
The return value is a unique identifier for that monitor.
There can be multiple monitors on the same process,
and a message for each will be sent.
If the process is already dead, the ProcessDown message
will be sent immediately, without exit reason
Since: 0.12.0
demonitor :: forall r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => MonitorReference -> Eff r () Source #
Remove a monitor created with monitor.
Since: 0.12.0
withMonitor :: (HasCallStack, Member Interrupts r, SetMember Process (Process q) r, Member Interrupts r) => ProcessId -> (MonitorReference -> Eff r a) -> Eff r a Source #
receiveWithMonitor :: (HasCallStack, Member Interrupts r, SetMember Process (Process q) r, Member Interrupts r, Typeable a, Show a) => ProcessId -> MessageSelector a -> Eff r (Either ProcessDown a) Source #
A MessageSelector for receiving either a monitor of the
given process or another message.
Since: 0.12.0
becauseProcessIsDown :: ProcessDown -> Interrupt Recoverable Source #
Make an Interrupt for a ProcessDown message.
For example: doSomething >>= either (interrupt . becauseProcessIsDown) return
Since: 0.12.0
selectProcessDown :: MonitorReference -> MessageSelector ProcessDown Source #
A MessageSelector for the ProcessDown message of a specific
process.
Since: 0.12.0
linkProcess :: forall r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => ProcessId -> Eff r () Source #
Connect the calling process to another process, such that
if one of the processes crashes (i.e. isCrash returns True), the other
is shutdown with the Interrupt LinkedProcessCrashed.
Since: 0.12.0
unlinkProcess :: forall r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => ProcessId -> Eff r () Source #
Unlink the calling process from the other process.
Since: 0.12.0
exitBecause :: forall r q a. (HasCallStack, SetMember Process (Process q) r) => Interrupt NoRecovery -> Eff r a Source #
Exit the process with a Interrupt.
exitNormally :: forall r q a. (HasCallStack, SetMember Process (Process q) r) => Eff r a Source #
Exit the process.
exitWithError :: forall r q a. (HasCallStack, SetMember Process (Process q) r) => String -> Eff r a Source #
Exit the process with an error.
newtype Endpoint protocol Source #
Constructors
| Endpoint | |
Fields | |
Instances
| Eq (Endpoint protocol) Source # | |
| Ord (Endpoint protocol) Source # | |
Defined in Control.Eff.Concurrent.Protocol Methods compare :: Endpoint protocol -> Endpoint protocol -> Ordering # (<) :: Endpoint protocol -> Endpoint protocol -> Bool # (<=) :: Endpoint protocol -> Endpoint protocol -> Bool # (>) :: Endpoint protocol -> Endpoint protocol -> Bool # (>=) :: Endpoint protocol -> Endpoint protocol -> Bool # max :: Endpoint protocol -> Endpoint protocol -> Endpoint protocol # min :: Endpoint protocol -> Endpoint protocol -> Endpoint protocol # | |
| Typeable protocol => Show (Endpoint protocol) Source # | |
| NFData (Endpoint protocol) Source # | |
Defined in Control.Eff.Concurrent.Protocol | |
| type ToPretty (Endpoint a :: Type) Source # | |
type family ProtocolReply (s :: Synchronicity) where ... Source #
This type function takes an Pdu and analysis the reply type, i.e. the Synchronicity
and evaluates to either t for an
Pdu x ( or to '()' for an Synchronous t)Pdu x .Asynchronous
Since: 0.24.0
Equations
| ProtocolReply (Synchronous t) = t | |
| ProtocolReply Asynchronous = () |
data Synchronicity Source #
The (promoted) constructors of this type specify (at the type level) the
reply behavior of a specific constructor of an Pdu instance.
Constructors
| Synchronous Type | Specify that handling a request is a blocking operation
with a specific return type, e.g. |
| Asynchronous | Non-blocking, asynchronous, request handling |
type TangiblePdu p r = (Typeable p, Typeable r, Tangible (Pdu p r)) Source #
A Constraint that bundles the requirements for the
Pdu values of a protocol.
This ensures that Pdus can be strictly and deeply evaluated and shown
such that for example logging is possible.
Since: 0.24.0
data family Pdu (protocol :: Type) (reply :: Synchronicity) Source #
This data family defines the **protocol data units**(PDU) of a protocol.
A Protocol in the sense of a communication interface description between processes.
The first parameter is usually a user defined type that identifies the
protocol that uses the Pdus are. It maybe a phantom type.
The second parameter specifies if a specific constructor of an (GADT-like)
Pdu instance is Synchronous, i.e. returns a result and blocks the caller
or if it is Asynchronous
Example:
data BookShop deriving Typeable
data instance Pdu BookShop r where
RentBook :: BookId -> Pdu BookShop ('Synchronous (Either RentalError RentalId))
BringBack :: RentalId -> Pdu BookShop 'Asynchronous
type BookId = Int
type RentalId = Int
type RentalError = String
Instances
| (Show (Pdu a1 r), Show (Pdu a2 r)) => Show (Pdu (a1, a2) r) Source # | |
| (Show (Pdu a1 r), Show (Pdu a2 r), Show (Pdu a3 r)) => Show (Pdu (a1, a2, a3) r) Source # | |
| (Show (Pdu a1 r), Show (Pdu a2 r), Show (Pdu a3 r), Show (Pdu a4 r)) => Show (Pdu (a1, a2, a3, a4) r) Source # | |
| (Show (Pdu a1 r), Show (Pdu a2 r), Show (Pdu a3 r), Show (Pdu a4 r), Show (Pdu a5 r)) => Show (Pdu (a1, a2, a3, a4, a5) r) Source # | |
| Show (ChildId p) => Show (Pdu (Sup p) (Synchronous r)) Source # | |
Defined in Control.Eff.Concurrent.Protocol.Supervisor | |
| Show (Pdu (ObserverRegistry o) r) Source # | |
Defined in Control.Eff.Concurrent.Protocol.Observer | |
| Show o => Show (Pdu (Observer o) r) Source # | |
| (NFData (Pdu a1 r), NFData (Pdu a2 r)) => NFData (Pdu (a1, a2) r) Source # | |
Defined in Control.Eff.Concurrent.Protocol | |
| (NFData (Pdu a1 r), NFData (Pdu a2 r), NFData (Pdu a3 r)) => NFData (Pdu (a1, a2, a3) r) Source # | |
Defined in Control.Eff.Concurrent.Protocol | |
| (NFData (Pdu a1 r), NFData (Pdu a2 r), NFData (Pdu a3 r), NFData (Pdu a4 r)) => NFData (Pdu (a1, a2, a3, a4) r) Source # | |
Defined in Control.Eff.Concurrent.Protocol | |
| (NFData (Pdu a1 r), NFData (Pdu a2 r), NFData (Pdu a3 r), NFData (Pdu a4 r), NFData (Pdu a5 r)) => NFData (Pdu (a1, a2, a3, a4, a5) r) Source # | |
Defined in Control.Eff.Concurrent.Protocol | |
| NFData (ChildId p) => NFData (Pdu (Sup p) (Synchronous r)) Source # | |
Defined in Control.Eff.Concurrent.Protocol.Supervisor Methods rnf :: Pdu (Sup p) (Synchronous r) -> () # | |
| NFData (Pdu (ObserverRegistry o) r) Source # | |
Defined in Control.Eff.Concurrent.Protocol.Observer Methods rnf :: Pdu (ObserverRegistry o) r -> () # | |
| NFData o => NFData (Pdu (Observer o) Asynchronous) Source # | |
Defined in Control.Eff.Concurrent.Protocol.Observer Methods rnf :: Pdu (Observer o) Asynchronous -> () # | |
| data Pdu (Observer o) r Source # | A minimal Protocol for handling observations.
This is one simple way of receiving observations - of course users can use
any other Since: 0.16.0 |
Defined in Control.Eff.Concurrent.Protocol.Observer data Pdu (Observer o) r where
| |
| type ToPretty (Pdu x y :: Type) Source # | |
| data Pdu (a1, a2) x Source # | |
Defined in Control.Eff.Concurrent.Protocol | |
| data Pdu (Sup p) r Source # | The Since: 0.23.0 |
Defined in Control.Eff.Concurrent.Protocol.Supervisor data Pdu (Sup p) r where
| |
| data Pdu (ObserverRegistry o) r Source # | Protocol for managing observers. This can be added to any server for any number of different observation types.
The functions Since: 0.16.0 |
Defined in Control.Eff.Concurrent.Protocol.Observer data Pdu (ObserverRegistry o) r where
| |
| data Pdu (a1, a2, a3) x Source # | |
| data Pdu (a1, a2, a3, a4) x Source # | |
| data Pdu (a1, a2, a3, a4, a5) x Source # | |
class EmbedProtocol protocol embeddedProtocol where Source #
A class for Pdu instances that embed other Pdu.
A Prism for the embedded Pdu is the center of this class
Laws: embeddedPdu = prism' embedPdu fromPdu
Since: 0.24.0
Minimal complete definition
Nothing
Methods
embeddedPdu :: Prism' (Pdu protocol result) (Pdu embeddedProtocol result) Source #
embedPdu :: Pdu embeddedProtocol r -> Pdu protocol r Source #
fromPdu :: Pdu protocol r -> Maybe (Pdu embeddedProtocol r) Source #
Instances
| EmbedProtocol a a Source # | |
| EmbedProtocol (a1, a2) a2 Source # | |
| EmbedProtocol (a1, a2) a1 Source # | |
| EmbedProtocol (a1, a2, a3) a3 Source # | |
| EmbedProtocol (a1, a2, a3) a2 Source # | |
| EmbedProtocol (a1, a2, a3) a1 Source # | |
| EmbedProtocol (a1, a2, a3, a4) a4 Source # | |
| EmbedProtocol (a1, a2, a3, a4) a3 Source # | |
| EmbedProtocol (a1, a2, a3, a4) a2 Source # | |
| EmbedProtocol (a1, a2, a3, a4) a1 Source # | |
| EmbedProtocol (a1, a2, a3, a4, a5) a5 Source # | |
| EmbedProtocol (a1, a2, a3, a4, a5) a4 Source # | |
| EmbedProtocol (a1, a2, a3, a4, a5) a3 Source # | |
| EmbedProtocol (a1, a2, a3, a4, a5) a2 Source # | |
| EmbedProtocol (a1, a2, a3, a4, a5) a1 Source # | |
fromEndpoint :: forall protocol protocol. Iso (Endpoint protocol) (Endpoint protocol) ProcessId ProcessId Source #
proxyAsEndpoint :: proxy protocol -> ProcessId -> Endpoint protocol Source #
asEndpoint :: forall protocol. ProcessId -> Endpoint protocol Source #
data TimerElapsed Source #
A value to be sent when timer started with startTimer has elapsed.
Since: 0.12.0
Instances
| Eq TimerElapsed Source # | |
Defined in Control.Eff.Concurrent.Process.Timer | |
| Ord TimerElapsed Source # | |
Defined in Control.Eff.Concurrent.Process.Timer Methods compare :: TimerElapsed -> TimerElapsed -> Ordering # (<) :: TimerElapsed -> TimerElapsed -> Bool # (<=) :: TimerElapsed -> TimerElapsed -> Bool # (>) :: TimerElapsed -> TimerElapsed -> Bool # (>=) :: TimerElapsed -> TimerElapsed -> Bool # max :: TimerElapsed -> TimerElapsed -> TimerElapsed # min :: TimerElapsed -> TimerElapsed -> TimerElapsed # | |
| Show TimerElapsed Source # | |
Defined in Control.Eff.Concurrent.Process.Timer Methods showsPrec :: Int -> TimerElapsed -> ShowS # show :: TimerElapsed -> String # showList :: [TimerElapsed] -> ShowS # | |
| NFData TimerElapsed Source # | |
Defined in Control.Eff.Concurrent.Process.Timer Methods rnf :: TimerElapsed -> () # | |
data TimerReference Source #
The reference to a timer started by startTimer, required to stop
a timer via cancelTimer.
Since: 0.12.0
Instances
A number of micro seconds.
Since: 0.12.0
Instances
| Enum Timeout Source # | |
| Eq Timeout Source # | |
| Integral Timeout Source # | |
Defined in Control.Eff.Concurrent.Process.Timer | |
| Num Timeout Source # | |
| Ord Timeout Source # | |
Defined in Control.Eff.Concurrent.Process.Timer | |
| Real Timeout Source # | |
Defined in Control.Eff.Concurrent.Process.Timer Methods toRational :: Timeout -> Rational # | |
| Show Timeout Source # | |
| NFData Timeout Source # | |
Defined in Control.Eff.Concurrent.Process.Timer | |
receiveAfter :: forall a r q. (Lifted IO q, HasCallStack, SetMember Process (Process q) r, Member Interrupts r, Typeable a, NFData a, Show a) => Timeout -> Eff r (Maybe a) Source #
Wait for a message of the given type for the given time. When no message
arrives in time, return Nothing. This is based on
receiveSelectedAfter.
Since: 0.12.0
receiveSelectedAfter :: forall a r q. (Lifted IO q, HasCallStack, SetMember Process (Process q) r, Member Interrupts r, Show a) => MessageSelector a -> Timeout -> Eff r (Either TimerElapsed a) Source #
Wait for a message of the given type for the given time. When no message
arrives in time, return Left TimerElapsed. This is based on
selectTimerElapsed and startTimer.
Since: 0.12.0
receiveSelectedWithMonitorAfter :: forall a r q. (Lifted IO q, HasCallStack, SetMember Process (Process q) r, Member Interrupts r, Show a) => ProcessId -> MessageSelector a -> Timeout -> Eff r (Either (Either ProcessDown TimerElapsed) a) Source #
Like receiveWithMonitor combined with receiveSelectedAfter.
Since: 0.22.0
selectTimerElapsed :: TimerReference -> MessageSelector TimerElapsed Source #
A MessageSelector matching TimerElapsed messages created by
startTimer.
Since: 0.12.0
sendAfter :: forall r q message. (Lifted IO q, HasCallStack, SetMember Process (Process q) r, Member Interrupts r, Typeable message, NFData message) => ProcessId -> Timeout -> (TimerReference -> message) -> Eff r TimerReference Source #
Send a message to a given process after waiting. The message is created by
applying the function parameter to the TimerReference, such that the
message can directly refer to the timer.
Since: 0.12.0
startTimer :: forall r q. (Lifted IO q, HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => Timeout -> Eff r TimerReference Source #
Start a new timer, after the time has elapsed, TimerElapsed is sent to
calling process. The message also contains the TimerReference returned by
this function. Use cancelTimer to cancel the timer. Use
selectTimerElapsed to receive the message using receiveSelectedMessage.
To receive messages with guarded with a timeout see receiveAfter.
Since: 0.12.0
cancelTimer :: forall r q. (Lifted IO q, HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => TimerReference -> Eff r () Source #
Cancel a timer started with startTimer.
Since: 0.12.0
type EndpointReader o = Reader (Endpoint o) Source #
The reader effect for ProcessIds for Pdus, see runEndpointReader
type ServesProtocol o r q = (Typeable o, SetMember Process (Process q) r, Member (EndpointReader o) r) Source #
cast :: forall o' o r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r, TangiblePdu o' Asynchronous, TangiblePdu o Asynchronous, EmbedProtocol o' o) => Endpoint o' -> Pdu o Asynchronous -> Eff r () Source #
Send a request Pdu that has no reply and return immediately.
The type signature enforces that the corresponding Pdu clause is
Asynchronous. The operation never fails, if it is important to know if the
message was delivered, use call instead.
The message will be reduced to normal form (rnf) in the caller process.
call :: forall result protocol' protocol r q. (SetMember Process (Process q) r, Member Interrupts r, TangiblePdu protocol' (Synchronous result), TangiblePdu protocol (Synchronous result), EmbedProtocol protocol' protocol, Tangible result, HasCallStack) => Endpoint protocol' -> Pdu protocol (Synchronous result) -> Eff r result Source #
Send a request Pdu and wait for the server to return a result value.
The type signature enforces that the corresponding Pdu clause is
Synchronous.
Always prefer callWithTimeout over call
callWithTimeout :: forall result protocol' protocol r q. (SetMember Process (Process q) r, Member Interrupts r, TangiblePdu protocol' (Synchronous result), TangiblePdu protocol (Synchronous result), EmbedProtocol protocol' protocol, Tangible result, Member Logs r, Lifted IO q, Lifted IO r, HasCallStack) => Endpoint protocol' -> Pdu protocol (Synchronous result) -> Timeout -> Eff r result Source #
Send an request Pdu and wait for the server to return a result value.
The type signature enforces that the corresponding Pdu clause is
Synchronous.
If the server that was called dies, this function interrupts the
process with ProcessDown.
If the server takes longer to reply than the given timeout, this
function interrupts the process with TimeoutInterrupt.
Always prefer this function over call
Since: 0.22.0
runEndpointReader :: HasCallStack => Endpoint o -> Eff (EndpointReader o ': r) a -> Eff r a Source #
Run a reader effect that contains the one server handling a specific
Pdu instance.
askEndpoint :: Member (EndpointReader o) e => Eff e (Endpoint o) Source #
Get the Endpoint registered with runEndpointReader.
callEndpointReader :: forall reply o r q. (ServesProtocol o r q, HasCallStack, Tangible reply, TangiblePdu o (Synchronous reply), Member Interrupts r) => Pdu o (Synchronous reply) -> Eff r reply Source #
Like call but take the Endpoint from the reader provided by
runEndpointReader.
castEndpointReader :: forall o r q. (ServesProtocol o r q, HasCallStack, Member Interrupts r, TangiblePdu o Asynchronous) => Pdu o Asynchronous -> Eff r () Source #
Like cast but take the Endpoint from the reader provided by
runEndpointReader.
type ObserverState o = State (Observers o) Source #
Alias for the effect that contains the observers managed by manageObservers
Internal state for manageObservers
Instances
| Eq (Observers o) Source # | |
| Ord (Observers o) Source # | |
Defined in Control.Eff.Concurrent.Protocol.Observer | |
| Show (Observers o) Source # | |
| NFData o => NFData (Observers o) Source # | |
Defined in Control.Eff.Concurrent.Protocol.Observer | |
data ObserverRegistry o Source #
A protocol for managing Observers, encompassing registration and de-registration of
Observers.
Since: 0.16.0
Instances
| Show (Pdu (ObserverRegistry o) r) Source # | |
Defined in Control.Eff.Concurrent.Protocol.Observer | |
| NFData (Pdu (ObserverRegistry o) r) Source # | |
Defined in Control.Eff.Concurrent.Protocol.Observer Methods rnf :: Pdu (ObserverRegistry o) r -> () # | |
| type ToPretty (ObserverRegistry o :: Type) Source # | |
Defined in Control.Eff.Concurrent.Protocol.Observer | |
| data Pdu (ObserverRegistry o) r Source # | Protocol for managing observers. This can be added to any server for any number of different observation types.
The functions Since: 0.16.0 |
Defined in Control.Eff.Concurrent.Protocol.Observer data Pdu (ObserverRegistry o) r where
| |
data Observer o where Source #
Describes a process that observes another via Asynchronous Pdu messages.
An observer consists of a filter and a process id. The filter converts an observation to
a message understood by the observer process, and the ProcessId is used to send the message.
Since: 0.16.0
Constructors
| Observer :: (Tangible o, TangiblePdu p Asynchronous, Tangible (Endpoint p), Typeable p) => (o -> Maybe (Pdu p Asynchronous)) -> Endpoint p -> Observer o |
Instances
| Eq (Observer o) Source # | |
| Ord (Observer o) Source # | |
Defined in Control.Eff.Concurrent.Protocol.Observer | |
| Show (Observer o) Source # | |
| NFData o => NFData (Observer o) Source # | |
Defined in Control.Eff.Concurrent.Protocol.Observer | |
| Show o => Show (Pdu (Observer o) r) Source # | |
| NFData o => NFData (Pdu (Observer o) Asynchronous) Source # | |
Defined in Control.Eff.Concurrent.Protocol.Observer Methods rnf :: Pdu (Observer o) Asynchronous -> () # | |
| data Pdu (Observer o) r Source # | A minimal Protocol for handling observations.
This is one simple way of receiving observations - of course users can use
any other Since: 0.16.0 |
Defined in Control.Eff.Concurrent.Protocol.Observer data Pdu (Observer o) r where
| |
| type ToPretty (Observer o :: Type) Source # | |
Defined in Control.Eff.Concurrent.Protocol.Observer | |
registerObserver :: (SetMember Process (Process q) r, HasCallStack, Member Interrupts r, TangibleObserver o, EmbedProtocol x (ObserverRegistry o), TangiblePdu x Asynchronous) => Observer o -> Endpoint x -> Eff r () Source #
And an Observer to the set of recipients for all observations reported by observed.
Note that the observers are keyed by the observing process, i.e. a previous entry for the process
contained in the Observer is overwritten. If you want multiple entries for a single process, just
combine several filter functions.
Since: 0.16.0
forgetObserver :: (SetMember Process (Process q) r, HasCallStack, Member Interrupts r, Typeable o, NFData o, EmbedProtocol x (ObserverRegistry o), TangiblePdu x Asynchronous) => Observer o -> Endpoint x -> Eff r () Source #
Send the ForgetObserver message
Since: 0.16.0
handleObservations :: (HasCallStack, Typeable o, SetMember Process (Process q) r, NFData (Observer o)) => (o -> Eff r ()) -> Pdu (Observer o) Asynchronous -> Eff r () Source #
Based on the Pdu instance for Observer this simplified writing
a callback handler for observations. In order to register to
and ObserverRegistry use toObserver.
Since: 0.16.0
toObserver :: TangibleObserver o => Endpoint (Observer o) -> Observer o Source #
Use a Endpoint as an Observer for handleObservations.
Since: 0.16.0
toObserverFor :: (TangibleObserver o, Typeable a, TangiblePdu a Asynchronous) => (o -> Pdu a Asynchronous) -> Endpoint a -> Observer o Source #
handleObserverRegistration :: forall o q r. (HasCallStack, Typeable o, SetMember Process (Process q) r, Member (ObserverState o) r, Member Logs r) => Pdu (ObserverRegistry o) Asynchronous -> Eff r () Source #
Provide the implementation for the ObserverRegistry Protocol, this handled RegisterObserver and ForgetObserver
messages. It also adds the ObserverState constraint to the effect list.
Since: 0.16.0
manageObservers :: Eff (ObserverState o ': r) a -> Eff r a Source #
Keep track of registered Observers.
Handle the ObserverState introduced by handleObserverRegistration.
Since: 0.16.0
emptyObservers :: Observers o Source #
The empty ObserverState
Since: 0.24.0
observed :: forall o r q. (SetMember Process (Process q) r, Member (ObserverState o) r, Member Interrupts r, TangibleObserver o) => o -> Eff r () Source #
Report an observation to all observers.
The process needs to manageObservers and to handleObserverRegistration.
Since: 0.16.0
type ObservationQueueReader a = Reader (ObservationQueue a) Source #
A Reader for an ObservationQueue.
data ObservationQueue a Source #
Contains a TBQueue capturing observations.
See spawnLinkObservationQueueWriter, readObservationQueue.
Instances
| (TangibleObserver o, TangiblePdu (Observer o) Asynchronous, Lifted IO q, Member Logs q) => Server (ObservationQueue o) q Source # | |
Defined in Control.Eff.Concurrent.Protocol.Observer.Queue Associated Types data StartArgument (ObservationQueue o) q :: Type Source # type Protocol (ObservationQueue o) :: Type Source # type Model (ObservationQueue o) :: Type Source # type Settings (ObservationQueue o) :: Type Source # Methods setup :: StartArgument (ObservationQueue o) q -> Eff (Processes q) (Model (ObservationQueue o), Settings (ObservationQueue o)) Source # update :: StartArgument (ObservationQueue o) q -> Event (Protocol (ObservationQueue o)) -> Eff (ModelState (ObservationQueue o) ': (SettingsReader (ObservationQueue o) ': Processes q)) () Source # | |
| data StartArgument (ObservationQueue o) q Source # | |
| type Protocol (ObservationQueue o) Source # | |
| type Model (ObservationQueue o) Source # | |
| type Settings (ObservationQueue o) Source # | |
readObservationQueue :: forall o r. (Member (ObservationQueueReader o) r, HasCallStack, MonadIO (Eff r), Typeable o, Member Logs r) => Eff r o Source #
Read queued observations captured and enqueued in the shared TBQueue by spawnLinkObservationQueueWriter.
This blocks until something was captured or an interrupt or exceptions was thrown. For a non-blocking
variant use tryReadObservationQueue or flushObservationQueue.
tryReadObservationQueue :: forall o r. (Member (ObservationQueueReader o) r, HasCallStack, MonadIO (Eff r), Typeable o, Member Logs r) => Eff r (Maybe o) Source #
Read queued observations captured and enqueued in the shared TBQueue by spawnLinkObservationQueueWriter.
Return the oldest enqueued observation immediately or Nothing if the queue is empty.
Use readObservationQueue to block until an observation is observed.
flushObservationQueue :: forall o r. (Member (ObservationQueueReader o) r, HasCallStack, MonadIO (Eff r), Typeable o, Member Logs r) => Eff r [o] Source #
Read at once all currently queued observations captured and enqueued
in the shared TBQueue by spawnLinkObservationQueueWriter.
This returns immediately all currently enqueued observations.
For a blocking variant use readObservationQueue.
withObservationQueue :: forall o b e len. (HasCallStack, Typeable o, Show o, Member Logs e, Lifted IO e, Integral len, Member Interrupts e) => len -> Eff (ObservationQueueReader o ': e) b -> Eff e b Source #
Create a mutable queue for observations. Use spawnLinkObservationQueueWriter for a simple way to get
a process that enqueues all observations.
Example
withObservationQueue 100 $ do q <- ask @(ObservationQueueReader TestEvent) wq <- spawnLinkObservationQueueWriter q registerObserver wq testServer ... cast testServer DoSomething evt <- readObservationQueue @TestEvent ...
Since: 0.18.0
spawnLinkObservationQueueWriter :: forall o q h. (TangibleObserver o, TangiblePdu (Observer o) Asynchronous, Member Logs q, Lifted IO q, LogsTo h (Processes q), HasCallStack) => ObservationQueue o -> Eff (Processes q) (Observer o) Source #
Spawn a process that can be used as an Observer that enqueues the observations into an
ObservationQueue. See withObservationQueue for an example.
The observations can be obtained by readObservationQueue. All observations are captured up to
the queue size limit, such that the first message received will be first message
returned by readObservationQueue.
Since: 0.18.0
type CaptureLogWriter = Writer LogMessage Source #
Alias for the Writer that contains the captured LogMessages from CaptureLogs.
newtype CaptureLogs a Source #
Constructors
| MkCaptureLogs | |
Fields
| |
Instances
runCaptureLogWriter :: Eff (CaptureLogWriter ': e) a -> Eff e (a, [LogMessage]) Source #
Run a Writer for LogMessages.
Such a Writer is needed to handle CaptureLogWriter
type LoggingAndIo = '[Logs, LogWriterReader IO, Lift IO] Source #
The concrete list of Effects for logging with an IO based LogWriter, and a LogWriterReader.
mkLogWriterIO :: HasCallStack => (LogMessage -> IO ()) -> LogWriter IO Source #
A LogWriter that uses an IO action to write the message.
This is just an alias for MkLogWriter but with IO as parameter. This reduces the need to
apply something to the extra type argument @IO.
Example use cases for this function are the consoleLogWriter and the ioHandleLogWriter.
ioHandleLogWriter :: HasCallStack => Handle -> LogWriter IO Source #
A LogWriter that renders LogMessages to strings via renderLogMessageConsoleLog
and prints them to an Handle using hPutStrLn.
Arguments
| :: SetMember Lift (Lift IO) e | |
| => LogWriter IO | The |
| -> Text | The default application name to put into the |
| -> Facility | The default RFC-5424 facility to put into the |
| -> LogPredicate | The inital predicate for log messages, there are some pre-defined in Control.Eff.Log.Message |
| -> Eff (Logs ': (LogWriterReader IO ': e)) a | |
| -> Eff e a |
Enable logging to IO using the defaultIoLogWriter.
Example:
exampleWithIoLogging :: IO ()
exampleWithIoLogging =
runLift
$ withIoLogging debugTraceLogWriter
"my-app"
local7
(lmSeverityIsAtLeast informationalSeverity)
$ logInfo "Oh, hi there"Arguments
| :: Text | The default application name to put into the |
| -> Facility | The default RFC-5424 facility to put into the |
| -> LogWriter IO | The IO based writer to decorate |
| -> LogWriter IO |
Decorate an IO based LogWriter to fill out these fields in LogMessages:
- The messages will carry the given application name in the
lmAppNamefield. - The
lmTimestampfield contains the UTC time of the log event - The
lmHostnamefield contains the FQDN of the current host - The
lmFacilityfield contains the givenFacility
It works by using mappingLogWriterM.
printLogMessage :: LogMessage -> IO () Source #
Render a LogMessage but set the timestamp and thread id fields.
Arguments
| :: (Lifted IO e, MonadBaseControl IO (Eff e)) | |
| => FilePath | Path to the log-file. |
| -> Text | The default application name to put into the |
| -> Facility | The default RFC-5424 facility to put into the |
| -> LogPredicate | The inital predicate for log messages, there are some pre-defined in Control.Eff.Log.Message |
| -> Eff (Logs ': (LogWriterReader IO ': e)) a | |
| -> Eff e a |
Enable logging to a file, with some LogMessage fields preset
as described in withIoLogging.
If the file or its directory does not exist, it will be created.
Example:
exampleWithFileLogging :: IO ()
exampleWithFileLogging =
runLift
$ withFileLogging "/var/log/my-app.log" "my-app" local7 allLogMessages
$ logInfo "Oh, hi there"To vary the LogWriter use withIoLogging.
Arguments
| :: (Lifted IO e, LogsTo IO e, MonadBaseControl IO (Eff e)) | |
| => FilePath | Path to the log-file. |
| -> Eff e b | |
| -> Eff e b |
Enable logging to a file.
If the file or its directory does not exist, it will be created. Example:
exampleWithFileLogWriter :: IO ()
exampleWithFileLogWriter =
runLift
$ withSomeLogging @IO
$ withFileLogWriter "test.log"
$ logInfo "Oh, hi there"Arguments
| :: Lifted IO e | |
| => Text | The default application name to put into the |
| -> Facility | The default RFC-5424 facility to put into the |
| -> LogPredicate | The inital predicate for log messages, there are some pre-defined in Control.Eff.Log.Message |
| -> Eff (Logs ': (LogWriterReader IO ': e)) a | |
| -> Eff e a |
Enable logging via traceM using the debugTraceLogWriter, with some LogMessage fields preset
as in withIoLogging.
Log messages are rendered using renderLogMessageConsoleLog.
Example:
exampleWithTraceLogging :: IO ()
exampleWithTraceLogging =
runLift
$ withTraceLogging "my-app" local7 allLogMessages
$ logInfo "Oh, hi there"withTraceLogWriter :: forall h e a. (Monad h, LogsTo h e) => Eff e a -> Eff e a Source #
Enable logging via traceM using the debugTraceLogWriter. The
logging monad type can be any type with a Monad instance.
Log messages are rendered using renderLogMessageConsoleLog.
Example:
exampleWithTraceLogWriter :: IO ()
exampleWithTraceLogWriter =
runLift
$ withSomeLogging @IO
$ withTraceLogWriter
$ logInfo "Oh, hi there"debugTraceLogWriter :: forall h. Monad h => LogMessageRenderer Text -> LogWriter h Source #
Write LogMessages via traceM.
Arguments
| :: Lifted IO e | |
| => Text | The default application name to put into the |
| -> Facility | The default RFC-5424 facility to put into the |
| -> LogPredicate | The inital predicate for log messages, there are some pre-defined in Control.Eff.Log.Message |
| -> Eff (Logs ': (LogWriterReader IO ': e)) a | |
| -> Eff e a |
Enable logging to standard output using the consoleLogWriter, with some LogMessage fields preset
as in withIoLogging.
Log messages are rendered using renderLogMessageConsoleLog.
Example:
exampleWithConsoleLogging :: IO ()
exampleWithConsoleLogging =
runLift
$ withConsoleLogging "my-app" local7 allLogMessages
$ logInfo "Oh, hi there"To vary the LogWriter use withIoLogging.
withConsoleLogWriter :: (LogsTo IO e, Lifted IO e) => Eff e a -> Eff e a Source #
Enable logging to standard output using the consoleLogWriter.
Log messages are rendered using renderLogMessageConsoleLog.
Example:
exampleWithConsoleLogWriter :: IO ()
exampleWithConsoleLogWriter =
runLift
$ withSomeLogging @IO
$ withConsoleLogWriter
$ logInfo "Oh, hi there"consoleLogWriter :: LogWriter IO Source #
Write LogMessages to standard output, formatted with printLogMessage.
It uses stdoutLogWriter with renderLogMessageConsoleLog.
stdoutLogWriter :: LogMessageRenderer Text -> LogWriter IO Source #
A LogWriter that uses a LogMessageRenderer to render, and putStrLn to print it.
Arguments
| :: (Lifted IO e, MonadBaseControl IO (Eff e), Integral len) | |
| => LogWriter IO | |
| -> len | Size of the log message input queue. If the queue is full, message are dropped silently. |
| -> Text | The default application name to put into the |
| -> Facility | The default RFC-5424 facility to put into the |
| -> LogPredicate | The inital predicate for log messages, there are some pre-defined in Control.Eff.Log.Message |
| -> Eff (Logs ': (LogWriterReader IO ': e)) a | |
| -> Eff e a |
This is a wrapper around withAsyncLogWriter and withIoLogging.
Example:
exampleWithAsyncLogging :: IO ()
exampleWithAsyncLogging =
runLift
$ withAsyncLogWriter consoleLogWriter (1000::Int) "my-app" local0 allLogMessages
$ do logMsg "test 1"
logMsg "test 2"
logMsg "test 3"
Arguments
| :: (LogsTo IO e, Lifted IO e, MonadBaseControl IO (Eff e), Integral len) | |
| => len | Size of the log message input queue. If the queue is full, message are dropped silently. |
| -> Eff e a | |
| -> Eff e a |
Move the current LogWriter into its own thread.
A bounded queue is used to forward logs to the process.
If an exception is received, the logging process will be killed.
Log messages are deeply evaluated before being sent to the logger process, to prevent that lazy evaluation leads to heavy work being done in the logger process instead of the caller process.
Example:
exampleAsyncLogWriter :: IO ()
exampleAsyncLogWriter =
runLift
$ withLogging consoleLogWriter
$ withAsyncLogWriter (1000::Int)
$ do logMsg "test 1"
logMsg "test 2"
logMsg "test 3"
Arguments
| :: (HasCallStack, MonadBaseControl IO (Eff e), Lifted IO e) | |
| => (LogMessage -> Text) |
|
| -> String | Hostname or IP |
| -> String | Port e.g. |
| -> Text | The default application name to put into the |
| -> Facility | The default RFC-5424 facility to put into the |
| -> LogPredicate | The inital predicate for log messages, there are some pre-defined in Control.Eff.Log.Message |
| -> Eff (Logs ': (LogWriterReader IO ': e)) a | |
| -> Eff e a |
Enable logging to a remote host via UDP, with some LogMessage fields preset
as in withIoLogging.
Arguments
| :: (Lifted IO e, LogsTo IO e, MonadBaseControl IO (Eff e), HasCallStack) | |
| => (LogMessage -> Text) |
|
| -> String | Hostname or IP |
| -> String | Port e.g. |
| -> Eff e b | |
| -> Eff e b |
Enable logging to a (remote-) host via UDP.
withUnixSocketLogging Source #
Arguments
| :: (HasCallStack, MonadBaseControl IO (Eff e), Lifted IO e) | |
| => LogMessageRenderer Text |
|
| -> FilePath | Path to the socket file |
| -> Text | The default application name to put into the |
| -> Facility | The default RFC-5424 facility to put into the |
| -> LogPredicate | The inital predicate for log messages, there are some pre-defined in Control.Eff.Log.Message |
| -> Eff (Logs ': (LogWriterReader IO ': e)) a | |
| -> Eff e a |
Enable logging to a unix domain socket, with some LogMessage fields preset
as in withIoLogging.
withUnixSocketLogWriter Source #
Arguments
| :: (Lifted IO e, LogsTo IO e, MonadBaseControl IO (Eff e), HasCallStack) | |
| => LogMessageRenderer Text |
|
| -> FilePath | Path to the socket file |
| -> Eff e b | |
| -> Eff e b |
Enable logging to a (remote-) host via UnixSocket.
foreverCheap :: Monad m => m a -> m () Source #
A version of forever that hopefully tricks
GHC into not creating a space leak.
The intuition is, that we want to do something that is cheap, and hence
should be recomputed instead of shared.
Since: 0.4.0.0
replicateCheapM_ :: Monad m => Int -> m a -> m () Source #
A version of replicateM_ that hopefully tricks
GHC into not creating a space leak.
The intuition is, that we want to do something that is cheap, and hence
should be recomputed instead of shared.
Since: 0.4.0.0
Scheduler
schedule :: HasCallStack => LogWriter IO -> Eff Effects a -> IO (Either (Interrupt NoRecovery) a) Source #
Run the Effects using a single threaded, coroutine based, scheduler
from Control.Eff.Concurrent.Process.SingleThreadedScheduler.
Since: 0.25.0
defaultMain :: HasCallStack => Eff EffectsIo () -> IO () Source #
Execute a Process using scheduleM on top of Lift IO.
All logging is written to the console using consoleLogWriter.
To use another LogWriter use defaultMainWithLogWriter instead.
defaultMainWithLogWriter :: HasCallStack => LogWriter IO -> Eff EffectsIo () -> IO () Source #
type SafeEffects = SafeEffectsIo Source #
The effect list for Process effects in the single threaded scheduler.
This is like SafeProcesses, no Interrupts are present.
See SafeEffectsIo
Since: 0.25.0
type BaseEffects = BaseEffectsIo Source #
type HasBaseEffects e = HasBaseEffectsIo e Source #