[Haskell-cafe] Pattern Matching for record syntax

Jeon-Young Kang jykang22 at gmail.com
Thu Jan 7 21:54:47 UTC 2016


Dear All.

Hope your 2016 is off to a great start.

I would like to get results from pattern matching or something.

Here is the my code.

data Person = Person {name :: String, age :: Int}

names = ["tom", "sara"] -- list of names, String

persons = [Person {name = "tom", age = 10}, Person {name="sara", age=9},
                  Person {name = "susan", age = 8}].

Is there any solution to get the age of "tom" and "sara"?

I have no idea of pattern matching for this one.

I've tried to use recursion, but I couldn't find any solution for list of
records.

Sincerely,
Young
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160107/4657fc47/attachment.html>


More information about the Haskell-Cafe mailing list