Last active
August 29, 2015 13:57
-
-
Save mklinik/9620752 to your computer and use it in GitHub Desktop.
This file contains 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 Printf where | |
int :: (String -> a) -> String -> Int -> a | |
int cont str n = cont (str ++ show n) | |
lit :: String -> (String -> a) -> String -> a | |
lit l cont str = cont (str ++ l) | |
str :: (String -> a) -> String -> String -> a | |
str cont str s = cont (str ++ s) | |
eol cont str = cont (str ++ "\n") | |
format :: ((String -> String) -> String -> a) -> a | |
format f = f id "" | |
name = "Marvin" | |
age = 27 :: Int | |
occupation = "\955-scientist" | |
myFormat = (str . lit " the " . int . lit "-year-old " . str . eol) | |
main = putStr $ format myFormat name age occupation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment