If I have a function like so:
func:: Arg1->Arg2->String
and Arg1 has a constructor like:
data Arg1 = something1 something2 something3
I want to pattern match on one of the Arg1 constructors within func (below I have pattern matched on “Val1”):
func:: Arg1->Arg2->String
func (a b Val1) e = "Something"
but it keeps saying I have a problem with parsing symbol ‘a’
The variables in the brackets just represent Arg1??? “e” is the Arg2 parameter.
EDIT: This seems to work:
func:: Arg1-> Arg2-> String
func (A b Val1) e = "Something"
but I cannot pattern-match on A because i’m not bothered about that value.
EDIT2: Seems like I need to do:
data Arg1 = Arg1 something1 something2 something3
for it to work?!?!
You have to pattern match on the constructor as well.
You also forgot to specify the constructor for
Arg1.