[Haskell-cafe] Question about classes from a Haskell newbie.

Simon Peyton-Jones simonpj at microsoft.com
Wed May 25 08:37:07 EDT 2005


http://research.microsoft.com/%7Esimonpj/Papers/type-class-design-space

will fix manual

Simon

| -----Original Message-----
| From: haskell-cafe-bounces at haskell.org
[mailto:haskell-cafe-bounces at haskell.org] On Behalf Of
| Scott J.
| Sent: 25 May 2005 13:29
| To: haskell-cafe
| Subject: Re: [Haskell-cafe] Question about classes from a Haskell
newbie.
| 
| Hello,
| 
| the web page http://research.microsoft.com/~simonpj/multi.ps.gz
mentioned
| in
| 
|
http://www.haskell.org/ghc/docs/latest/html/users_guide/type-extensions.
html#multi-param-type-
| classes
| 
| is not reachable or does not exist anymore.
| 
| Any hints how I can get my hands on this paper are welcome
| 
| Jan
| 
| 
| ----- Original Message -----
| From: "robert dockins" <robdockins at fastmail.fm>
| To: <Jeff.Harper at handheld.com>
| Cc: <haskell-cafe at haskell.org>
| Sent: Tuesday, May 24, 2005 10:07 PM
| Subject: Re: [Haskell-cafe] Question about classes from a Haskell
newbie.
| 
| 
| >
| >>  However, I didn't understand the syntax of the class declaration.
| >>
| >> Lemmih wrote:
| >>  > import Complex
| >>  >
| >>  > class ConvertibleToComplex a b | a -> b where
| >>  >    toComplex :: RealFloat b => a -> Complex b
| >>
| >> I've looked at several sources to try to understand this
declaration.  I
| >> can't find any examples where a class declaration takes two type
| >> variables or uses the pipe symbol.  One of the sources I used was
| >> _Haskell 98 Language and Libraries The Revised Report_.  I'm not an
| >> expert at BNF notation, but the definitions for topdecl, tycls, and
tyvar
| >> in the grammar seems to exclude Lemmih's declaration.
| >>
| >> If someone could point me to some sources that explain this
notation, I'd
| >> be very grateful.
| >
| > This is a multi-parameter typeclass (with functional dependencies),
which
| > is not a part of Haskell 98, so its no surprise that you didn't find
it in
| > the Report.  The Muli-parameter part is pretty easy to understand:
the
| > type class simply introduces more than one type variable.
Functional
| > dependencies let you say which types should determine which other
types.
| > Here are some pages on these ideas:
| >
| >
http://www.haskell.org/ghc/docs/latest/html/users_guide/type-extensions.
html#multi-param-type-
| classes
| >
http://www.haskell.org/ghc/docs/latest/html/users_guide/type-extensions.
html#functional-
| dependencies
| > http://haskell.org/hawiki/FunDeps
| >
| > In this particular instance, what the class definition means is that
| > 'ConvertaibleToComplex' is a class which relates two types 'a' and
'b' AND
| > the type 'a' uniquely determines the type 'b'.
| >
| >
| > Hope that helps,
| > Robert Dockins
| >
| > _______________________________________________
| > Haskell-Cafe mailing list
| > Haskell-Cafe at haskell.org
| > http://www.haskell.org/mailman/listinfo/haskell-cafe
| >
| 
| 
| _______________________________________________
| Haskell-Cafe mailing list
| Haskell-Cafe at haskell.org
| http://www.haskell.org/mailman/listinfo/haskell-cafe


More information about the Haskell-Cafe mailing list