Skip to content

Is it safe to suggest mconcat . fmap g $ xs ==> foldMap g xs ? #1339

@Javran

Description

@Javran

Spotted this refactoring opportunity that HLint doesn't warn me about:

> f g xs = mconcat . fmap g $ xs
> :t f
f :: Monoid c => (a -> c) -> [a] -> c
> :t foldMap
foldMap :: (Foldable t, Monoid m) => (a -> m) -> t a -> m

I know the type is different because of mconcat, but it is a safe thing to suggest?

Side note: just learnt fold while writing this up, which HLint does warn. So probably the real question is, is it aligned with HLint's goal to boost awareness for something like mconcat vs. fold?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions