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 right/left Kan extensions for functors along themselves #32

Open
Icelandjack opened this issue Dec 30, 2016 · 1 comment

Comments

@Icelandjack
Copy link
Contributor

These instances exist already as Codensity and Density but they could be included for right/left Kan extensions of functors along themselves.

instance f~ f=> Applicative (Ran ff₂) where
  pure x = Ran (\k -> k x)
  Ran f <*> Ran g = Ran (\bfr -> f (\ab -> g (bfr . ab)))

instance f~ f=> Monad (Ran ff₂) where
  return = pure
  m >>= k = Ran (\c -> runRan m (\a -> runRan (k a) c))
-- etc.

and

instance f~ f=> Comonad (Lan ff₂) where
  duplicate (Lan f ws) = Lan (Lan f) ws
  extract (Lan f a) = f a
-- etc.

Annoyingly the same can be done for Yoneda / Coyoneda

instance (Identity ~ id, Applicative f) => Applicative (Ran id f) where
  pure a = Ran (\f -> pure (runIdentity (f a)))

-- ... 
instance Identity ~ id => Foldable (Codensity id) where
  foldMap f = foldMap f . lowerYoneda . ranToYoneda . codensityToRan

which overlaps and looks icky, is this a horrible idea?

@Icelandjack
Copy link
Contributor Author

Icelandjack commented Feb 1, 2017

Similar example?

instance p ~ q => Category (Rift p q) where
  id = Rift id
  Rift f . Rift g = Rift (g . f)

Context

a ~ b => Comonad (Context a b)
a ~ b => ComonadStore a (Context a b)

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

1 participant