[Haskell-beginners] combine pattern matching against named fields and tuples

Michael Mossey mpm at alumni.caltech.edu
Tue Apr 7 03:30:04 EDT 2009


I'm trying to do something like this:

data Thing = Thing { field1, field2 :: ( Int, Int ) }

myfunc = Thing { field1 ( _, x ) } = x

but it doesn't work. That is, I want to match against the second item of the tuple 
which is the named field1. I'm not just trying to do this particular thing, but 
trying to figure out if some kind of general pattern matching can be done like this.



More information about the Beginners mailing list