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 a ReaderT monad instance.
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
- data LookupItem a = LI {}
- messageType :: forall a. Lens' (LookupItem a) (Maybe Text)
- ident :: forall a. Lens' (LookupItem a) (Maybe Text)
- body :: forall a a. Lens (LookupItem a) (LookupItem a) a a
- type Lookup a = [LookupItem a]
- data AppState cb = AppState {}
- connection :: forall cb. Lens' (AppState cb) Connection
- collections :: forall cb. Lens' (AppState cb) EJsonValue
- callbackSet :: forall cb cb. Lens (AppState cb) (AppState cb) (Lookup cb) (Lookup cb)
- type Callback = EJsonValue -> DeadpanApp ()
- newtype DeadpanApp a = DeadpanApp {}
- deadpanApp :: forall a a. Iso (DeadpanApp a) (DeadpanApp a) (ReaderT (TVar (AppState Callback)) IO a) (ReaderT (TVar (AppState Callback)) IO a)
- runDeadpan :: DeadpanApp a -> TVar (AppState Callback) -> IO a
- setHandler :: LookupItem Callback -> DeadpanApp ()
- setIdHandler :: Text -> Callback -> DeadpanApp ()
- setMsgHandler :: Text -> Callback -> DeadpanApp ()
- setCatchAllHandler :: Callback -> DeadpanApp ()
- deleteHandlerID :: Text -> DeadpanApp ()
- modifyAppState :: (AppState Callback -> AppState Callback) -> DeadpanApp ()
- getAppState :: DeadpanApp (AppState Callback)
- sendData :: EJsonValue -> DeadpanApp ()
- sendMessage :: Text -> EJsonValue -> DeadpanApp ()
- connect :: DeadpanApp ()
- fork :: DeadpanApp a -> DeadpanApp ThreadId
- fetchMessages :: DeadpanApp ()
- getServerMessage :: DeadpanApp (Maybe EJsonValue)
- (=?) :: Eq a => Maybe a -> Maybe a -> Bool
- respondToMessage :: Lookup Callback -> Maybe EJsonValue -> DeadpanApp ()
- module Data.EJson
- data Text :: *
- pack :: String -> Text
Documentation
data LookupItem a Source
The LookupItem data-type is used to store a set of callbacks If ident, or messageType are set, then the callback will only be called if these fields match.
messageType :: forall a. Lens' (LookupItem a) (Maybe Text) Source
body :: forall a a. Lens (LookupItem a) (LookupItem a) a a Source
type Lookup a = [LookupItem a] Source
AppState | |
|
connection :: forall cb. Lens' (AppState cb) Connection Source
collections :: forall cb. Lens' (AppState cb) EJsonValue Source
type Callback = EJsonValue -> DeadpanApp () Source
newtype DeadpanApp a Source
deadpanApp :: forall a a. Iso (DeadpanApp a) (DeadpanApp a) (ReaderT (TVar (AppState Callback)) IO a) (ReaderT (TVar (AppState Callback)) IO a) Source
runDeadpan :: DeadpanApp a -> TVar (AppState Callback) -> IO a Source
The order of these args match that of runReaderT
setHandler :: LookupItem Callback -> DeadpanApp () Source
setIdHandler :: Text -> Callback -> DeadpanApp () Source
setMsgHandler :: Text -> Callback -> DeadpanApp () Source
setCatchAllHandler :: Callback -> DeadpanApp () Source
deleteHandlerID :: Text -> DeadpanApp () Source
modifyAppState :: (AppState Callback -> AppState 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 ThreadId Source
Provides a way to fork a background thread running the app provided
fetchMessages :: DeadpanApp () Source
respondToMessage :: Lookup Callback -> Maybe EJsonValue -> DeadpanApp () Source
module Data.EJson
data Text :: *
A space efficient, packed, unboxed Unicode text type.
IsList Text | |
Eq Text | |
Data Text | This instance preserves data abstraction at the cost of inefficiency. We omit reflection services for the sake of data abstraction. This instance was created by copying the updated behavior of
The original discussion is archived here: could we get a Data instance for Data.Text.Text? The followup discussion that changed the behavior of |
Ord Text | |
Read Text | |
Show Text | |
IsString Text | |
ToJSON Text | |
FromJSON Text | |
Chunk Text | |
Monoid Text | |
NFData Text | |
Hashable Text | |
Semigroup Text | |
Ixed Text | |
WebSocketsData Text | |
Typeable * Text | |
Convertible Text Text | |
Convertible Text Text | |
Strict Text Text | |
Convertible Text [Char] | |
Convertible [Char] Text | |
ToJSON v => ToJSON (HashMap Text v) | |
ToJSON v => ToJSON (Map Text v) | |
FromJSON v => FromJSON (HashMap Text v) | |
FromJSON v => FromJSON (Map Text v) | |
type State Text = Buffer | |
type ChunkElem Text = Char | |
type Item Text = Char | |
type Index Text = Int | |
type IxValue Text = Char |