Created
February 7, 2018 11:10
-
-
Save slipset/4d4a13f5f12b5d98de102d11cebfec61 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
;; import Data.Monoid ((<>)) | |
;; 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" ]) | |
(defn prompt [attr] | |
(println (str "What is your " attr "?")) | |
(let [v (read-line)] | |
(fn [] (println (str "Your " attr " is " v))))) | |
(defn run-wizards [wzs] | |
(doseq [w wzs] | |
(w))) | |
(run-wizards (map prompt ["name" "age" "favourite-color" "sign"])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment