Effective Haskell: list-comprehension version of partyBudget has an error if food is duplicated (page 90)

Another good catch. Some of these are tricky because if you dig too much into the edge cases the example starts becoming dominated by edge case handling rather than the idea that’s being explained, but I think there’s probably a good way to handle this one.

Unfortunately, nub is probably best avoided since it’s very slow, and using it on even moderately sized lists can be really bad for performance, so it’s probably best to avoid teaching people to use it.

1 Like