Last active
August 22, 2019 04:13
-
-
Save jfischoff/75079af9e82c27bf944f8f3352ebc075 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
-- What I am struggling to do is sequence to looping things. First I have a loop where the output is feed into the | |
-- next step as input until it completes. Then the next loop starts. | |
-- I doubt this works ... I'm trying to test it now ... anyway I don't like it and feel like | |
-- there must be an easier way. | |
advance :: (Adjustable t m, MonadHold t m, Monad m, MonadFix m) | |
=> m (Event t (Maybe a)) | |
-- ^ initial | |
-> (a -> m (Event t (Maybe a))) | |
-- loop step | |
-> (forall void. a -> m void) | |
-- next loop ... probably never returns | |
-> m () | |
advance initial loopStep next = do | |
rec out <- networkHold initial $ ffor (updated out) $ \e -> do | |
rec delayed <- networkHold (delayOne e) $ ffor (switch $ current delayed) $ \case | |
(Just x , _) -> fmap (, Just x) <$> loopStep x | |
(Nothing, Just x) -> next x | |
(Nothing, Nothing) -> error "impossible" | |
pure never | |
pure () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment