[Haskell-cafe] Identity type

Pierre-Etienne Meunier pierreetienne.meunier at gmail.com
Tue Dec 14 19:31:14 CET 2010


Hi,

Is there something like an identity type, transparent to the type-checker, in haskell ?
For instance, I'm defining an interval arithmetic, with polynomials, matrices, and all that... defined with intervals. The types are :

Polynomial Interval (instead of Polynomial Double for instance)
Matrix Interval
etc.

Now I'd like to be able to define some typeclass "intervalize" that would convert a IEEE-754 version of my types into the interval ones :

class Intervalize a where
	intervalize::a Double-> a Interval

Wouldn't it be very natural wanting to use this class on Doubles directly :

intervalize' :: Double->Interval
intervalize'=intervalize

Does this exist in haskell ? in GHC ?

Cheers,
Pierre





More information about the Haskell-Cafe mailing list