[Haskell-cafe] Should there be a haskell template for inclusion polymorphism in Haskell?

Olaf Klinke olf at aatal-apotheke.de
Thu May 26 21:32:38 UTC 2022

> So my central questions for discussions are:
> - Is inclusion polymorphism something we should use at all in Haskell?
> - These boiler plate code maybe better be generated using Haskell template
> instead, is there one already, or should
>   there be one?

Maybe one of the authors of a sub-typing library can share a more
informed opinion on this. My view as a mathematician: 
A type being a subtype of another is a relation between types. 
Relations between types is what multi-parameter type classes is about. 
Hence it seems that this is how subtypes in Haskell ought to be done.
For example, in the attenuation and records-sop package, the latter of
which is based on genercis-sop, which depends on Template Haskell. So
without having used any of the mentioned packages, I believe your
second question can be answered with  "yes". 
Regarding the first question, we should probably ask ourselves how much
type-safety we're sacrificing for the convenience we gain. The Num
example you gave shows one possible danger: While a subtype relation
may hold mathematically, the implementiation details may cause this
relation to fail in reality. Example: All floating point numbers are
rationals, aren't they? So there should be a subtype relation. But how
to convert NaN, -infinity or -0 of type Double to a pair of Integers?


More information about the Haskell-Cafe mailing list