packages feed

epass 0.1.1 → 0.2.1

raw patch · 6 files changed

+44/−16 lines, 6 filesdep +stmdep ~basePVP ok

version bump matches the API change (PVP)

Dependencies added: stm

Dependency ranges changed: base

API changes (from Hackage documentation)

Files

+ CHANGES view
@@ -0,0 +1,15 @@+0.2 -> 0.2.1+    * Replaced deprected Prelude.catch by Control.Exception.catch.++0.1.2 -> 0.2+    * Supports GHC-7.0.* and GHC-7.2.1+    * Using Haskell2010+    * Default MailBox implementation now uses TChan+    * Removed some warnings++0.1.1 -> 0.1.2++0.1 -> 0.1.1+    * Updated demo+    * Works with time == 1.1.* || == 1.2.*+
demo/TestClient.hs view
@@ -1,3 +1,5 @@+{-# OPTIONS_GHC -fno-warn-incomplete-patterns #-}+ module Main where  import Message@@ -20,7 +22,7 @@                  (\ _ e -> inBox <! (MsgError $ show e))      loop inBox outBox 1-    mapM close [inBox, outBox]+    mapM_ close [inBox, outBox]     hClose hdl  loop :: MailboxClass mb => mb Message -> mb Message -> Int -> IO ()
demo/TestServer.hs view
@@ -1,3 +1,5 @@+{-# OPTIONS_GHC -fno-warn-incomplete-patterns #-}+ module Main where  import Message@@ -18,7 +20,7 @@                  (\ _ e -> inBox <! (MsgError $ show e))      loop inBox outBox-    mapM close [inBox, outBox]+    mapM_ close [inBox, outBox]     hClose hdl  loop :: MailboxClass mb => mb Message -> mb Message -> IO ()@@ -34,9 +36,9 @@         ] $ receiveTimeout inBox 1000                 [ \ (MsgError e) -> handler $                         putStrLn $ "received error: " ++ e-                , \ (m@(M (n + 1))) -> handler $ do+                , \ (m@(M n)) -> handler $ do                     putStrLn $ "Matched " ++ show m ++ " within timeout."-                    outBox <! M (n * 2)+                    outBox <! M ((n - 1) * 2)                     loop inBox outBox                 , \ m -> handler $ do                     print m
epass.cabal view
@@ -1,5 +1,5 @@ Name:          epass-Version:       0.1.1+Version:       0.2.1 Stability:     Alpha Synopsis:      Baisc, Erlang-like message passing supporting sockets. Description:   This package provides Erlang-like mailboxes for message passing.@@ -12,11 +12,12 @@ Homepage:      http://github.com/baldo/epass Bug-Reports:   http://github.com/baldo/epass/issues Category:      Concurrency, Network-Tested-With:   GHC == 6.12.3-Cabal-Version: >= 1.8+Tested-With:   GHC == 7.0.3+Cabal-Version: >= 1.10  Extra-Source-Files:     Setup.hs+    CHANGES     CONTRIB     README     demo/Message.hs@@ -28,8 +29,12 @@     Location: git://github.com/baldo/epass.git  Library+    Default-Language:+        Haskell2010+     Build-Depends:-        base == 4.*,+        base >= 4.3 && < 4.5,+        stm == 2.2.*,         time == 1.1.* || == 1.2.*      Ghc-Options:
src/Control/Concurrent/Mailbox.hs view
@@ -40,7 +40,8 @@  import Prelude hiding (catch) -import Control.Concurrent+import Control.Concurrent (yield)+import Control.Concurrent.STM import Control.Exception hiding (Handler) import Data.Time import System.Timeout@@ -86,18 +87,18 @@         -> IO ()  -- | A 'Chan' based mailbox.-newtype Mailbox m = MBox { unMBox :: Chan m }+newtype Mailbox m = MBox (TChan m)  -- | Creates a new mailbox. newMailbox :: IO (Mailbox m)-newMailbox = fmap MBox newChan+newMailbox = fmap MBox newTChanIO  instance MailboxClass Mailbox where-    getMessage   = readChan    . unMBox-    unGetMessage = unGetChan   . unMBox-    putMessage   = writeChan   . unMBox-    isEmpty      = isEmptyChan . unMBox-    close        = const $ return ()+    getMessage   (MBox chan)     = atomically $ readTChan chan+    unGetMessage (MBox chan) msg = atomically $ unGetTChan chan msg+    putMessage   (MBox chan) msg = atomically $ writeTChan chan msg+    isEmpty      (MBox chan)     = atomically $ isEmptyTChan chan+    close        _               = return ()   -- Sending messages ------------------------------------------------------------
src/Control/Concurrent/Mailbox/Wrapper.hs view
@@ -15,9 +15,12 @@     ) where +import Prelude hiding (catch)+ import Control.Concurrent.Mailbox  import Control.Concurrent+import Control.Exception import System.IO