-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Simpler interface to the websockets api
--   
--   Simpler interface to the websockets api
@package websockets-simple
@version 0.0.6.3

module Network.WebSockets.Simple
data WebSocketsAppParams send m
WebSocketsAppParams :: (send -> m ()) -> m () -> WebSocketsAppParams send m
[send] :: WebSocketsAppParams send m -> send -> m ()
[close] :: WebSocketsAppParams send m -> m ()
data WebSocketsApp send receive m
WebSocketsApp :: (WebSocketsAppParams send m -> m ()) -> (WebSocketsAppParams send m -> receive -> m ()) -> (Maybe (Word16, ByteString) -> m ()) -> WebSocketsApp send receive m
[onOpen] :: WebSocketsApp send receive m -> WebSocketsAppParams send m -> m ()
[onReceive] :: WebSocketsApp send receive m -> WebSocketsAppParams send m -> receive -> m ()

-- | Either was a clean close, with <a>CloseRequest</a> params, or was
--   unclean. Note that to implement backoff strategies, you should catch
--   your <a>ConnectionException</a> <i>outside</i> this simple app, and
--   only after you've <a>runClient</a> or server, because the
--   <a>Connection</a> will be different.
[onClose] :: WebSocketsApp send receive m -> Maybe (Word16, ByteString) -> m ()
hoistWebSocketsApp :: (forall a. m a -> n a) -> (forall a. n a -> m a) -> WebSocketsApp send receive m -> WebSocketsApp send receive n

-- | This can throw a <a>WebSocketSimpleError</a> when json parsing fails.
--   However, do note: the <a>onOpen</a> is called once, but is still
--   forked when called. Likewise, the <a>onReceive</a> function is called
--   <i>every time</i> a (parsable) response is received from the other
--   party, and is forked on every invocation.
toClientAppT :: forall send receive m. (ToJSON send, FromJSON receive, MonadBaseControl IO m, MonadThrow m, MonadCatch m) => WebSocketsApp send receive m -> ClientAppT m (Maybe WebSocketsAppThreads)
toClientAppT' :: (ToJSON send, FromJSON receive, MonadBaseControl IO m, MonadThrow m, MonadCatch m) => WebSocketsApp send receive m -> ClientAppT m ()
toServerAppT :: (ToJSON send, FromJSON receive, MonadBaseControl IO m, MonadThrow m, MonadCatch m) => WebSocketsApp send receive m -> ServerAppT m

-- | A simple backoff strategy, which (per second), will increasingly delay
--   at <tt>2^soFar</tt>, until <tt>soFar &gt;= 5minutes</tt>, where it
--   will then routinely poll every 5 minutes.
expBackoffStrategy :: forall m a. (MonadBaseControl IO m, MonadCatch m) => m a -> m a
data WebSocketSimpleError
JSONParseError :: ByteString -> WebSocketSimpleError
data WebSocketsAppThreads
WebSocketsAppThreads :: Async () -> TChan (Async ()) -> WebSocketsAppThreads
[onOpenThread] :: WebSocketsAppThreads -> Async ()
[onReceiveThreads] :: WebSocketsAppThreads -> TChan (Async ())
instance GHC.Show.Show Network.WebSockets.Simple.WebSocketSimpleError
instance GHC.Classes.Eq Network.WebSockets.Simple.WebSocketSimpleError
instance GHC.Generics.Generic Network.WebSockets.Simple.WebSocketSimpleError
instance GHC.Generics.Generic (Network.WebSockets.Simple.WebSocketsApp send receive m)
instance GHC.Generics.Generic (Network.WebSockets.Simple.WebSocketsAppParams send m)
instance GHC.Exception.Exception Network.WebSockets.Simple.WebSocketSimpleError

module Network.WebSockets.Simple.PingPong
newtype PingPong a
PingPong :: Maybe a -> PingPong a
[getPingPong] :: PingPong a -> Maybe a

-- | Assumes <tt>a</tt> isn't an <a>Array</a> of anything

-- | Assumes <tt>a</tt> isn't an <a>Array</a> of anything
pingPong :: (MonadBaseControl IO m) => Int -> WebSocketsApp send receive m -> m (WebSocketsApp (PingPong send) (PingPong receive) m)
instance Data.Aeson.Types.ToJSON.ToJSON a => Data.Aeson.Types.ToJSON.ToJSON (Network.WebSockets.Simple.PingPong.PingPong a)
instance Data.Aeson.Types.FromJSON.FromJSON a => Data.Aeson.Types.FromJSON.FromJSON (Network.WebSockets.Simple.PingPong.PingPong a)

module Test.WebSockets.Simple

-- | Runs two <a>WebSocketsApp</a>s together in a forged channel.
runConnected :: forall send receive m. (MonadIO m, MonadBaseControl IO m) => WebSocketsApp send receive m -> WebSocketsApp receive send m -> m (Async (), Async (), TChan send, TChan receive)
