error-message-catalog
error-message-catalog copied to clipboard
Error message not helping when pattern matching `Set.empty` in case expression
The following code:
printUser users =
case users of
Set.empty ->
text "Empty"
_ ->
text users
caused the syntax error below which is confusing:
-- SYNTAX PROBLEM --------------------------------------------------------------
I ran into something unexpected when parsing your code!
6| Set.empty ->
^
I am looking for one of the following things:
an upper case name
I will suggest @jessta 's answer to my question in the slack, which is much clearer and helpful:
The pattern in
case..of
need to be literals, they can't be functions or variables. Set.empty is a function.You probably want to use a
if..then..else
andSet.isEmpty
, eg.if Set.isEmpty users then text "empty" else text users