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

Remove MonadFilter, and fix MonadCombineLaws #1342

Closed
wants to merge 1 commit into from

Conversation

eed3si9n
Copy link
Contributor

@eed3si9n eed3si9n commented Sep 1, 2016

Fixes #1336

The MonadCombine typeclass unifies Monad, FunctorFilter, and
MonoidK, bringing three of the lineages together. This uses the
emptiness notion introduced in MonoidK and flatMap to implement
mapFilter, along with unite.

Given that MonadCombine exists (our equivalent of MonadPlus) there's no need for MonadFilter to exist.

The laws are migrated over from MonadFilter to MonadCombine, except these laws would now check identity laws and the consistencies against the correct F.empty from MonoidK.

Fixes typelevel#1336

The `MonadCombine` typeclass unifies `Monad`, `FunctorFilter`, and
`MonoidK`, bringing three of the lineages together. This uses the
emptiness notion introduced in `MonoidK` and `flatMap` to implement
`mapFilter`, along with `unite`.

Given that `MonadCombine` exists, which is Cats equivalent of
`MonadPlus` there's no need for `MonadFilter` to exist.

The laws are migrated over from `MonadFilter` to `MonadCombine`, except
these laws would now check  identity laws and the consistencies against
the correct `F.empty` from `MonoidK`.
@mpilquist
Copy link
Member

Given that MonadCombine exists (our equivalent of MonadPlus) there's no need for MonadFilter to exist.

Can you expand on this? Doesn't this mean we can't define MonadFilter instances for monads that don't have lawful / sensible combine implementations?

@codecov-io
Copy link

Current coverage is 91.54% (diff: 88.88%)

Merging #1342 into master will increase coverage by 0.15%

@@             master      #1342   diff @@
==========================================
  Files           237        233     -4   
  Lines          3567       3550    -17   
  Methods        3502       3487    -15   
  Messages          0          0          
  Branches         64         62     -2   
==========================================
- Hits           3260       3250    -10   
+ Misses          307        300     -7   
  Partials          0          0          

Sunburst

Powered by Codecov. Last update 449e0b0...5e0165b

@eed3si9n
Copy link
Contributor Author

eed3si9n commented Sep 1, 2016

Doesn't this mean we can't define MonadFilter instances for monads that don't have lawful / sensible combine implementations?

Yes. If I want to define filter there's now FunctorFilter, so what's the use of introducing a notion of emptiness that's different from combine?

@edmundnoble
Copy link
Contributor

MonadFilter was removed in cats-mtl as @eed3si9n says because there are no laws, as well as MonadCombine because the laws are all derivable from parametricity and Alternative's laws.

@eed3si9n eed3si9n deleted the wip/remove_monadfilter branch January 2, 2018 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants