[Haskell-cafe] Guards on variable bindings

Tom Ellis tom-lists-haskell-cafe-2017 at jaguarpaw.co.uk
Mon Jan 24 21:28:32 UTC 2022


I don't think that can be the reason.  It is possible to have a single
clause with multiple guards:

    bar | False = ()
        | True = ()
    
It's just not possible to have multiple clauses if one of them is
guarded, apparently.


On Mon, Jan 24, 2022 at 04:24:43PM -0500, Brandon Allbery wrote:
> I think because it desugars to a case-of and there's nothing to case
> on in the first one?
> 
> On Mon, Jan 24, 2022 at 4:18 PM Tom Ellis
> <tom-lists-haskell-cafe-2017 at jaguarpaw.co.uk> wrote:
> >
> > According to GHC there are multiple declarations of bar, but not of
> > foo.  I don't understand.  Why is it not valid to have multiple
> > clauses for a variable binding?
> >
> >
> > Tom
> >
> >
> >     bar | False = ()
> >     bar = ()
> >
> >     foo _ | False = ()
> >     foo _ = ()


More information about the Haskell-Cafe mailing list