Skip to content

adds asumMap to Foldable#85

Merged
chshersh merged 4 commits intokowainik:masterfrom
cronokirby:master
Oct 1, 2018
Merged

adds asumMap to Foldable#85
chshersh merged 4 commits intokowainik:masterfrom
cronokirby:master

Conversation

@cronokirby
Copy link
Copy Markdown
Collaborator

@cronokirby cronokirby commented Sep 30, 2018

Resolves #81

Not much to say here. I added imports for Alt from Applicative to be able to treat Alternative as a monoid, which made the function implementation quite simple.

Checklist:

I'm not exactly sure if I should have added anything to the hlint.dhall file for this change.

HLint

  • I've changed the exposed interface (add new reexports, remove reexports, rename reexported things, etc.).
    • I've updated hlint.dhall
      accordingly to my changes (add new rules for the new imports, remove old ones, when they are outdated, etc.).
    • I've generated the new .hlint.yaml file (see
      this instructions).

General

  • I've updated the CHANGELOG
    with the short description of my latest changes.
  • All new and existing tests pass.
  • I keep the code style used in the files I've changed (see
    style-guide
    for more details).
  • I've used the stylish-haskell file.
  • My change requires the documentation updates.
    • I've updated the documentation accordingly.
  • I've added the [ci skip] text to the docs-only related commit's name.

@chshersh chshersh requested a review from vrom911 October 1, 2018 01:42
@chshersh chshersh added Hacktoberfest https://hacktoberfest.digitalocean.com/ reexport Reexport something new labels Oct 1, 2018
Copy link
Copy Markdown
Contributor

@chshersh chshersh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cronokirby Thanks a lot for your contribution! Just couple minor things. Regarding HLint rules: I think this can go under separate issue, because the function is brand new (there's no such function on Hackage). So the set of HLint rules is not clear yet... Otherwise looks great 👍 Just requires some polishing before merging 🙂

Just 3
-}
asumMap :: (Foldable f, Alternative m) => (a -> m b) -> f a -> m b
asumMap f = getAlt . foldMap (\a -> Alt (f a))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the implementation! Probably you can even write foldMap (Alt . f). This looks readable enough to be 👍

-}
asumMap :: (Foldable f, Alternative m) => (a -> m b) -> f a -> m b
asumMap f = getAlt . foldMap (\a -> Alt (f a))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add {-# INLINE asumMap #-} pragma after this function? I guess it might be useful. Don't think it will harm.

CHANGELOG.md Outdated
Add `under2` and `underF2` functions to `Relude.Extra.Newtype`.
* [#60](https://github.com/kowainik/relude/issues/60):
Add `hoistMaybe` and `hoistEither` functions.
* [#81](https://github.com/kowainik/relude/issues/81):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for not forgetting to update the CHANGELOG! Could you please create separate entry with 0.3.1 version and move this line there? And also update version in .cabal file? 0.3.0 version is already published to Hackage, so this change is going to the next version.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right

Copy link
Copy Markdown
Contributor

@chshersh chshersh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great change!

@chshersh chshersh merged commit f69d531 into kowainik:master Oct 1, 2018
@cronokirby
Copy link
Copy Markdown
Collaborator Author

The change was made all the easier by the existing quality of your libraries! 8^)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Hacktoberfest https://hacktoberfest.digitalocean.com/ reexport Reexport something new

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants