[Haskell-cafe] Data types and Haskell classes
Dylan Thurston
dpt at lotus.bostoncoop.net
Wed May 18 16:03:59 EDT 2005
On Tue, May 17, 2005 at 01:13:17PM +0200, Jens Blanck wrote:
> > > How would I introduce number classes that are extended with plus and
> > > minus infinity? I'd like to have polymorphism over these new classes,
> > > something like a signature
> > >
> > > f :: (Real a, Extended a b) => b -> b
> > >
> > > which clearly is not part of the current syntax, but I hope you get
> > > the picture. What are the elegant ways of doing this?
> >
> > How about
> > f :: Real a => Extended a -> Extended a
>
> Not quite what I had in mind. I'd like to have extended integers and
> extended rationals, and possibly extended dyadic numbers. So I can't
> have just a single type ExtendedRational (unless I'm prepared to do
> some ugly coersing).
You're missing the point. Try:
> data Extended a = PlusInf | NegInf | Finite a
Peace,
Dylan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org//pipermail/haskell-cafe/attachments/20050518/948196d3/attachment.bin
More information about the Haskell-Cafe
mailing list