Newbie working through The Book. Have done the exercises for chapter 3.
On exercise is to check whether an addressbook entry is in an addressbook when two string string (firstname and last anme) are given. (Excercise 4). My solution is:
isInBook :: String -> String -> AddressBook -> Boolean isInBook first last book = not null (filter filterEntry book) where filterEntry entry = entry.firstName == first && entry.lastName == last
This works fine. However I know if I have only one condition I can streamline this to a anonymous filter function and then write the none-explicit (eta?) function definition:
isInBook1 :: String -> String -> AddressBook -> Boolean isInBook1 first last = not null <<< filter (eq first <<< _.firstName) -- omitting test for last!
Now my question is can I do an “and-compose” on the functions
(eq first <<< _.firstName) and `(eq last <<< _.lastName) and then use this new (anonymous) function as argument to filter?