Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Isaac Dupree <isaacdupree <at> charter.net>
Subject: Re: 'data' syntax - a suggestion
Newsgroups: gmane.comp.lang.haskell.cafe
Date: Thursday 27th September 2007 13:03:52 UTC (over 9 years ago)
Tomasz Zielonka wrote:
> On 9/27/07, [email protected]
> <[email protected]> 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
 
CD: 7ms