Deadpan-DDP-0.4.1.0: Write clients for Meteor's DDP Protocol

Safe HaskellNone
LanguageHaskell2010

Web.DDP.Deadpan.DSL

Description

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

Synopsis

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.

Constructors

LI 

ident :: 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

data AppState cb Source

Constructors

AppState 

Fields

_callbackSet :: Lookup cb

Callbacks to match against by message

_collections :: EJsonValue

Shared data Expected to be an EJObject

_connection :: Connection

Network connection to server

callbackSet :: forall cb cb. Lens (AppState cb) (AppState cb) (Lookup cb) (Lookup cb) Source

runDeadpan :: DeadpanApp a -> TVar (AppState Callback) -> IO a Source

The order of these args match that of runReaderT

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.

fork :: DeadpanApp a -> DeadpanApp ThreadId Source

Provides a way to fork a background thread running the app provided

(=?) :: Eq a => Maybe a -> Maybe a -> Bool Source

module Data.EJson

data Text :: *

A space efficient, packed, unboxed Unicode text type.

Instances

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 Data.Set.Set and Data.Map.Map. If you feel a mistake has been made, please feel free to submit improvements.

The original discussion is archived here: could we get a Data instance for Data.Text.Text?

The followup discussion that changed the behavior of Set and Map is archived here: Proposal: Allow gunfold for Data.Map, ...

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 

pack :: String -> Text

O(n) Convert a String into a Text. Subject to fusion. Performs replacement on invalid scalar values.