Hello i am asking if there is any other way to pattern match against a type besides case
or left-hand-side
pattern match.
data T=A Int | B Int |C Int | D Int
....//many cases
Method 1
getType::T->Char
getType A _ = 'a'
getType B _ ='b'
...............
Method 2:
getType::T->Char
getType x=case x of
A _ -> 'a'
B _ -> 'b'
...........
My example above is just an example for its sake ..i assume there are some easy ways if i just want to associate the "reflected'"name of the data constructor with its lower-case-char
.
I am more like curious if there are any other ways / constructs in haskell when you want to achive pattern matching.