Created
October 13, 2015 01:43
-
-
Save michaelt/242f6a23267707ad29e9 to your computer and use it in GitHub Desktop.
Hello world.
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
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