Update haddock

This commit is contained in:
Joscha 2020-01-22 15:05:59 +00:00
parent 1dc97fcc4c
commit 5fe8294a09
2 changed files with 25 additions and 8 deletions

View file

@ -1,5 +1,7 @@
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
-- | This module attempts to map the structure of the ephoria API to types.
module Haboli.Euphoria.Api module Haboli.Euphoria.Api
( ToJSONObject(..) ( ToJSONObject(..)
-- * Basic types -- * Basic types
@ -75,6 +77,8 @@ import qualified Data.Text as T
import Data.Time import Data.Time
import Data.Time.Clock.POSIX import Data.Time.Clock.POSIX
-- | A class for all types that can be converted into an 'Data.Aeson.Object'.
-- Similar to 'ToJSON', but more restrictive.
class ToJSONObject a where class ToJSONObject a where
toJSONObject :: a -> Object toJSONObject :: a -> Object
@ -94,8 +98,9 @@ toPacket packetType packetData = HMap.fromList
{- Basic types -} {- Basic types -}
-- | A method of authenticating.
data AuthOption = Passcode data AuthOption = Passcode
deriving (Show) deriving (Show, Eq)
instance ToJSON AuthOption where instance ToJSON AuthOption where
toJSON Passcode = String "passcode" toJSON Passcode = String "passcode"

View file

@ -3,6 +3,18 @@
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-} {-# LANGUAGE RankNTypes #-}
-- | This library is based around the custom 'Client' monad. It is based on 'IO'
-- and represents computations that happen while a connection to an euphoria
-- server is open. Once a 'Client' finishes executing, the connection is
-- automatically closed. If the connection closes unexpectedly while the
-- corresponding 'Client' is still running, it is notified and commands like
-- 'send' or 'nick' will result in an exception. The 'Client' does not
-- automatically reconnect.
--
-- The 'Client' monad supports exceptions via the 'throw', 'catch' and 'handle'
-- operations, as well as multiple threads via the 'fork' and 'wait' operations.
-- It supports all session and chat room commands listed in <api.euphoria.io>.
module Haboli.Euphoria.Client module Haboli.Euphoria.Client
( (
-- * The Client monad -- * The Client monad
@ -64,9 +76,9 @@ import qualified Wuss as WSS
import Haboli.Euphoria.Api import Haboli.Euphoria.Api
-- | This type represents a @'Reply' e r@ with arbitrary @r@ that has yet to be -- | This type represents a @Reply e r@ with arbitrary @r@ that has yet to be
-- received. The @forall@ allows whoever creates the 'AwaitingReply' to decide -- received. The @forall@ allows whoever creates the AwaitingReply to decide on
-- on the type of @r@. -- the type of @r@.
data AwaitingReply e data AwaitingReply e
= forall r. FromJSON r => AwaitingReply (TMVar (Reply e r)) = forall r. FromJSON r => AwaitingReply (TMVar (Reply e r))
@ -121,8 +133,8 @@ closeConnectionOnInvalidMessage connection (WS.UnicodeException _) =
closeConnectionOnInvalidMessage _ e = E.throwIO e closeConnectionOnInvalidMessage _ e = E.throwIO e
-- | An exception handler that stops the client if any sort of -- | An exception handler that stops the client if any sort of
-- 'WS.ConnectionException' occurs. It does this by setting 'ciStopped' to True -- 'WS.ConnectionException' occurs. It does this by setting ciStopped to True
-- and cancelling all 'AwaitingReply'-s in 'ciAwaiting'. -- and cancelling all AwaitingReply-s in ciAwaiting.
cancelAllReplies :: ClientInfo e -> WS.ConnectionException -> IO () cancelAllReplies :: ClientInfo e -> WS.ConnectionException -> IO ()
cancelAllReplies info _ = atomically $ do cancelAllReplies info _ = atomically $ do
writeTVar (ciStopped info) True writeTVar (ciStopped info) True
@ -195,8 +207,8 @@ defaultConfig = ConnectionConfig
, confPingInterval = 10 , confPingInterval = 10
} }
-- | @'withRoom' roomname config@ modifies the 'cdPath' of @config@ to point to -- | @'withRoom' roomname config@ modifies the 'confPath' of @config@ to point
-- the room @roomname@. -- to the room @roomname@.
withRoom :: String -> ConnectionConfig -> ConnectionConfig withRoom :: String -> ConnectionConfig -> ConnectionConfig
withRoom room config = config{confPath = "/room/" ++ room ++ "/ws"} withRoom room config = config{confPath = "/room/" ++ room ++ "/ws"}