Skip to content

Instantly share code, notes, and snippets.

@michaelt
Created October 13, 2015 01:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelt/242f6a23267707ad29e9 to your computer and use it in GitHub Desktop.
Save michaelt/242f6a23267707ad29e9 to your computer and use it in GitHub Desktop.
Hello world.
import Streaming
import qualified Streaming.Prelude as S
import Control.Monad
main = do
S.effects (hilo 30 )
putStrLn "Right, 30 is correct!"
hilo :: Int -> Stream (Of Int) IO ()
hilo n = void $ S.break (== n)
$ S.chain (\a -> when (a < n) $ putStrLn $ "Too small!")
$ S.chain (\a -> when (a > n) $ putStrLn $ "Too big!")
$ S.map snd
$ S.zip (S.cycle $ do lift (putStrLn "\nEnter a number")
S.yield ())
$ S.delay 0.1
$ S.readLn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment