News for hackers. Stuff that matters.
Re:The Most Important Language Feature No One Talks About by 10ren on Tuesday October 20, 2009 @07:34AM (#892208)
That seems right, though I was thinking more of alternate ("union"?) types, like `A -> A | null`. That's the expressive part.

(nb: I'm not a Haskell user, so my syntax aims to be more suggestive than correct. I only know about it from some paper I came across).

But you're right you could do that example in Java (4eg): int xxxxx(int[] x)

Re:The Most Important Language Feature No One Talks About by loup-vaillant on Tuesday October 20, 2009 @11:29AM (#892546)
In Haskell, what you call a union type is more often called "sum type", or "tagged union". You declare them this way (your syntax was quite good):

    data IntOrNothing = AnInteger Int
                      | Nothing
You can use it that way:

    test :: IntOrNothing -> bool -- optional type declaration
    test AnInteger i -> True
    test Nothing     -> False
This is not overloading. This is the same function. I also can write it this way:

    test :: IntOrNothing -> bool -- optional type declaration
    test intOrNot = case intOrNot of
                      AnInteger i -> True
                      Nothing     -> False
So, the "choice" of union type is in the world of values, not in the world of types. Therefore, it isn't particularly relevant in the case of a type-based search.