Skip to content

Instantly share code, notes, and snippets.

@sarkologist
Last active August 9, 2018 14:28
Show Gist options
  • Save sarkologist/6ff701c994b9da0c4c44486bad32716d to your computer and use it in GitHub Desktop.
Save sarkologist/6ff701c994b9da0c4c44486bad32716d to your computer and use it in GitHub Desktop.
convert ScanM to Pipe
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