Hi,

I'm writing a very simple address book. I defined the follwoing types for Contact and AddressBook:

type Name= String
type PhoneNumber= Integer

data Contact = Contact {name :: Name, phone:: PhoneNumber} deriving Show

-- The addressBook is a lista of Contacts
data AddressBook= AddressBook [Contact] deriving Show

-- Create a test one
ag = Agenda [Contact "BillG" 618965332, Contact "Linus" 5897458]

I wan't to write a function to search for a given phone by name and return a Maybe PhoneNumber. I know how to do this recursively on a "raw" list, but how do I access the list inside AddressBook? Also, how do I represent an AddressBook with an empty list and one with data on its list for my pattern matching?

Thanks!



_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to