News for hackers. Stuff that matters.
Re:Pitfalls in Haskell by dllthomas on Monday August 22, 2016 @11:03AM (#12336794)
Regarding...

    A{} or B{} -> f1
a big part of the problem is that A and B are going to be putting different things into scope in the context of f1.

If you're not binding anything, you could do it with guards:

    ...
    | isA myData || isB myData -> f1
    ...
Re:Pitfalls in Haskell by Morgawr on Monday August 22, 2016 @11:27AM (#12336980)
This assumes that you have an isA and an isB function. This forces me to write such a function which I might not have and in case of very very very large data types (like ~20-30, if not more, constructors) it becomes unwieldy and very messy.
Re:Pitfalls in Haskell by dllthomas on Monday August 22, 2016 @11:37AM (#12337068)
It's probably less work than duplicating the cases, and ideally you can give a more meaningful name to the whole "isA or isB" construct - especially when you have a lot of constructors!
Re:Pitfalls in Haskell by pklausler on Monday August 22, 2016 @11:30AM (#12337001)
If he's not binding anything, he could just match C{} in the first rule and a wildcard (_) in the second.
Re:Pitfalls in Haskell by dllthomas on Monday August 22, 2016 @11:35AM (#12337044)
Yes, but there could be a D{}, now or in the future.

I rarely use wildcards that aren't embedded in the middle of some larger structure. They stop the compiler from telling me points I need to consider, as I change my code.