| Copyright | (c) Moritz Angermann 2014 |
|---|---|
| License | MIT |
| Maintainer | moritz@lichtzwerge.de |
| Stability | stable |
| Portability | portable |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Network.Service
Description
A service is an endpoint that can receive and send messages.
- class ServiceMessage a where
- toBS :: a -> ByteString
- fromBS :: ByteString -> a
- data Service a = Service {}
- type ServiceHandler a = Service a -> IO ()
Documentation
class ServiceMessage a where Source
Services operate on Messages, the ServiceMessage class abstracts the serialization.
Methods
Arguments
| :: a | |
| -> ByteString | serialization to ByteString representation |
Arguments
| :: ByteString | |
| -> a | deserialization from ByteString representation |
A Service of a certain Message data.
type ServiceHandler a = Service a -> IO () Source
A handler takes a service and returns an IO action.
The idea is that a service handler will run a service
a simple echo handler might look like the following:
handler service = do { msg <- sRecv service
; sSend service msg
; isDone <- sDone service
; unless isDone (handler service)
}