module Control.Wire.Trans.Exhibit
(
event,
exhibit
)
where
import Control.Arrow
import Control.Wire.Types
event :: Arrow (>~) => Wire e (>~) a b -> Wire e (>~) a (Maybe b)
event (WPure f) =
mkPure $ \(f -> (mx, w)) ->
(Right $ either (const Nothing) Just mx, event w)
event (WGen c) =
mkGen $ proc x' -> do
(mx, w) <- c -< x'
returnA -< (Right $ either (const Nothing) Just mx, event w)
exhibit :: Arrow (>~) => Wire e (>~) a b -> Wire e (>~) a (Either e b)
exhibit (WPure f) =
mkPure $ \(f -> (mx, w)) ->
(Right mx, exhibit w)
exhibit (WGen c) =
mkGen $ proc x' -> do
(mx, w) <- c -< x'
returnA -< (Right mx, exhibit w)