[Haskell-beginners] Syntax error using where with guards.

mva.led at gmail.com mva.led at gmail.com
Sat Sep 16 01:37:58 UTC 2017


Thanks, that solves it.  I really like `where`, though.


Francesco Ariis <fa-ml at ariis.it> writes:
> On Fri, Sep 15, 2017 at 06:53:54PM -0400, Manuel Vázquez Acosta wrote:
>>     $ ghc xoutil/dim/meta.hs
>>     [1 of 1] Compiling Meta             ( xoutil/dim/meta.hs, xoutil/dim/meta.o )
>> 
>>     xoutil/dim/meta.hs:19:3: parse error on input ‘|’
>
> Hello Manuel,
>     `where` scopes over several guarded equations (and this is the main
> difference with `let`). This should do the trick:
>
>     | a == 1 = let x = 10
>                in x + a
>     | a == 2 = let x = 3
>                in x + a
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


More information about the Beginners mailing list