Folks,
Interesting! Phil, Mark, and Jeff all have a different interpretation of
how contexts on how data type declarations work than I did. So unless
some other people chime in, I will therefore adopt their interpretation,
since (a) I'm in the minority and (b) it's not a big deal at all.
But just to make it clear what's under review here, consider
data Ord a => Tree a = MkTree {
item :: a,
kids :: [Tree a]
}
We know that
MkTree :: Ord a => a -> [Tree a] -> Tree a
But what type does the selector 'item' have? Phil, Mark and Jeff think:
item :: Ord a => Tree a -> a
The same would apply to any use of MkTree in a pattern. For example:
f (MkTree _ _) = True
would get the type
f :: Ord a => Tree a -> Bool
Speak now or put up with overloaded selectors!
Simon
- Contexts on data type declarations Simon Peyton-Jones
- Re: Contexts on data type declarations Philip Wadler
- RE: Contexts on data type declarations Simon Peyton-Jones
- Re: Contexts on data type declarations Philip Wadler
- RE: Contexts on data type declarations Mark P Jones
- Re: Contexts on data type declarations Simon Peyton-Jones
- Re: Contexts on data type declarations Erik Meijer
- Re: RE: Contexts on data type declarations Christian Maeder
- RE: Contexts on data type declarations Koen Claessen
- Re: Contexts on data type declarations Olaf Chitil
- Re: Contexts on data type declarations Christian Maeder
- Re: Contexts on data type declarations Koen Claessen
- Re: Contexts on data type declarations Fergus Henderson
