Skip to content

Instantly share code, notes, and snippets.

@dbp
Created October 13, 2018 19:08
Show Gist options
  • Save dbp/0c92ca0b4a235cae2f7e26abc14e29fe to your computer and use it in GitHub Desktop.
Save dbp/0c92ca0b4a235cae2f7e26abc14e29fe to your computer and use it in GitHub Desktop.
c :: String -> ((String -> a) -> a)
c str = \k -> k str
d :: (String -> a) -> Int -> a
d = \k -> (\int -> k (show (int::Int)))
s :: (String -> a) -> String -> a
s = \k -> (\str -> k (str::String))
printf :: ((String -> IO ()) -> a) -> a
printf format = format putStrLn
(%) :: ((String -> a) -> c)
-> ((String -> b) -> a)
-> (String -> b) -> c
(%) f1 f2 = \k -> f1 (\s1 -> f2 (\s2 -> k (s1 ++ s2)))
main = do printf (d % c "foo" % s) 10 "bar"
printf (d % c "foo") 10
@denismerigoux
Copy link

Here's what I managed to do : https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=159cfda7ced5f44149e58849955071d8.

The individual functions compile but you can't use them because currification and partial application don't really work in Rust...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment