module Control.Wire.Trans.Simple
(
WOverrideInput(..),
(>--)
)
where
import Control.Arrow
import Control.Wire.Types
class Arrow (>~) => WOverrideInput (>~) where
(--<) :: Arrow (>~) => Wire e (>~) a b -> (a -> a) -> Wire e (>~) a b
infixr 5 --<
instance Monad m => WOverrideInput (Kleisli m) where
WmPure f --< g =
WmPure $ \x' ->
let (mx, w) = f (g x') in
(mx, either (const $ w --< g) (const w) mx)
WmGen c --< g =
WmGen $ \x' -> do
(mx, w) <- c (g x')
return (mx, either (const $ w --< g) (const w) mx)
(>--) :: WOverrideInput (>~) => (a -> a) -> Wire e (>~) a b -> Wire e (>~) a b
(>--) = flip (--<)
infixl 5 >--