packages feed

extensible-effects-concurrent 0.24.1 → 0.24.2

raw patch · 5 files changed

+70/−23 lines, 5 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Control.Eff.Concurrent.Protocol.Request: embedReplySerializer :: EmbedProtocol outer inner => Serializer (Reply outer reply) -> Serializer (Reply inner reply)
+ Control.Eff.Concurrent.Protocol.Request: embedRequestOrigin :: EmbedProtocol outer inner => RequestOrigin inner reply -> RequestOrigin outer reply
- Control.Eff.Concurrent: fromEndpoint :: forall protocol_aRHv protocol_aRV1. Iso (Endpoint protocol_aRHv) (Endpoint protocol_aRV1) ProcessId ProcessId
+ Control.Eff.Concurrent: fromEndpoint :: forall protocol_aRHy protocol_aRV4. Iso (Endpoint protocol_aRHy) (Endpoint protocol_aRV4) ProcessId ProcessId
- Control.Eff.Concurrent.Protocol: fromEndpoint :: forall protocol_aRHv protocol_aRV1. Iso (Endpoint protocol_aRHv) (Endpoint protocol_aRV1) ProcessId ProcessId
+ Control.Eff.Concurrent.Protocol: fromEndpoint :: forall protocol_aRHy protocol_aRV4. Iso (Endpoint protocol_aRHy) (Endpoint protocol_aRV4) ProcessId ProcessId

Files

ChangeLog.md view
@@ -1,19 +1,11 @@ # Changelog for extensible-effects-concurrent -## Plan for future Versions--- Put timing into pure processes!-- Every `Api` type instance now **must** be an `NFData` -  and a `ToLogText` instance-- `call` will always require a `Timeout`-- `call` now monitors the caller-- `call` now monitors the called process-- `call` now returns `Either TimeoutError a`   --- Logging improvements:-    - Introduce `ToLogText`-    - Remove `ToLogMessage`-    - Remove `logXXX'` users have to use `logXXX` and `ToLogText` +## 0.24.2+- Add more `EmbedProtocol` related functions:+    - `embedReplySerializer`+    - `embedRequestOrigin`+- Improve documentation for `EffectfulServer`     +- Improve documentation for `StatefulServer`       ## 0.24.1 
extensible-effects-concurrent.cabal view
@@ -1,6 +1,6 @@ cabal-version:  2.0 name:           extensible-effects-concurrent-version:        0.24.1+version:        0.24.2 description:    Please see the README on GitHub at <https://github.com/sheyll/extensible-effects-concurrent#readme> synopsis:       Message passing concurrency as extensible-effect homepage:       https://github.com/sheyll/extensible-effects-concurrent#readme
src/Control/Eff/Concurrent/Protocol/EffectfulServer.hs view
@@ -1,4 +1,4 @@--- | A better, more safe implementation of the Erlang/OTP gen_server behaviour.+-- | Utilities to implement /effectful server-loops/. -- -- @since 0.24.0 module Control.Eff.Concurrent.Protocol.EffectfulServer@@ -36,8 +36,16 @@ import qualified Data.Text as T import GHC.Stack (HasCallStack) --- | A type class for building supervised processes, that handle 'Event's--- with 'Request's for 'Pdu' instance.+-- | A type class for effectful server loops.+--+-- This type class serves as interface for other abstractions, for example /process supervision/+--+-- The methods of this class handle 'Event's 'Request's for 'Pdu' instance.+--+-- Instances can by /index types/ for 'Pdu' family directly, or indirectly via the 'ServerPdu' type family.+--+-- To builder servers serving multiple protocols, use the generic 'Pdu' instances, for which 'EmbedProtocol'+-- instances exist, like 2-,3-,4-, or 5-tuple. -- -- @since 0.24.1 class Server (a :: Type) (e :: [Type -> Type])
src/Control/Eff/Concurrent/Protocol/Request.hs view
@@ -5,7 +5,9 @@   ( Request(..)   , sendReply   , RequestOrigin(..)+  , embedRequestOrigin   , Reply(..)+  , embedReplySerializer   , makeRequestOrigin   )   where@@ -16,6 +18,7 @@ import Control.Eff.Concurrent.Protocol import Data.Kind (Type) import Data.Typeable (Typeable)+import Data.Functor.Contravariant import GHC.Generics  -- | A wrapper sum type for calls and casts for the 'Pdu's of a protocol@@ -89,15 +92,49 @@  instance NFData (RequestOrigin p r) - -- | Send a 'Reply' to a 'Call'. -- -- The reply will be deeply evaluated to 'rnf'. --+-- To send replies for 'EmbedProtocol' instances use 'embedReplySerializer'.+-- -- @since 0.15.0 sendReply ::      (SetMember Process (Process q) eff, Member Interrupts eff, Tangible reply, Typeable protocol)   => Serializer (Reply protocol reply) -> RequestOrigin protocol reply -> reply -> Eff eff () sendReply ser o r = sendAnyMessage (_requestOriginPid o) $! runSerializer ser $! Reply o r +-- | Turn an /embedded/ 'RequestOrigin' to a 'RequestOrigin' for the /bigger/ request.+--+-- This function is strict in all parameters.+--+-- This is useful of a server delegates the @calls@ and @casts@ for an embedded protocol+-- to functions, that require the 'Serializer' and 'RequestOrigin' in order to call+-- 'sendReply'.+--+-- See also 'embedReplySerializer'.+--+-- @since 0.24.2+embedRequestOrigin :: EmbedProtocol outer inner => RequestOrigin inner reply -> RequestOrigin outer reply+embedRequestOrigin (RequestOrigin !pid !ref) = RequestOrigin pid ref +-- | Turn a 'Serializer' for a 'Pdu' instance that contains embedded 'Pdu' values+-- into a 'Reply' 'Serializer' for the embedded 'Pdu'.+--+-- This is useful of a server delegates the @calls@ and @casts@ for an embedded protocol+-- to functions, that require the 'Serializer' and 'RequestOrigin' in order to call+-- 'sendReply'.+--+-- See also 'embedRequestOrigin'.+--+-- @since 0.24.2+embedReplySerializer :: EmbedProtocol outer inner => Serializer (Reply outer reply) -> Serializer (Reply inner reply)+embedReplySerializer = contramap embedReply++-- | Turn an /embedded/ 'Reply' to a 'Reply' for the /bigger/ request.+--+-- This function is strict in all parameters.+--+-- @since 0.24.2+embedReply :: EmbedProtocol outer inner => Reply inner reply -> Reply outer reply+embedReply (Reply (RequestOrigin !pid !ref) !v) = Reply (RequestOrigin pid ref) v
src/Control/Eff/Concurrent/Protocol/StatefulServer.hs view
@@ -1,4 +1,4 @@--- | A better, more safe implementation of the Erlang/OTP gen_server behaviour.+-- | Utilities to implement /server-loops/ with builtin state and /TEA/-like naming. -- -- @since 0.24.0 module Control.Eff.Concurrent.Protocol.StatefulServer@@ -40,11 +40,21 @@ import Data.Typeable import GHC.Stack (HasCallStack) --- | A class for 'Stateful' server processes.+-- | A type class for server loops. ----- This is inspired by The Elm Architecture, without the @view@ callback.+-- This type class serves as interface for other abstractions, for example /process supervision/ ----- This can be used for a variety of typical server loop implementations.+-- The methods of this class handle 'Event's 'Request's for 'Pdu' instance.+--+-- Instances can by /index types/ for 'Pdu' family directly, or indirectly via the 'ServerPdu' type family.+--+-- To builder servers serving multiple protocols, use the generic 'Pdu' instances, for which 'EmbedProtocol'+-- instances exist, like 2-,3-,4-, or 5-tuple.+--+-- The naming is inspired by The Elm Architecture, without the @view@ callback.+--+-- This class is based on "Control.Eff.Concurrent.Protocol.EffectfulServer" and adds a default+-- 'State' and 'Reader' effect. -- -- @since 0.24.0 class (Typeable (Protocol a)) => Server (a :: Type) q where