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

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Tue Apr 7 03:37:02 EDT 2009


On 2009 Apr 7, at 3:30, Michael Mossey wrote:
> I'm trying to do something like this:
>
> data Thing = Thing { field1, field2 :: ( Int, Int ) }
>
> myfunc = Thing { field1 ( _, x ) } = x

 > myfunc (Thing {field1 = (_,x)}) = x
using record pattern matching

-- 
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH


-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/beginners/attachments/20090407/3bf147a7/PGP.bin


More information about the Beginners mailing list