summaryrefslogtreecommitdiff
path: root/lore/Control/Concurrent/Go.hs
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2019-02-24 12:36:48 -0800
committerBen Sima <ben@bsima.me>2019-02-24 12:36:48 -0800
commitf36371f324ca85100590438e45d186c9704b8140 (patch)
tree4df1254a491748776bc32f06674848b39381ae64 /lore/Control/Concurrent/Go.hs
parentaee2750000526b0cdd658aadaf7d7500ff881ed3 (diff)
Organize/document lore modules a bit
Diffstat (limited to 'lore/Control/Concurrent/Go.hs')
-rw-r--r--lore/Control/Concurrent/Go.hs13
1 files changed, 7 insertions, 6 deletions
diff --git a/lore/Control/Concurrent/Go.hs b/lore/Control/Concurrent/Go.hs
index 05626d7..69ce9ed 100644
--- a/lore/Control/Concurrent/Go.hs
+++ b/lore/Control/Concurrent/Go.hs
@@ -70,6 +70,7 @@ go = forkIO
{- Example: (TODO: move to module-level docs)
+-- can I just implement forM/Traversable over the channel?
forRange :: TChan (Maybe a) -> (a -> IO b) -> IO [b]
forRange ch fn = helper fn [] where
-- I could not get Intero or ghc to accept a type-annotation for the helper function,
@@ -83,19 +84,19 @@ forRange ch fn = helper fn [] where
b <- fn v
helper fn (b : acc)
-generate :: (Num a, Enum a) => TChan (Maybe a) -> IO ()
-generate ch = do
+feedData :: (Num a, Enum a) => TChan (Maybe a) -> IO ()
+feedData ch = do
forM_ [1 .. 9999] (\x -> writeCh ch (Just x))
writeQ ch Nothing -- EOF value
-process :: TChan (Maybe Int) -> IO ()
-process c = do
+printData :: TChan (Maybe Int) -> IO ()
+printData c = do
forRange c (print :: Int -> IO ())
return ()
main :: IO ()
main = do
ch <- chan
- go $ generate ch
- process ch
+ go $ feedData ch
+ printData ch
-}