Enjoy point-free style? Check out this new package!

I’ve been using this for a little over a month now and have really enjoyed it.

  1. Could you describe f <. g <~. h more. What is done first, left or right. What happens when the first operator is applied

  2. Why <. is better

1 Like
  1. <. and <~. are both right-associative with the same precedence, so this is how you would transform it step by step
f <. g <~. h
(f <. g) <~. h
(\z -> f (g z)) <~. h
\x y -> (\z -> f (g z)) x (h y)
\x y -> f (g x) (h y)

But an easier way to think about it is to use the symbols. f <. g means make a new function consisting of g being applied to the first argument of f. f <~. g mean make a new (at least) two argument function where the first argument is passed to f unaltered, and the second argument is passed to f after first having g applied to it. So when you combine them, f <. g <~. h becomes "take f, apply g to it’s first argument and apply h to its second argument.

  • personally I find <<< unnecessarily verbose.
  • I don’t like how <<< and >>> are both right-associative
  • it’s the natural operator for normal composition when using the generalization I’m using (what comes next? <...., <..., <.., ?)
  • it’s kinda like haskell’s . but can be used in both directions
1 Like