Last active
August 29, 2015 14:22
-
-
Save Forkk/fd2517217d6c962ec7ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | Sample an auto's output when a blip stream outputs something. | |
-- | |
-- Takes two autos, one which outputs a some value, and another which outputs a | |
-- blip stream. Produces an auto which outputs a blip with the contents of the | |
-- first auto whenever the blip stream outputs. | |
sample :: forall m a b c. (Monad m) => | |
Auto m a c | |
-> Auto m a (Blip b) | |
-> Auto m a (Blip (b, c)) | |
sample valueAuto blipAuto = onJusts <<< arr extractMaybe <<< ((asMaybes <<< blipAuto) &&& valueAuto) | |
where | |
extractMaybe :: (Maybe b, c) -> Maybe (b, c) | |
extractMaybe (Just b, c) = Just (b, c) | |
extractMaybe _ = Nothing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Functor
instance forBlip
is usually handy :)