On 9 February 2011 19:33, Alexey Khudyakov <alexey.sklad...@gmail.com> wrote:
> 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.
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>

Indeed, this is exactly what I use in explicit-iomodes:

http://hackage.haskell.org/packages/archive/explicit-iomodes/0.6.0.2/doc/html/System-IO-ExplicitIOModes.html#t:ReadModes

Bas

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to