[Haskell-cafe] Class Quantification

Jules Bean jules at jellybean.co.uk
Wed Oct 1 09:48:35 EDT 2008

Bas van Dijk wrote:
> On Wed, Oct 1, 2008 at 3:01 AM, Reiner Pope <reiner.pope at gmail.com> wrote:
>> I believe there is no way to simply express this "abstraction over classes",
>> but the Scrap your boilerplate with class[1] paper discusses this same
>> problem and present a workaround by defining the class's dictionary of
>> methods as an explicit type.
>> What follows is the code to implement their workaround for your example.
>> First some fairly standard extensions:
>>> {-# LANGUAGE Rank2Types, EmptyDataDecls, FlexibleInstances, KindSignatures
>>> #-}
>> And some more controversial, but necessary ones:
>>> {-# LANGUAGE UndecidableInstances, OverlappingInstances #-}

Just an observation:

That terrifying list of extensions is needed for this 'full' solution.

To just literally encode what the OP wanted you just need a concrete 
dictionary and existentials, AFAIK.


More information about the Haskell-Cafe mailing list