packages feed

yesod-websockets-extra (empty) → 0.1.0.0

raw patch · 4 files changed

+106/−0 lines, 4 filesdep +basedep +enclosed-exceptionsdep +transformerssetup-changed

Dependencies added: base, enclosed-exceptions, transformers, websockets, yesod-websockets

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2015, Marcin Tolysz++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Marcin Tolysz nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ src/Yesod/WebSockets/Extra.hs view
@@ -0,0 +1,46 @@++module Yesod.WebSockets.Extra where++import Prelude+import qualified Network.WebSockets             as WS++import Yesod.WebSockets++import Control.Monad.Trans.Reader     (ReaderT (ReaderT))+import Control.Exception (SomeException)+import Control.Exception.Enclosed (tryAny)+import Control.Monad.IO.Class++wrapWSE :: (MonadIO m, WS.WebSocketsData a) => (WS.Connection -> a -> IO ())-> a -> WebSocketsT m (Either SomeException ())+wrapWSE ws x = ReaderT $ liftIO . tryAny . flip ws x++wrapWS :: (MonadIO m, WS.WebSocketsData a) => (WS.Connection -> a -> IO ()) -> a -> WebSocketsT m ()+wrapWS ws x = ReaderT $ liftIO . flip ws x++sendPing :: (MonadIO m, WS.WebSocketsData a) => a -> WebSocketsT m ()+sendPing = wrapWS WS.sendPing++sendPingE :: (MonadIO m, WS.WebSocketsData a) => a -> WebSocketsT m (Either SomeException ())+sendPingE = wrapWSE WS.sendPing++sendClose :: (MonadIO m, WS.WebSocketsData a) => a -> WebSocketsT m ()+sendClose = wrapWS WS.sendClose++sendCloseE :: (MonadIO m, WS.WebSocketsData a) => a -> WebSocketsT m (Either SomeException ())+sendCloseE = wrapWSE WS.sendClose++sendTextDataE :: (MonadIO m, WS.WebSocketsData a) => a -> WebSocketsT m (Either SomeException ())+sendTextDataE = wrapWSE WS.sendTextData++-- Binary+sendBinaryDataE :: (MonadIO m, WS.WebSocketsData a) => a -> WebSocketsT m (Either SomeException ())+sendBinaryDataE = wrapWSE WS.sendBinaryData++receiveDataE :: (MonadIO m, WS.WebSocketsData a) => WebSocketsT m (Either SomeException a)+receiveDataE = ReaderT $ liftIO . tryAny . WS.receiveData++sendDataMessageE :: (MonadIO m) => WS.DataMessage -> WebSocketsT m (Either SomeException ())+sendDataMessageE x = ReaderT $ liftIO . tryAny . (`WS.sendDataMessage` x)++receiveDataMessageE :: (MonadIO m) => WebSocketsT m (Either SomeException WS.DataMessage)+receiveDataMessageE = ReaderT $ liftIO . tryAny . WS.receiveDataMessage
+ yesod-websockets-extra.cabal view
@@ -0,0 +1,28 @@+-- Initial yesod-websockets-extra.cabal generated by cabal init.  For +-- further documentation, see http://haskell.org/cabal/users-guide/++name:                yesod-websockets-extra+version:             0.1.0.0+synopsis:            Extension to yesod-websockets+description:         Adding exceptions to ws handling+license:             BSD3+license-file:        LICENSE+author:              Marcin Tolysz+maintainer:          tolysz@gmail.com+-- copyright:           +category:            Web+build-type:          Simple+-- extra-source-files:  +cabal-version:       >=1.10++library+  exposed-modules:     Yesod.WebSockets.Extra+  -- other-modules:       +  -- other-extensions:    +  build-depends:       base >=4.7 && <5+               ,       yesod-websockets+               ,       websockets+               ,       transformers+               ,       enclosed-exceptions+  hs-source-dirs:      src+  default-language:    Haskell2010