0 | module Data.Profunctor.Representable
2 | import Control.Applicative.Const
3 | import Control.Monad.Identity
4 | import Data.Morphisms
5 | import Data.Profunctor
6 | import Data.Profunctor.Costrong
7 | import Data.Profunctor.Sieve
19 | interface (Sieve p f,
Strong p) => Representable p f | p where
20 | tabulate : (a -> f b) -> p a b
25 | interface Cosieve p f => Corepresentable p f | p where
26 | cotabulate : (f a -> b) -> p a b
30 | tabulated : (Representable q f, Representable r g) => forall p. Profunctor p =>
31 | p (q a b) (r a' b') -> p (a -> f b) (a' -> g b')
32 | tabulated = dimap tabulate sieve
35 | cotabulated : (Corepresentable q f, Corepresentable r g) => forall p. Profunctor p =>
36 | p (q a b) (r a' b') -> p (f a -> b) (g a' -> b')
37 | cotabulated = dimap cotabulate cosieve
46 | Representable Morphism Identity where
47 | tabulate f = Mor (runIdentity . f)
52 | [Function] Representable (\a,b => a -> b) Prelude.id
53 | using Sieve.Function Strong.Function where
57 | Functor f => Representable (Kleislimorphism f) f where
61 | Functor f => Representable (Star f) f where
65 | Representable (Forget r) (Const r) where
66 | tabulate = MkForget . (runConst .)
69 | Corepresentable Morphism Identity where
70 | cotabulate f = Mor (f . Id)
72 | namespace Corepresentable
76 | [Function] Corepresentable (\a,b => a -> b) Prelude.id using Cosieve.Function where
80 | Functor f => Corepresentable (Costar f) f where
81 | cotabulate = MkCostar
84 | Corepresentable (Coforget r) (Const r) where
85 | cotabulate = MkCoforget . (. MkConst)