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

Instances for Codensity (Semigroup, Monoid, numeric classes) #37

Open
Icelandjack opened this issue Apr 2, 2017 · 1 comment
Open

Comments

@Icelandjack
Copy link
Contributor

Icelandjack commented Apr 2, 2017

There are some trivial instances for Managed that could be implemented for Codensity, the Monoid instance is put to good use by Gabriel Gonzales in his Applied category theory and abstract algebra talk

instance Semigroup a => Semigroup (Codensity m a) where
  (<>) = liftA2 (<>)

instance Monoid a => Monoid (Codensity m a) where
  mempty = pure mempty

#if !(MIN_VERSION_base(5,0,0))
  mappend = liftA2 (<>)
#endif

Same with Num, Fractional, Floating.

@Atry
Copy link

Atry commented Jan 19, 2020

Why not use Ap (Codensity m) a instead?
https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Monoid.html#t:Ap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants