Ertugrul Soeylemez writes: > I find myself writing the following very often: > > system :: Wire IO () String > system = > proc _ -> do > botAddPeriod <- succ ^<< noise -< () > botAddSpeed <- noise1 -< () > botAddStart <- noise1 -< () > botMsg <- event addBot -< (botAddPeriod, botAddSpeed, botAddStart) > > bots <- manager -< ((), maybe MgrNop id botMsg) > let botStr = concatMap (printf "%8.2") . M.elems $ bots :: String > identity -< printf "Bot positions: %s" botStr > > where > addBot :: Wire IO (Double, Double, Double) (MgrMsg Int IO () Double) > addBot = > proc (addPeriod, addSpeed, addStart) -> do > periodically -< addPeriod > botId <- identifier -< () > identity -< MgrAdd botId (constant addSpeed >>> integral > addStart)
If addPeriod is supposed to be the same as botAddPeriod, etc, this should be equivalent: system :: Wire IO () String system = proc _ -> do addPeriod <- succ ^<< noise -< () addSpeed <- noise1 -< () addStart <- noise1 -< () botMsg <- (|event (do periodically -< addPeriod botId <- identifier -< () identity -< MgrAdd botId (constant addSpeed >>> integral addStart))|) bots <- manager -< ((), maybe MgrNop id botMsg) let botStr = concatMap (printf "%8.2") . M.elems $ bots :: String identity -< printf "Bot positions: %s" botStr See the GHC Arrow notation documentation for more about the banana brackets, which let you use user-defined control structures like event. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe