%n

perl -e 'use strict; print "$x";'

.

print (some magic here)

print format1 3 "foo"

(some magic type involving an a) -> a

lit :: String -> (String -> a) -> String -> a

lit text k s = k (s ++ text)



int :: (String -> a) -> String -> Int -> a

int k s val = k (s ++ show val)



printf :: ((String -> String) -> String -> a) -> a

printf fmt = fmt id ""

lit

int

"my int is %d

"

lit "my int is " . int . lit "

"

printf (lit "my int is " . int . lit "

")

Int -> String

printf

map

int

lit

k

s

printf (lit "foo" . int)

(lit "foo" (int (id))) ""

id

int

(String -> a) -> (String -> (Int -> a))

Int -> a

a