[Haskell-cafe] Synthetic values?

Alexey Khudyakov alexey.skladnoy at gmail.com
Wed Feb 9 19:33:51 CET 2011


On 09.02.2011 20:57, Chris Smith wrote:
> On Wed, 2011-02-09 at 18:15 +0100, Cristiano Paris wrote:
>> I've a type problem that I cannot solve and, before I keep banging my
>> head against an unbreakable wall, I'd like to discuss it with the
>> list.
>
> If I'm understanding your high-level goals correctly, then you're going
> about things the wrong way.  It looks like in your "Sealed" type, you're
> accumulating a list of type class constraints that are needed by a
> phantom type, in order to access the value.  But type classes are open;
> anyone can make any new type an instance of the type class whenever they
> want.
>

It's possible to have closed type classes. Trick consist in adding 
unsatisfiable constraint. For example:

 > -- This type class is not exported
 > class Private a
 > class Private a => PRead a

If Private is not exported one cannot add instances to PRead.



More information about the Haskell-Cafe mailing list