Add missing haddocks.
[haskell-cryptsy-api.git] / src / Cryptsy / API / Public.hs
blob2bdccefe9eb1ac0d1c49ad0c00c8bb128bdf3557
1 -- |Re-exports the entire Cryptsy.API.Public.* heirarchy.
2 module Cryptsy.API.Public
3 ( module Cryptsy.API.Public.Types
4 , module Cryptsy.API.Public.MarketData.Old
5 , module Cryptsy.API.Public.MarketData.New
6 , module Cryptsy.API.Public.Market
7 , module Cryptsy.API.Public.OrderData
8 , module Cryptsy.API.Public.OrderBook
9 , defaultEvalPubCryptsy
10 , defaultRunPubCryptsy
12 where
14 -- base
15 import Data.Maybe (fromMaybe)
16 import Data.Monoid (mempty)
18 -- either
19 import Control.Monad.Trans.Either (runEitherT)
21 -- http-client
22 import Network.HTTP.Client (CookieJar, withManager)
24 -- http-client-tls
25 import Network.HTTP.Client.TLS (tlsManagerSettings)
27 -- transformers
28 import Control.Monad.Trans.Reader (runReaderT)
29 import Control.Monad.Trans.State (runStateT)
31 -- this package
32 import Cryptsy.API.Public.Market
33 import Cryptsy.API.Public.MarketData.New
34 import Cryptsy.API.Public.MarketData.Old
35 import Cryptsy.API.Public.OrderBook
36 import Cryptsy.API.Public.OrderData
37 import Cryptsy.API.Public.Types
39 {-|
40 Like 'defaultRunPubCryptsy', but the resulting cookir jar is ignored.
42 defaultEvalPubCryptsy :: PubCryptsy a -> IO (Either CryptsyError a)
43 defaultEvalPubCryptsy = fmap fst . defaultRunPubCryptsy
44 {-# INLINABLE defaultEvalPubCryptsy #-}
46 {-|
47 Converts a public cryptsy action to an action in the IO Monad, using a new
48 manager created from 'tlsManagerSettings' and closed as the last part of the IO
49 action and starting from an empty cookie jar. Both the resulting cookie jar
50 and either the resolt of the public cryptsy action or the first cryptsy error
51 encountered are the results of the IO action.
53 defaultRunPubCryptsy :: PubCryptsy a -> IO (Either CryptsyError a, CookieJar)
54 defaultRunPubCryptsy = withManager tlsManagerSettings
55 . (defaultRunInReader .) . runReaderT
56 where
57 defaultRunInReader = fmap (msnd (fromMaybe mempty)) . ($ Just mempty)
58 . runStateT . runEitherT
59 msnd f (x, y) = (x, f y)
60 {-# INLINABLE defaultRunPubCryptsy #-}