[Haskell-cafe] 'data' syntax - a suggestion
tomasz.zielonka at gmail.com
Thu Sep 27 07:33:59 EDT 2007
On 9/27/07, jerzy.karczmarczuk at info.unicaen.fr
<jerzy.karczmarczuk at info.unicaen.fr> wrote:
> Thomas Conway writes:
> > On 9/27/07, ok <ok at cs.otago.ac.nz> 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".
More information about the Haskell-Cafe