[Haskell-cafe] infix naming
droundy at abridgegame.org
Wed Mar 17 07:01:58 EST 2004
[moving to haskell-cafe due to an extreme shift in topic]
On Wed, Mar 17, 2004 at 08:55:22AM +0100, Ketil Malde wrote:
> > So it is agreed: we use "isXXXX" :-)
> s1 `isSubsetOf` s2 vs s1 `isSubset` s2
> isSubsetOf s1 s2 isSubset s1 s2
> I'm not sure I have any clear preference. ..Of reads slightly clearer
> in infix notation, but is arguably a bit more confusing in prefix.
This seems to be a common problem: a name that makes sense (i.e. it is
obvious what it does) in prefix notation very often is completely wrong in
infix notation, particularly when partially applied.
"e `isElementOf` list" makes perfect sense, while "isElementOf e list"
seems a bit wrong, and "isElementOf e" (of type [a] -> Bool) reads
completely wrong. I guess "`isElementOf` list" (which is of type a ->
Bool) does make sense.
I guess perhaps names just have be chosen to either make sense in infix
notation, or in prefix notation, but not both? Is this a general
principle, and if so, that seems bad, since the choice of infix vs prefix
notation seems like it shouldn't have to be made at the API level.
Does anyone know why it was originally decided to make infix notation work
as it does? To me it seems like it would make sense for (`f` x) to be the
same as (f x) rather than the opposite. e.g. (`is_less_than` 2) and
(is_less_than 2) sound the same way when I pronounce them, and it's not
entirely pleasant that the second one is in fact the same as (>= 2). On
the other hand, if you don't think of it as (is_less_than a) b, one might
naturally think that (is_less_than a b) should be (a < b).
More information about the Haskell-Cafe