Last active
August 9, 2018 14:28
-
-
Save sarkologist/6ff701c994b9da0c4c44486bad32716d to your computer and use it in GitHub Desktop.
convert ScanM to Pipe
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
import Control.Scanl | |
import Pipes | |
import Pipes.Lift | |
scanMToPipe :: (Monad m) => ScanM m a b -> Pipe a b m () | |
scanMToPipe (ScanM step initial) = | |
let pipe = do | |
a <- await | |
b <- lift $ step a | |
yield b | |
pipe | |
in lift initial >>= flip evalStateP pipe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment