packages feed

zre-0.1.0.0: app/Monadic.hs

{-# LANGUAGE OverloadedStrings #-}
module Main where

import Control.Monad (forever)
import Control.Monad.IO.Class
import Control.Concurrent
import Control.Concurrent.Async.Lifted

import Network.ZRE

main :: IO ()
main = runZre app

app :: ZRE ((), ())
app = (recv `concurrently` act)
  where
    recv = dump
    act = ohaivololo

-- shouts ohai vololo for group, then one vololo per second, forever
ohaivololo :: ZRE ()
ohaivololo = do
  let group = "chat"
  zjoin group
  zshout group "ohai"
  forever $ do
    zshout group "vololo"
    liftIO $ threadDelay 1000000

dump :: ZRE ()
dump = forever $ do
  e <- readZ
  case e of
--    (Message ZREMsg{ msgCmd=(Shout _ content) })  -> liftIO $ B.putStrLn $ B.concat content
    x -> liftIO $ print x
    --_ -> return ()