help from the community?

Andres Loeh loeh at iai.uni-bonn.de
Wed Jan 31 05:49:15 EST 2007


> >>Just a little remark on the side: 'If' and 'case' demand exactly one
> >>expression. In such cases allowing zero expressions is not a
> >>generalization but an unnecessary complication. 'Let' and 'where'
> >>allow any number of bindings, so allowing zero bindings (instead of
> >>demanding at least one) is a simplification.
> >
> >I meant the branches of a case (the report specifies at least 1).
> 
> I think it's important to keep some possibility for the compiler to detect 
> probable errors as syntax errors. If all syntax is inhabited by strange 
> defaults then this just means simple errors will go undetected eg:
> 
>    let a = case foo of
> 
> Here, the user has probably got sidetracked into editing some other part of 
> the program and just forgotten to get back to fill in the cases for the 
> case construct. Allowing zero cases means the user will get a strange 
> runtime error instead as the "function" part of the case is undefined.

I agree. On the other hand, if there are uninhabited types (modulo _|_), it
might be nice to have an empty case as an explicit eliminator.

>    let z = \y (foo y)
> 
> Here, it seems clear that the user has just forgotten to type the -> which 
> means a simple syntax error would get transformed into a much more puzzling 
> (esp for a newbie) type error.

Again, for the lambda I obviously meant the case of 0 variables, i.e. something
like (\ -> y) which would then just be equivalent to y. I think this case is
probably the one that's most comparable to the situation in question (whether
to allow empty forall's). Since the designers of previous Haskell versions
obviously thought it's a good idea to disallow empty lambdas, let's disallow
empty forall's as well.

Cheers,
  Andres


More information about the Haskell-prime mailing list