Functional programming in Python

Malcolm Wallace Malcolm.Wallace@cs.york.ac.uk
Mon, 28 May 2001 10:23:58 +0100


It seems that right-associativity is so intuitive that even the person
proposing it doesn't get it right.  :-)  Partial applications are a
particular problem:

> Haskell				Non-Haskell
> Left Associative			Right Associative
> ------------From Prelude----------------------
> f x (foldr1 f xs)			f x foldr1 f xs

Wouldn't the rhs actually mean f x (foldr1 (f xs)) in current notation?

> showChar '[' . shows x . showl xs	showChar '[] shows x showl xs

Wouldn't the rhs actually mean  showChar '[' (shows x (showl xs))
in current notation?   This is quite different to the lhs composition.

For these two examples, the correct right-associative expressions,
as far as I can tell, should be:
  f x (foldr1 f xs)			f x (foldr1 f) xs
  showChar '[' . shows x . showl xs	showChar '[' . shows x . showl xs

Regards,
    Malcolm