# Pastebin IeHn3hi9 import Data.Function ((&)) example :: [(String, [String])] example = [ ("apple", ["crisp", "juicy", "floury"]), ("banana", ["fresh", "rotten"]) ] alistModify :: Eq k => k -> (Maybe v -> Maybe v) -> [(k, v)] -> [(k, v)] alistModify key f [] = case f Nothing of Nothing -> [] Just v -> [(key, v)] alistModify key f ((k, v) : xs) | key == k = case f (Just v) of Nothing -> xs Just v' -> (k, v') : xs | otherwise = (k, v) : alistModify key f xs example' :: [(String, [String])] example' = example & alistModify "banana" f where f Nothing = Just ["tasty"] f (Just xs) = Just ("tasty":xs)