
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

On Tue, Dec 14, 2010 at 10:31 AM, Pierre-Etienne Meunier
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 :
No, such a thing doesn't exist. In fact, it would make the type system undecidable if it did exist. I only know this because a long while ago I really wanted such a thing to exist then tried to work out the consequences and realized it would break the type system. I have found liberal use of 'newtype-deriving' has mitigated my need for it in the specific cases I was interested in. John
participants (2)
-
John Meacham
-
Pierre-Etienne Meunier