Permalink
Browse files

Review and compiled with ghc 7.4.1

  • Loading branch information...
1 parent e1a950b commit 0b91c65442700c98e56c846c1d9860ae84c45f2e @toschoo committed May 12, 2012
View
@@ -35,13 +35,13 @@ run:
$(TDIR)/basic
$(TDIR)/device
-$(TDIR)/enum: $(TDIR)/enum.hs $(SUBSRC)
+$(TDIR)/enum: $(TDIR)/enum.hs $(TDIR)/Common.hs $(SUBSRC)
$(GHC) $(FLGS) $(INC) $@
-$(TDIR)/basic: $(TDIR)/basic.hs $(SUBSRC)
+$(TDIR)/basic: $(TDIR)/basic.hs $(TDIR)/Common.hs $(SUBSRC)
$(GHC) $(FLGS) $(INC) $@
-$(TDIR)/device: $(TDIR)/device.hs $(SUBSRC)
+$(TDIR)/device: $(TDIR)/device.hs $(TDIR)/Common.hs $(SUBSRC)
$(GHC) $(FLGS) $(INC) $@
smoke: $(SMOKEDIR)/db \
@@ -1,6 +1,10 @@
module Main
where
+ ------------------------------------------------------------------------
+ -- Playing ping pong
+ ------------------------------------------------------------------------
+
import Network.Mom.Patterns
import qualified Data.Enumerator as E
import qualified Data.ByteString.Char8 as B
@@ -1,6 +1,10 @@
module Main
where
+ ------------------------------------------------------------------------
+ -- Simple puller
+ ------------------------------------------------------------------------
+
import Helper (getOs, address, onErr_,
output, untilInterrupt)
import Network.Mom.Patterns
@@ -1,6 +1,10 @@
module Main
where
+ ------------------------------------------------------------------------
+ -- Simple sporadic subscriber (just writing to stdout)
+ ------------------------------------------------------------------------
+
import Helper (getOs, address, untilInterrupt)
import Network.Mom.Patterns
import qualified Data.ByteString.Char8 as B
@@ -1,6 +1,10 @@
module Main
where
+ ------------------------------------------------------------------------
+ -- Simple weather report subscriber
+ ------------------------------------------------------------------------
+
import Helper (getOs, address, output, onErr_, untilInterrupt)
import Network.Mom.Patterns
import qualified Data.ByteString.Char8 as B
@@ -1,5 +1,9 @@
module Main
where
+
+ ------------------------------------------------------------------------
+ -- Simple weather report subscriber that writes to a file
+ ------------------------------------------------------------------------
import Helper (getOs, address, untilInterrupt, onErr_)
import Network.Mom.Patterns
@@ -1,6 +1,10 @@
module Main
where
+ ------------------------------------------------------------------------
+ -- Simple weather report publisher, using "issue"
+ ------------------------------------------------------------------------
+
import Helper (getOs, address)
import Network.Mom.Patterns
@@ -1,6 +1,10 @@
module Main
where
+ ------------------------------------------------------------------------
+ -- Simple weather report publisher
+ ------------------------------------------------------------------------
+
import Helper(getOs, address, untilInterrupt, onErr_)
import Network.Mom.Patterns
import qualified Data.ByteString.Char8 as B
@@ -1,6 +1,11 @@
module Main
where
+ ------------------------------------------------------------------------
+ -- Reads data from a database table (ignoring client input)
+ -- and sends the data back, one message per row
+ ------------------------------------------------------------------------
+
import Helper (getOs, address, onErr,
dbFetcher, untilInterrupt)
import Network.Mom.Patterns
@@ -13,7 +18,9 @@ where
main = do
(l, p, _) <- getOs
withContext 1 $ \ctx -> do
- c <- connectODBC "DSN=jose"
+ c <- connectODBC "DSN=jose" -- jose is a chess database
+ -- here, we use ODBC to connect
+ -- to a mysql server
s <- prepare c "select Id, substr(Name, 1, 30) Name from Player"
withServer ctx "Player" noparam 5
(address l "tcp" "localhost" p []) l
@@ -25,4 +32,20 @@ where
iconv :: InBound [SqlValue]
iconv = return . convRow . B.unpack
where convRow :: String -> [SqlValue]
- convRow _ = [] -- no input parameter, in fact
+ convRow _ = []
+
+ ------------------------------------------------------------------------
+ -- ODBC example configuration (/etc/odbc.ini)
+ ------------------------------------------------------------------------
+ -- [jose]
+ -- Driver = /usr/lib/i386-linux-gnu/odbc/libmyodbc.so
+ -- Description = MyODBC 3.51 Driver DSN
+ -- SERVER = localhost
+ -- PORT =
+ -- USER = jose
+ -- Password = jose
+ -- Database = jose
+ -- OPTION = 3
+ -- SOCKET =
+ ------------------------------------------------------------------------
+
@@ -1,7 +1,7 @@
module Main
where
------------------------------------------------------------------------
- -- Sends the poem "Stopping by Woods on a Snowy Evening on request
+ -- Sends the poem "Stopping by Woods on a Snowy Evening" on request
------------------------------------------------------------------------
import Helper (getOs, address, onErr,
@@ -1,6 +1,14 @@
module Main
where
+ ------------------------------------------------------------------------
+ -- Device that sends data streams coming from a connected publisher
+ -- to all connected subscribers;
+ -- subscribers can be connected and removed through the "ifc" program.
+ -- The program cannot be stopped by the INT signal.
+ -- Instead, it is stopped by using the "stop" command with ifc.
+ ------------------------------------------------------------------------
+
import Command
import Helper (getPorts, address, onErr_, onErr)
import Network.Mom.Patterns
@@ -1,6 +1,10 @@
module Main
where
+ ------------------------------------------------------------------------
+ -- A simple forwarder (Publisher -> Subscriber)
+ ------------------------------------------------------------------------
+
import Helper (getPorts, address, untilInterrupt, onErr_)
import Network.Mom.Patterns
import Control.Concurrent
@@ -1,6 +1,10 @@
module Main
where
+ ------------------------------------------------------------------------
+ -- Client to send commands to the "fork" program
+ ------------------------------------------------------------------------
+
import Command
import Helper
import Network.Mom.Patterns
@@ -1,6 +1,10 @@
module Main
where
+ ------------------------------------------------------------------------
+ -- A simple pipeline (pusher -> puller)
+ ------------------------------------------------------------------------
+
import Helper (getPorts, address, onErr_, untilInterrupt)
import Network.Mom.Patterns
import Control.Concurrent
@@ -1,6 +1,10 @@
module Main
where
+ ------------------------------------------------------------------------
+ -- Simple queue (client <-> server)
+ ------------------------------------------------------------------------
+
import Helper (getPorts, untilInterrupt, address, onErr_)
import Network.Mom.Patterns
import Control.Concurrent
@@ -1,24 +1,23 @@
Name: patterns
-Version: 0.0.2
-Cabal-Version: >= 1.8
+Version: 0.0.3
+Cabal-Version: >= 1.14.0
Copyright: Copyright (c) Tobias Schoofs, 2011 - 2012
License: LGPL
license-file: license/lgpl-3.0.txt
Author: Tobias Schoofs
Maintainer: tobias dot schoofs at gmx dot net
Category: Network, Message-oriented Middleware, zeromq
-Homepage: http://github.com/toschoo/mom/src/patterns
+Homepage: http://github.com/toschoo/mom
Build-Type: Simple
Synopsis: Common patterns in message-oriented applications
Description:
- There are common patterns often reused
- - or, in fact, reimplemented,
- in many distributed, message-oriented applications,
+ In distributed, message-oriented applications,
+ similar communication patterns are used over and over again,
such as Server\/Client (a.k.a Request\/Response),
- Publish\/Subscribe,
- Pipline (a.k.a. Push\/Pull) and
- Exclusive Pair (a.k.a. Peer-to-Peer).
+ Publish\/Subscribe,
+ Pipline (a.k.a. Push\/Pull) and
+ Exclusive Pair (a.k.a. Peer-to-Peer).
The Patterns package implements those patterns based on zeromq.
More information on zeromq can be found at
@@ -28,14 +27,16 @@ Description:
on <http://github.com/toschoo/mom>.
Library
- Build-Depends: base >= 4.0 && <= 5.0,
- bytestring >= 0.9.1.9,
- utf8-string >= 0.3.6,
- containers >= 0.3.0.0,
- zeromq-haskell >= 0.8.3,
- enumerator >= 0.4.11,
+ Build-Depends: base >= 4.5 && <= 5.0,
+ bytestring >= 0.9.2.1,
+ utf8-string >= 0.3.7,
+ containers >= 0.4.2.1,
+ zeromq-haskell >= 0.8.4,
+ enumerator >= 0.4.18,
mtl >= 2.0.1.0,
- time >= 1.1.4
+ time >= 1.4
+
+ default-language: Haskell98
hs-source-dirs: src/Network/Mom, src
@@ -1,4 +1,3 @@
-{-# OPTIONS -fglasgow-exts -fno-cse #-}
module Factory (
mkUniqueId)
where
@@ -212,8 +212,8 @@ where
(String -> E.Iteratee c IO i) ->
Fetch i o ->
(Service -> IO a) -> IO a
- withServer ctx name param n ac t iconv oconv onerr build fetch action =
- withService ctx name param service action
+ withServer ctx name param n ac t iconv oconv onerr build fetch =
+ withService ctx name param service
where service = serve n ac t iconv oconv onerr
build fetch
@@ -633,8 +633,8 @@ where
OnError_ ->
Fetch_ o ->
(Service -> IO a) -> IO a
- withPeriodicPub ctx name param period ac oconv onerr fetch action =
- withService ctx name param service action
+ withPeriodicPub ctx name param period ac oconv onerr fetch =
+ withService ctx name param service
where service = publish period ac oconv onerr fetch
------------------------------------------------------------------------
@@ -728,8 +728,8 @@ where
InBound i -> OnError_ ->
Dump i ->
(Service -> IO a) -> IO a
- withSub ctx name param sub ac iconv onErr dump action =
- withService ctx name param service action
+ withSub ctx name param sub ac iconv onErr dump =
+ withService ctx name param service
where service = subscribe sub ac iconv onErr dump
subscribe :: [Topic] ->
@@ -893,8 +893,8 @@ where
OnError_ ->
Dump i ->
(Service -> IO a) -> IO a
- withPuller ctx name param ac iconv onerr dump action =
- withService ctx name param service action
+ withPuller ctx name param ac iconv onerr dump =
+ withService ctx name param service
where service = pull ac iconv onerr dump
pull :: AccessPoint ->
@@ -89,8 +89,8 @@ where
(Parameter -> OnTimeout) ->
(Parameter -> Transformer o) ->
(Service -> IO a) -> IO a
- withDevice ctx name param tmo acs iconv oconv onerr ontmo trans action =
- withService ctx name param service action
+ withDevice ctx name param tmo acs iconv oconv onerr ontmo trans =
+ withService ctx name param service
where service = device_ tmo acs iconv oconv onerr ontmo trans
------------------------------------------------------------------------
Oops, something went wrong.

0 comments on commit 0b91c65

Please sign in to comment.