Skip to content

Instantly share code, notes, and snippets.

@mklinik
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mklinik/9620752 to your computer and use it in GitHub Desktop.
Save mklinik/9620752 to your computer and use it in GitHub Desktop.
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