
Tomasz Zielonka wrote:
On 9/27/07, jerzy.karczmarczuk@info.unicaen.fr
wrote: Thomas Conway writes:
On 9/27/07, ok
wrote: I have often found myself wishing for a small extension to the syntax of Haskell 'data' declarations. It goes like this: ['where' clause to allow locally defined names in type declarations]
Nice.
Quite a few times I've found myself declaring type synonyms for this reason, but you end up polluting the global namespace.
+1 vote. Data with where? You haven't heard about GADTs?
I think that you haven't read the question carefully, because "where" in GADTs is simply a syntactic sugar. However, this seems to be available already with GADTs and type equality constraints:
data BST key val where Empty :: BST key val Fork :: (bst ~ BST key val) => key -> val -> bst -> bst -> BST key val
It's a pity you can't use bst (or a type synonym) instead of the last "BST key val".
Indeed. GADT syntax looks like a type signature (except for strictness annotations, which presently aren't part of function syntax!) but apparently the (->)s and result-type aren't type-signature, because type-synonyms can't be used for them. I tried. (because there were several GADT constructors with slightly different signatures, so I made a type-synonym with an argument to try to shorten them). It seems a pity to me too. Isaac