F# utilities in haskell
Slowly I am getting more familiar with Haskell, but there are some things that really irk me. For example, a lot of the point free functions are right to left, instead of left to right. Coming from an F# background this drives me nuts. I want to see what happens first first not last.
For example, if we wanted to do (x+2)+3
in f#
let chained = (+) 2 >> (+) 3
Compare to haskell:
chained :: Integer -> Integer
chained = (+3) . (+2)
In haskell, the +2 is given the argument 3, then that value is given to +3. In f# you work left to right, which I think is more readable.
Anyways, this is an easy problem to solve by defining a cusotm infix operator
(>>>) :: (a -> b) -> (b -> c) -> (a -> c)
(>>>) a b = b . a
Now we can do the same combinations as in F#.
Another thing that bugs me is pipe operator in haskell. I want to be able to pipe using the |>
operator left to right (as in subject followed by verb) instead of the way haskell does it with $
which is verb followed by subject.
Again, easy fix though
(|>) :: t -> (t -> b) -> b
(|>) a b = b $ a
Now we can do 1 |> (+1)
and get 2
. Fun!