Created
August 9, 2015 16:12
-
-
Save ethul/ee9a7ef6238903df4579 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
module Forever where | |
import Prelude | |
import Control.Monad.Eff | |
import Control.Monad.Eff.Console | |
import Control.Monad.Free | |
import Control.Monad.Rec.Class (forever) | |
import Data.NaturalTransformation | |
data TeletypeF a = PutStrLn String a | |
type Teletype a = Free TeletypeF a | |
putStrLn :: String -> Teletype Unit | |
putStrLn s = liftF (PutStrLn s unit) | |
teletypeN :: forall e. NaturalTransformation TeletypeF (Eff (console :: CONSOLE)) | |
teletypeN (PutStrLn s a) = const a <$> pure s | |
run :: forall a. Teletype a -> Eff (console :: CONSOLE) a | |
run = foldFree teletypeN | |
program = forever $ putStrLn "Forever" | |
main = run program |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment