Safe Haskell | None |
---|---|
Language | Haskell2010 |
An EDSL designed to make writing deadpan applications easy!
This DSL is a simple decoration of some application specific functions arround an RWST monad instance.
TODO: Check that this is still correct...
type deadpanapp a = Control.Monad.Rws.Rwst network.websockets.connection () callbackset io a
A core cabal of functions are exported from this module which are then put to use in web.ddp.deadpan to create an expressive dsl for creating ddp applications.
The main functions exported are...
TODO: Ensure these are up to date...
- rundeadpan
- sethandler
- deletehandler
- setdefaulthandler
- senddata
- sendmessage
these allow you to...
- run a deadpan application with some initial set of callbacks
- set new values for response handlers
- delete existing response handlers
- set a handler to act when no existing handler matches the incomming message
- send an ejsonvalue to the server (low-level)
- send messages to be interpreted as rpc calls
... respectively.
There is also a `control.lens.lens` collections
provided into a single ejsonvalue.
This can be used to...
- Retrieve any current collection data
- Set collection data manually
- Perform actions on collection data in callbacks
- type Lookup a = Map Text a
- data AppState cb = AppState {
- _defaultCallback :: cb
- _callbackSet :: Lookup cb
- _collections :: TVar EJsonValue
- defaultCallback :: forall cb. Lens' (AppState cb) cb
- collections :: forall cb. Lens' (AppState cb) (TVar EJsonValue)
- callbackSet :: forall cb. Lens' (AppState cb) (Lookup cb)
- type Callback = EJsonValue -> DeadpanApp ()
- newtype DeadpanApp a = DeadpanApp {
- _deadpanApp :: RWST Connection () (AppState Callback) IO a
- deadpanApp :: forall a a. Iso (DeadpanApp a) (DeadpanApp a) (RWST Connection () (AppState Callback) IO a) (RWST Connection () (AppState Callback) IO a)
- runDeadpan :: DeadpanApp a -> Connection -> AppState Callback -> IO (a, AppState Callback)
- setHandler :: Text -> Callback -> DeadpanApp ()
- deleteHandler :: Text -> DeadpanApp ()
- setDefaultHandler :: Callback -> DeadpanApp ()
- sendData :: EJsonValue -> DeadpanApp ()
- sendMessage :: Text -> EJsonValue -> DeadpanApp ()
- getAppState :: DeadpanApp (AppState Callback)
- connect :: DeadpanApp ()
- fork :: DeadpanApp a -> DeadpanApp ()
- setup :: DeadpanApp ()
- getServerMessage :: DeadpanApp (Maybe EJsonValue)
- respondToMessage :: Lookup Callback -> Callback -> Maybe EJsonValue -> DeadpanApp ()
- module Data.EJson
- module Data.EJson.Prism
- module Data.Text
Documentation
AppState | |
|
defaultCallback :: forall cb. Lens' (AppState cb) cb Source
collections :: forall cb. Lens' (AppState cb) (TVar EJsonValue) Source
callbackSet :: forall cb. Lens' (AppState cb) (Lookup cb) Source
type Callback = EJsonValue -> DeadpanApp () Source
newtype DeadpanApp a Source
DeadpanApp | |
|
deadpanApp :: forall a a. Iso (DeadpanApp a) (DeadpanApp a) (RWST Connection () (AppState Callback) IO a) (RWST Connection () (AppState Callback) IO a) Source
runDeadpan :: DeadpanApp a -> Connection -> AppState Callback -> IO (a, AppState Callback) Source
The order of these args match that of runRWST
setHandler :: Text -> Callback -> DeadpanApp () Source
deleteHandler :: Text -> DeadpanApp () Source
setDefaultHandler :: Callback -> DeadpanApp () Source
sendData :: EJsonValue -> DeadpanApp () Source
A low-level function intended to be able to send any arbitrary data to the server.
Given that all messages to the server are intended to fit the "message" format,
You should probably use sendMessage
instead.
TODO: Decide if this should perform the request in a seperate thread...
sendMessage :: Text -> EJsonValue -> DeadpanApp () Source
Send a particular type of message (indicated by the key) to the server. This should be the primary means of [client -> server] communication by a client application.
connect :: DeadpanApp () Source
fork :: DeadpanApp a -> DeadpanApp () Source
Provides a way to fork a background thread running the app provided TODO: Consider returning the thread-id
setup :: DeadpanApp () Source
respondToMessage :: Lookup Callback -> Callback -> Maybe EJsonValue -> DeadpanApp () Source
module Data.EJson
module Data.EJson.Prism
module Data.Text