[Haskell-cafe] NewbieQ: colon prefix for operators, e.g., Ratio ?
Matt Harden
matth at mindspring.com
Mon Oct 11 00:31:37 EDT 2004
On Sunday 10 October 2004 10:35 pm, Brian Beckman wrote:
> Apologies if this is the wrong mailing list in which to pester folks with
> Newbie Questions, but I couldn't find my answer after half an hour of
> scouring the Haskell Report, the Haskell Wiki, the School of Expression
> book and a couple of tutorials. The frustrating thing is that I know I saw
> the answer in ONE of those sources and it didn't stick at the time:
>
> what does it mean when an operator is prefixed by a colon? For instance,
> in the Ratio module, the meaning of x % y is clear, but x :% y appears in
> multiple places and I'm confused.
It's in the Report.
<http://www.haskell.org/onlinereport/lexemes.html#sect2.4>
Operator symbols are formed from one or more symbol characters, as defined
above, and are lexically distinguished into two namespaces (Section 1.4):
* An operator symbol starting with a colon is a constructor.
* An operator symbol starting with any other character is an ordinary
identifier.
So (:%) is the constructor for the Ratio type, whereas (%) is a function that
returns a Ratio.
More information about the Haskell-Cafe
mailing list