r/purescript • • Oct 14 '17
Why does PS generate a `throw("Failed pattern match")` code-path?
AFAIK the PS compiler errors if any case of switch on ADT values is not exhaustive (ie all known data constructors need to be matched), so the generated throw should never be reached in theory. Why is the above then being generated --- just for external JS calling PS-generated scripts/functions? Or am I missing something else?
4
Upvotes
4
u/Thimoteus Oct 14 '17 edited Oct 14 '17
You can still have partial pattern matches by giving a
Partialconstraint:results in
Error: Failed pattern match at Main line 8, column 1 - line 8, column 38: B1
u/mjhoy Oct 16 '17
I think it's a good safety check for anything that uses
unsafeCoerceorunsafeFromForeign. I'm not actually sure what it would do without it...