Hacker News new | ask | show | jobs
by megapoliss 1629 days ago
Curring is a way to do "dependency injection" in FP, so it let you to "capture" some arguments and don't pass them each time. Sure, arguments order matter, but you don't need to refactor that often.

I'm not familiar enough with clojure, buy in F# you sample with collision/shake/police may looks like

  someGameState
  |> handleCollisions
  |> handleShake
  |> handlePolice
  ...
  |> renderGameState

where each function accept gameState, run some login against it, and return modified state, so you don't need to pass dozen arguments through call-stack.
1 comments

In clojure:

    (-> someGameState
      handleCollisions 
      handleShake
      handlePolice
      ;; ...
      renderGameState)

    ;; ->> would work as well in this example cause it's both first and last argument
But this code is only pretending to be functional, because in practice every function can modify everything. So looking at this I have no idea where the particles were created - I have to look at every function anyway.