[Haskell-cafe] Data types and Haskell classes

Jens Blanck jens.blanck at gmail.com
Tue May 17 07:13:17 EDT 2005


> > 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
> 
> Double and Float already include -Infinity and +Infinity:
> 
> Prelude> -(1/0) :: Double
> -Infinity
 
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).

Jens


More information about the Haskell-Cafe mailing list