What does triple less-than sign (`<<<`) do in PureScript?

I saw this code in PureScript , what does <<< do?

 pinkieLogic :: (Tuple Boolean GameObject) -> GameObject -> GameObject pinkieLogic (Tuple jumpPressed hater) p = hated hater p (solidGround <<< gravity <<< velocity <<< jump jumpPressed <<< clearSound) 
+5
source share
1 answer

<<< is the composition operator from right to left . It is equivalent . in Haskell. It works as follows:

 (f <<< g) x = f (gx) 

That is, if you have two functions 1 and you put <<< between them, you will get a new function that calls the first function with the result of calling the second function.

So, this code can 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 the Haskell operator . , <<< in PureScript also works on categories or semigroupoids .

+9
source

All Articles