definition theorem example program
A Tambara module on a Monoidal Category (originally: cartesian, ) is a Profunctor equipped with a family of maps
natural in and dinatural in (since appears both co- and contravariantly), preserving the monoidal structure: and . Morphisms of Tambara modules are natural transformations commuting with the ‘s; they form the Tambara category . In Haskell (cartesian case, class Strong/Cartesian):
class Profunctor p => Cartesian p where
alpha :: p a b -> p (c, a) (c, b) -- parametricity supplies all the (di)naturalitySources: DaoFP Chapter 18 (“Tambara Modules”: §18.2 “Profunctor Lenses”: “Profunctors and lenses”, “Tambara module”, “Profunctor lenses”, “Profunctor lenses in Haskell”; §18.3 “General Optics”; §18.4 “Mixed Optics”), Exercises 18.2.1, 18.4.1; §17.8 (Arrows = pre-arrows that are Tambara modules).
Why they matter. To turn the Existential Lens into a representation “map to ”, one can lift by — but first needs . That missing map is the Tambara structure.
Comonad/monad picture. is a Comonad on profunctors ( projects at ), and Tambara modules are exactly its comonad coalgebras (a coalgebra is, by continuity of hom, a dinatural family ). Its left adjoint is the Monad
with ; so the Tambara category is the Eilenberg-Moore Category of , giving the free/forgetful adjunction needed for Tannakian Reconstruction. Evaluating on the representable and applying co-Yoneda returns exactly the existential lens — hence Profunctor Optics.
- Generalizations: for the Tambara modules are
Cocartesian/Choice(alpha' :: p a b -> p (Either c a) (Either c b)) and the optics are prisms; for the action of the Day-monoidal category they give traversals; any action of a monoidal category on (an actegory), or two actions on and , gives mixed optics (DaoFP Exercise 18.4.1). - Haskell’s
Arrowis a Prearrow that is also a Tambara module (first).
Docs: plain Julia — Catlab has no dedicated API for this; related: Catlab v0.16 docs · GATlab standard library
# a Tambara structure on the function profunctor (->): alpha f = (c, a) -> (c, f(a))
alpha(f) = ((c, a),) -> (c, f(a))
alpha(x -> x + 1)((:tag, 41)) # (:tag, 42)
# on the "get/set" profunctor FlipLens a b s t = (s -> a, s -> b -> t):
alpha_lens((get, set)) = (((c, s),) -> get(s), ((c, s), b) -> (c, set(s, b)))import Mathlib
-- Tambara modules as a structure on Type-valued profunctors (cartesian case)
structure Tambara (p : Type → Type → Type) where
dimap : (s → a) → (b → t) → p a b → p s t
alpha : p a b → p (c × a) (c × b)
def tambaraFun : Tambara (fun a b => a → b) :=
{ dimap := fun f g h => g ∘ h ∘ f, alpha := fun h ⟨c, a⟩ => (c, h a) }class Profunctor p where
dimap :: (s -> a) -> (b -> t) -> p a b -> p s t
class Profunctor p => Cartesian p where -- Tambara modules for (×); library name: Strong
alpha :: p a b -> p (c, a) (c, b)
class Profunctor p => Cocartesian p where -- Tambara modules for (+); library name: Choice
alpha' :: p a b -> p (Either c a) (Either c b)
instance Profunctor (->) where dimap f g h = g . h . f
instance Cartesian (->) where alpha h (c, a) = (c, h a)
instance Cocartesian (->) where alpha' h = fmap h -- Either c is a functor