Lets say i have a piece of code like this:
test pattern
| pattern == (_,NOT (WIRE _)) = 1
| pattern == (_,AND (WIRE _) (WIRE _)) = 2
| otherwise = 0
Where i am trying to match it against one of several possibilities, some with one (WIRE “”), some with two. I have actual input as follows e.g.: (“p”,NOT (WIRE “x”)). I would like to have a pattern that could accept any letter as input (what i was hoping for with the _) and am failing dismally (illegal _). Is it possible to do this in haskell?
OK, this makes a lot more sense after the edit.
==compares values, but_is a pattern. Patterns appear in only the following syntactic contexts:=“, at top level or inwhereblocks or inletexpressions or commands (indonotation);<-indonotation or in a list comprehension;->in acaseexpression;\) expressions.(I hope I haven’t forgotten any!) In your case, you can achieve what you want by simply writing
You might ask what is the correct version of “
pattern == (_, NOT (WIRE _))“. Well, you can write: