Skip to content

Instantly share code, notes, and snippets.

@seanparsons
Created January 8, 2015 17:17
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 seanparsons/2c8a7ecd3b84e3019bd3 to your computer and use it in GitHub Desktop.
Save seanparsons/2c8a7ecd3b84e3019bd3 to your computer and use it in GitHub Desktop.
Haskell partial application pondering.
-- In this case it would be in theory be possible to create a single thunk for "ab" if pointless was partially applied as so:
-- pointless 1 2
-- The resulting Int -> Int method would then only have to evaluate ab once because otherwise it never changes.
-- The obvious possibility this could cause would be caching very large intermediate representations that would otherwise be
-- garbage collected.
pointless :: Int -> Int -> Int -> Int
pointless a b c =
let ab = a + b
in ab + c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment