Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#230] Add hoistMaybe and hoistEither functions #231

Merged
merged 1 commit into from
Aug 26, 2020

Conversation

gpevnev
Copy link
Contributor

@gpevnev gpevnev commented Aug 19, 2020

Description

Problem: Currently to lift a value ma :: Maybe a into MaybeT m a
you need to write MaybeT (pure ma), which is bloating code with
unnecessary boilerplate.
Same idea applies for Either e a and ExceptT e m a.
`

Proposed solution:
Add functions hoistMaybe :: Applicative m => Maybe a -> MaybeT m a and
hoistEither :: Applicative m => Either e a -> ExceptT e m a

Related issues

✓ Checklist for your Pull Request

Ideally a PR has all of the checkmarks set.

If something in this list is irrelevant to your PR, you should still set this
checkmark indicating that you are sure it is dealt with (be that by irrelevance).

  • I made sure my PR addresses a single concern, or multiple concerns which
    are inextricably linked. Otherwise I should open multiple PR's.
  • If your PR fixes/relates to an open issue then the description should
    reference this issue. See also auto linking on
    github
    .

Related changes (conditional)

  • Tests

    • If I added new functionality, I added tests covering it.
    • If I fixed a bug, I added a regression test to prevent the bug from
      silently reappearing again.
  • Documentation

    I checked whether I should update the docs and did so if necessary:

  • Record your changes

    • I added an entry to the changelog if my changes are visible to the users
      and
    • provided a migration guide for breaking changes if possible

Stylistic guide (mandatory)

  • My commit history is clean (only contains changes relating to my
    issue/pull request and no reverted-my-earlier-commit changes) and commit
    messages start with identifiers of related issues in square brackets.

    Example: [#42] Short commit description

    If necessary both of these can be achieved even after the commits have been
    made/pushed using rebase and squash.

src/Universum/Monad/Trans.hs Show resolved Hide resolved
src/Universum/Monad/Trans.hs Show resolved Hide resolved
@gromakovsky gromakovsky added the type:feature Something new is added. label Aug 24, 2020
Copy link
Member

@gromakovsky gromakovsky left a comment

Choose a reason for hiding this comment

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

LGTM. Please add this change to the changelog and I'll approve and merge.

@gpevnev
Copy link
Contributor Author

gpevnev commented Aug 24, 2020

@gromakovsky should I add it as a new minor version (1.7.1 for example)

@gromakovsky
Copy link
Member

If I understand PVP correctly, yes. Typically we write Unreleased in the changelog and replace it with the actual version when a new release is ready to be made, but in this case I suppose we can release 1.7.1 right after merging this PR.

Problem: Currently to lift a value `ma :: Maybe a` into `MaybeT m a``
you need to write `MaybeT (pure ma)`, which is bloating code with
unnecessary boilerplate.
Same idea applies for `Either e a` and `ExceptT e m a`.
`

Proposed solution:
Add functions `hoistMaybe :: Applicative m => Maybe a -> MaybeT m a` and
`hoistEither :: Applicative m => Either e a -> ExceptT e m a `
@gpevnev gpevnev force-pushed the gpevnev/#230-add-hoist-maybe branch from 5162044 to bdbf082 Compare August 26, 2020 09:06
@gromakovsky gromakovsky merged commit 49bc01b into master Aug 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature Something new is added.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add function to lift Maybe value into MaybeT
3 participants