Copyright | (c) Anton Gushcha, 2015-2016 |
---|---|
License | BSD3 |
Maintainer | ncrashed@gmail.com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
- class Typeable objectId => ActorMessage objectId where
- type ActorMessageType objectId :: *
- fromCounter :: Int -> objectId
- toCounter :: objectId -> Int
- actorFingerprint :: forall proxy a. ActorMessage a => proxy a -> HashableTypeRep
Documentation
class Typeable objectId => ActorMessage objectId where Source
The typeclass separates message API's of different type of actors
In general you don't want to have one global type to handle all possible types of messages, it will break modularity. Thats why you creates (with newtype) separate types of ids for each actor and statically binds message type (usually algebraic type) to the id.
The class implies that your id is some integer type, but it could be not. Just provide way to stable convertion of you id to integer and vice-versa.
type ActorMessageType objectId :: * Source
Binded message type, mailbox with id type of objectId would accept only this message type
actorFingerprint :: forall proxy a. ActorMessage a => proxy a -> HashableTypeRep Source
Returns hashable fingerprint of actor that is stable across applications (unique by type name)