[Haskell-beginners] Re: Offside rule for function arguments?

John Smith voldermort at hotmail.com
Mon Aug 23 05:54:25 EDT 2010


Sorry, I missed the where.

On 23/08/2010 12:52, Jonas Almström Duregård wrote:
>  > The indentation on the second line would generate a parse error, the same as it does now.
> What parser error is that? Both
>
> function 0 = 0 where
>   fun     1 = 1
> function 2 = 2
>
> and
>
> function 0 = 0 where
>   fun     1 = 1
>   fun     2 = 2
>
> works for me.
>
> /J
>
> On 23 August 2010 11:46, John Smith <voldermort at hotmail.com <mailto:voldermort at hotmail.com>> wrote:
>
>     The indentation on the second line would generate a parse error, the same as it does now.
>
>
>     On 23/08/2010 12:32, Jonas Almström Duregård wrote:
>
>         Maybe because of this:
>
>         function 0 = 0 where
>           fun     1 = 1
>                   2 = 2
>
>         The last declaration (2=2) can define either fun or function. I'm not saying this is a major problem, but there
>         may be
>         other problems like these.
>
>         /J
>
>         On 23 August 2010 11:15, Brent Yorgey <byorgey at seas.upenn.edu <mailto:byorgey at seas.upenn.edu>
>         <mailto:byorgey at seas.upenn.edu <mailto:byorgey at seas.upenn.edu>>> wrote:
>          > On Mon, Aug 23, 2010 at 09:33:13AM +0300, John Smith wrote:
>          >> Why doesn't Haskell allow something like this?
>          >>
>          >> fac 0 = 0
>          >>     1 = 1
>          >>     x = x * fac (x-1)
>          >>
>          >> This would be clearer than repeating the function name each time,
>          >> and follow the same pattern as guards and case.
>          >
>          > Good question.  I don't know of any particular reason.
>          >
>          > -Brent



More information about the Beginners mailing list