Hacker News new | past | comments | ask | show | jobs | submit login

I can't understand what you mean, because

> A `data` declaration is declaring accessor functions for me, whether I ask for them or not, putting stuff into my namespace

It won't if you don't use record syntax. If you want the accessors, use record syntax. If you don't, don't.

> If I intend to declare a function f(a, b), I simply can't

Sure you can.

    f(a, b) = a + b
> it uses the same structure for declaration and for application

The same as Haskell




There's a core dispute here, and it's a pretty common one that can never quite be resolved.

The practicality argument I think you're making is necessary when you're working on an existing language feature, and that's because you're invariably forced into tradeoffs.

The argument from design I'm making is more appropriate to a completely new language feature; the more your design is based on math and especially the linguistics and psychology of user's intent, the fewer clever hacks the user has to make and the fewer tradeoffs you'll be making in the future.

Haskell did get a lot of design choices right because they had smart people who worked through the math, but I think regarding linguistics and psychology, it's much more of a "greybeard" language.

> It won't if you don't use record syntax.

"Don't use that feature" is simply acknowledging a feature is broken, it doesn't make it not broken.

And you typically need named fields because you have complex code and want it to be maintainble, that's also when you don't want your namespace polluted.

> Sure you can. f(a, b) = a + b

How does that work declaring an operator?

You're trying to write a binary function, but to do that thing you have to do something else, write a unary function that accepts a tuple.

It's hard to claim that "oh, n-ary functions are really just functions that accept n-tuples" when Haskell plainly doesn't believe it. That's evident in the fact that you lose the benefits of currying, sections, etc.

> > it uses the same structure for declaration and for application

> The same as Haskell

Nope.

    f :: Int -> (Int -> (Int -> Int))  -- Parens for clarity
    f a b c = a + b + c

    x = ((f 3) 5) 2
So we have two mismatches here:

1. The associativity of type is the reverse of application.

2. Neither of them reflect the simple case where I want to call a function with three arguments.

And, look, I get that math is what makes #1 an issue. I'm more an advocate of ubiquitous partial application:

    f :: (Int, Int, Int) -> Int
    f(a, b, c) = a + b + c
    x = f(3, 5, 2)
    y :: (Int) -> Int
    y = f(3, 5, ...)
    z = y(2)
It's stating exactly what you mean, and still has the benefit currying, and it's clearer to the reader what's a function and what's a value.

Function types become more complex, so I get why currying is attractive, but, again arguing from design, that's letting implementation drive interface.

And the math behind currying is certainly sound, but it's obscuring the fact that an n-ary function plainly isn't a unary function. They're just two different things.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: