netwire 4.0.6 → 4.0.7
raw patch · 5 files changed
+72/−3 lines, 5 files
Files
- Control/Wire/Prefab.hs +2/−0
- Control/Wire/Prefab/Event.hs +3/−1
- Control/Wire/Prefab/List.hs +36/−0
- Control/Wire/Wire.hs +29/−1
- netwire.cabal +2/−1
Control/Wire/Prefab.hs view
@@ -12,6 +12,7 @@ module Control.Wire.Prefab.Analyze, module Control.Wire.Prefab.Effect, module Control.Wire.Prefab.Event,+ module Control.Wire.Prefab.List, module Control.Wire.Prefab.Move, module Control.Wire.Prefab.Noise, module Control.Wire.Prefab.Queue,@@ -25,6 +26,7 @@ import Control.Wire.Prefab.Analyze import Control.Wire.Prefab.Effect import Control.Wire.Prefab.Event+import Control.Wire.Prefab.List import Control.Wire.Prefab.Move import Control.Wire.Prefab.Noise import Control.Wire.Prefab.Queue
Control/Wire/Prefab/Event.hs view
@@ -184,7 +184,9 @@ | otherwise = mkPure $ \_ x -> (Right x, forI (t - 1)) --- | Inhibit with the given value.+-- | Inhibit with the given value. You may want to use a combination of+-- 'Control.Applicative.empty' and 'Control.Wire.Trans.Event.<!>'+-- instead. -- -- * Inhibits: always.
+ Control/Wire/Prefab/List.hs view
@@ -0,0 +1,36 @@+-- |+-- Module: Control.Wire.Prefab.List+-- Copyright: (c) 2012 Ertugrul Soeylemez+-- License: BSD3+-- Maintainer: Ertugrul Soeylemez <es@ertes.de>+--+-- Wires from lists.++module Control.Wire.Prefab.List+ ( -- * Wires from lists+ cycleW,+ list+ )+ where++import Control.Applicative+import Control.Monad.Fix+import Control.Wire.Wire+import Data.Monoid+++-- | Produce the values in the given list cycling forever.+--+-- * Inhibits: when the argument list is empty.++cycleW :: (Monad m, Monoid e) => [b] -> Wire e m a b+cycleW [] = empty+cycleW xs = fix (\again -> foldr cons again xs)+++-- | Produce the values in the given list and then inhibit forever.+--+-- * Inhibits: when the list is exhausted.++list :: (Monad m, Monoid e) => [b] -> Wire e m a b+list = foldr cons empty
Control/Wire/Wire.hs view
@@ -21,7 +21,9 @@ constant, identity, never,- -- ** Helper functions+ -- ** Simple predefined combinators+ cons,+ fixW, mapOutput, -- * Stepping@@ -253,6 +255,19 @@ (*^) = liftA2 (*^) +-- | Wire cons. Prepend the given value to the wire's output stream.+-- This function is infixr like (':').+--+-- * Depends: like argument wire after the first instant.+--+-- * Inhibits: like argument wire after the first instant.++cons :: b -> Wire e m a b -> Wire e m a b+cons x xs = mkPure (\_ _ -> (Right x, xs))++infixr 5 `cons`++ -- | Variant of 'pure' without the 'Monad' constraint. Using 'pure' is -- preferable. @@ -260,8 +275,21 @@ constant = mkFix . const . const . Right +-- | Convenience combinator for the common case of feedback where you+-- ignore the input and produce the feedback value itself with 'loop'.+--+-- * Depends: like looped argument wire.+--+-- * Inhibits: when argument wire inhibits.++fixW :: (MonadFix m) => Wire e m b b -> Wire e m a b+fixW = loop . fmap (\x -> (x, x)) . lmap snd++ -- | Variant of 'id' without the 'Monad' constraint. Using 'id' is -- preferable.+--+-- * Depends: current instant. identity :: Wire e m a a identity = WPure (\_ x -> (Right x, identity))
netwire.cabal view
@@ -1,5 +1,5 @@ Name: netwire-Version: 4.0.6+Version: 4.0.7 Category: Control, FRP Synopsis: Flexible wire arrows for FRP Maintainer: Ertugrul Söylemez <es@ertes.de>@@ -53,6 +53,7 @@ Control.Wire.Prefab.Analyze Control.Wire.Prefab.Effect Control.Wire.Prefab.Event+ Control.Wire.Prefab.List Control.Wire.Prefab.Move Control.Wire.Prefab.Noise Control.Wire.Prefab.Queue