hzulip 1.0.0.0 → 1.1.0.0
raw patch · 2 files changed
+17/−11 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Web.HZulip: addAllSubscriptions :: ZulipM ()
Files
- hzulip.cabal +5/−1
- src/Web/HZulip.hs +12/−10
hzulip.cabal view
@@ -1,5 +1,5 @@ name: hzulip-version: 1.0.0.0+version: 1.1.0.0 synopsis: A haskell wrapper for the Zulip API. description: This a Zulip API wrapper for Haskell. homepage: https://github.com/yamadapc/hzulip@@ -11,6 +11,10 @@ category: Web build-type: Simple cabal-version: >=1.10++source-repository head+ type: git+ location: git://github.com/yamadapc/hzulip.git library exposed-modules: Web.HZulip
src/Web/HZulip.hs view
@@ -39,7 +39,7 @@ -- > -- complex patterns for concurrent message handling can be created -- > -- from it. As long as your zulip user is already subscribed to -- > -- streams, this is all you have to do:--- > onNewEvent ["message"] $ \msg -> do+-- > onNewMessage $ \msg -> do -- > liftIO $ putStrLn "Got a new message!" -- > let usr = messageSender msg -- > fn = userFullName usr@@ -55,6 +55,7 @@ , EventCallback , MessageCallback , addSubscriptions+ , addAllSubscriptions , defaultBaseUrl , eventTypes , getEvents@@ -76,10 +77,8 @@ where import Control.Arrow (second)-import Control.Concurrent (threadDelay) import Control.Lens ((^..)) import Control.Monad (void)-import Control.Monad.Catch (SomeException, handleAll) import Control.Monad.IO.Class (liftIO) import Control.Monad.Trans.Reader (ask, runReaderT) import Data.Aeson (decode)@@ -209,6 +208,11 @@ . key "name" . _String -- |+-- Subscribes the client to all streams+addAllSubscriptions :: ZulipM ()+addAllSubscriptions = getStreams >>= addSubscriptions++-- | -- Add new Stream subscriptions to the client. addSubscriptions :: [String] -> ZulipM () addSubscriptions sbs = do@@ -239,16 +243,14 @@ -- | -- Registers an event callback for specified events and keeps executing it--- over events as they come in. Will loop forever+-- over events as they come in onNewEvent :: [String] -> EventCallback -> ZulipM () onNewEvent etypes f = do q <- registerQueue etypes False- handleAll (tryAgain q) (loop q)- where tryAgain :: Queue -> SomeException -> ZulipM ()- tryAgain q _ = do- liftIO (threadDelay 1000000)- handleAll (tryAgain q) (loop q)- loop q = getEvents q False >>=+ -- We let it fail here, so that failures can be catched and handled by+ -- the user+ loop q+ where loop q = getEvents q False >>= \(q', evts) -> mapM_ f evts >> loop q'