Propsal: NoDatatypeContexts

John Meacham john at
Tue Jul 20 16:49:05 EDT 2010

On Tue, Jul 20, 2010 at 07:47:34PM +0100, Malcolm Wallace wrote:
> As Igloo notes, GADTs are a more viable way to achieve the storing of  
> the dictionary within the constructor, e.g.
>     data OrdTree a where
>         Leaf   ::          a -> OrdTree a
>         Branch :: Ord a => OrdTree a -> OrdTree a -> OrdTree a

I was thinking about this case the other day from an implementation
point of view, wouldn't it annotate every subnode of a tree with an
extra ord instance, which are guarenteed to be the same anyway? 

Something like

import Data.Set

data OrdSet a where
        OrdSet :: Ord a => Set a -> OrdSet a

then using the normal set operations seems like it would be more
efficient. It seems like it would be easy to accidentally end up with
extra instances being passed around with the current GADT system.

Another alternate proposal for what we might do with data contexts that
was floating around was to have them allow smaller type signatures.

data Ord a => Set a = ..

would mean that whenever you see a 'Set a' the 'Ord a' is implied and need
not be explicitly stated.


insert :: a -> Set a -> Set a

is shorthand for 

insert :: Ord a => a -> Set a -> Set a


John Meacham - ⑆⑆john⑈ -

More information about the Haskell-prime mailing list