• she/her, it/its

gay ass artist and programmer, i guess. 23. works on botania, the minecraft mod. also into weird functional programming stuff. talk to me about monads (or applicatives if you're even cooler)


fullmoon
@fullmoon

… so I'm just going to post some fun Haskell code to give it a test drive:

prompt :: String -> IO (IO ())
prompt attribute = do
    putStrLn ("What is your " ++ attribute ++ "?")
    x <- getLine
    return (putStrLn ("Your " ++ attribute ++ " is: " ++ x))

runWizard :: IO (IO a) -> IO a
runWizard request = do
    respond <- request
    respond

main :: IO ()
main = runWizard (foldMap prompt [ "name", "age", "favorite color", "sign" ])

In case you're wondering, this code snippet is from my The wizard monoid blog post


You must log in to comment.

in reply to @fullmoon's post: