I've seen this code in a PureScript program, what does <<<
do?
pinkieLogic :: (Tuple Boolean GameObject) -> GameObject -> GameObject
pinkieLogic (Tuple jumpPressed hater) p =
hated hater p
(solidGround
<<< gravity
<<< velocity
<<< jump jumpPressed
<<< clearSound)
<<<
is the right-to-left composition operator. It's equivalent to .
in Haskell. It works like this:
(f <<< g) x = f (g x)
That is, if you have two functions1 and you put <<<
between then, you'll get a new function that calls the first function with the result of calling the second function.
So, that code could be rewritten as follows:
pinkieLogic :: (Tuple Boolean GameObject) -> GameObject -> GameObject
pinkieLogic (Tuple jumpPressed hater) p =
hated hater p
(\x -> solidGround (gravity (velocity (jump jumpPressed (clearSound x)))))
[1] Unlike Haskell's .
operator, <<<
in PureScript also works on categories or semigroupoids.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With