Skip to content

Instantly share code, notes, and snippets.

@slipset
Created February 7, 2018 11:10
Show Gist options
  • Save slipset/4d4a13f5f12b5d98de102d11cebfec61 to your computer and use it in GitHub Desktop.
Save slipset/4d4a13f5f12b5d98de102d11cebfec61 to your computer and use it in GitHub Desktop.
;; 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