[Haskell-cafe] Guards on variable bindings
Brandon Allbery
allbery.b at gmail.com
Mon Jan 24 21:33:17 UTC 2022
That seems fine to me because they can be combined into a single
case-of. I just don't see how you'd do so with an unguarded clause;
guess I'd have to look at -ddump-ds to see what exactly it's doing
with them,
On Mon, Jan 24, 2022 at 4:29 PM Tom Ellis
<tom-lists-haskell-cafe-2017 at jaguarpaw.co.uk> wrote:
>
> 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 _ = ()
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
--
brandon s allbery kf8nh
allbery.b at gmail.com
More information about the Haskell-Cafe
mailing list