[Haskell-cafe] function unique

Hugh Perkins hughperkins at gmail.com
Wed Jul 11 16:49:27 EDT 2007


Well, there's a fundamental reason it wont work for Haskell: we dont
actually define the names of the parameters to the function!

Have a look at the function above, the function is defined as:

testunique' :: Eq a => [a] -> [a] -> [a]
testunique' [] elementssofar = []
testunique' (x:xs) elementssofar

There's an agreement here that the second parameter is called
"elementssofar"... but only because I was consistent in my naming in this
example.  What if we had multiple constructors for a particular type?

The first argument has no obvious naming at all.

We could do things like write it in comments:

testunique' :: Eq a => [a] -> [a] -> [a]
-- testunique' :: remainingelements -> elementssofar -> uniqueelements
testunique' [] elementssofar = []
testunique' (x:xs) elementssofar

... but we all know that no-one bothers writing comments, and certainly
never maintaining them, and in any case this is becoming insanely difficult
to read.

I dont have a solution, apart from using C# for production programming ;-) ,
but things like this are really important to solve in any "mainstream"
version of Haskell.

On 7/11/07, Steve Schafer <steve at fenestra.com> wrote:
>
> On Wed, 11 Jul 2007 22:39:27 +0200, you wrote:
>
> >In C#, when you call a function you type "(" and instantly you get a
> popup
> >box telling you what the name of the first argument is, then when you've
> >written the first argument and hit "," you get the name (and type) of the
> >second argument.
>
> That's not a feature of C# itself, but rather a feature of the
> development environment you're using. You can write C# code in NotePad,
> and I will guarantee you that you won't see any such popups. ;)
>
> There do exist various development environments for Haskell, but I don't
> think any of them are particularly popular.
>
> Steve Schafer
> Fenestra Technologies Corp.
> http://www.fenestra.com/
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070711/ab9a232e/attachment.htm


More information about the Haskell-Cafe mailing list