[Haskell-cafe] MultiCase alternative

Baa aquagnu at gmail.com
Mon Jun 19 07:44:11 UTC 2017


> Let's take the ABCD example.
> data ABCD a b c = A a | B b | C c | D c
> data ABC  a b c = A' A | B' b | C c Bool

You mean
  data ABC a b c = A' a | B' b | C' c Bool

It is very pleasant when a person has such a wide horizon: you
compared F#, SML, Erlang and Haskell, IMHO modern FP developer should
have basic knowledge about these languages/cultures and to know about
their trends/current researches. Example with SML 'OR'-pattern, am I
right that this terrible compile time is due search on all permutations
of patterns (func arguments)? But what is not obvious to me is what
is compiler try to match:

    P1    P2  ...   Pn  (0,0)  => True
    _     _   ...   _     _    => False
  (1,1) (2,2) ... (n,n) (1,1)  => False

is not enought to do depth-first search and to go from P1 to last
(0,0)? Or is it try to find all matches, not only one, first successful?
May be I miss what is 'Pn', how it's defined.

Your example with the introduction of a 'ABC' has good understandable
semantic, if they can be united, there is a reason to combine them in
new type, semantically it makes sense. And view pattern in your example
"unwraps" underlying datatype value to be matched and bound.

Good explanation, thanks for it! And from SML example I can understand
that obvious solution to the forehead of "OR"-pattern matching can be
problematic in practice...

===
Thanks again, best regards,
  Paul


More information about the Haskell-Cafe mailing list