Questions about profunctors, type constructors which support covariant mapping over a type parameter, like a plain functor, and contravariant mapping over a different one.
Questions tagged [profunctor]
11 questions
30
votes
2 answers
What's the relationship between profunctors and arrows?
Apparently, every Arrow is a Strong profunctor. Indeed ^>> and >>^ correspond to lmap and rmap. And first' and second' are just the same as first and second. Similarly every ArrowChoice is also Choice.
What profunctors lack compared to arrows is the…

Petr
- 62,528
- 13
- 153
- 317
16
votes
0 answers
What properties of profunctors do not make it into Haskell/PureScript?
In their paper on profunctor optics, Pickering et al. state that
The term ‘profunctor’ comes from category theory, although much of the categorical structure gets lost in translation.
That seems odd and kind of unique to me, as other algebraic…

Regis Kuckaertz
- 991
- 5
- 14
9
votes
2 answers
Generalization of strong and closed profunctors
I was looking at the classes of strong and closed profunctors:
class Profunctor p where
dimap :: (a' -> a) -> (b -> b') -> p a b -> p a' b'
class Profunctor p => Strong p where
strong :: p a b -> p (c, a) (c, b)
class Profunctor p => Closed…

M Farkas-Dyck
- 646
- 4
- 14
7
votes
1 answer
Why can't hyperfunctions be coerced in GHC?
I have the following type, which is based on the paper Coroutining folds with hyperfunctions:
newtype Hyper a b = Hyper { invoke :: Hyper b a -> b }
It's contravariant in its first argument and covariant in its second, so it's a…

Zemyla
- 468
- 3
- 7
7
votes
2 answers
Analog of free monads for Profunctors
We can define data Free f a = Pure a | Free (f (Free f a)) and so have Functor f => Monad (Free f).
If we define
data T f a b = R a | S b | T (f a (T f a b)) have we some analogous M so Profunctor f => M (T f a), where class Profunctor f where dimap…

M Farkas-Dyck
- 646
- 4
- 14
5
votes
1 answer
What's the Profunctor Representation of "Wither"?
This article by Chris Penner talks about "Witherable Optics"; Optics that can be used to filter items out from a structure.
The article uses the following "Van Laarhoven" representation for these optics:
type Wither s t a b = forall f. Alternative f…

Joe
- 1,479
- 13
- 22
2
votes
1 answer
Profunctor Iso doesn't type check
I'm trying to implement the simplest profunctor optic in Idris. Iso is a function that is supposed to be polymorphic in all profunctors. I think that's the correct syntax.
Everything type-checks, except for the final test.
interface Profunctor (p :…

Bartosz Milewski
- 11,012
- 5
- 36
- 45
2
votes
1 answer
Is there any reason why the Profunctor instance of (->) defines both dimap and lmap/rmap?
In the source code on Hackage I read this:
instance Profunctor (->) where
dimap ab cd bc = cd . bc . ab
{-# INLINE dimap #-}
lmap = flip (.)
{-# INLINE lmap #-}
rmap = (.)
{-# INLINE rmap #-}
but the default implementations of…

Enlico
- 23,259
- 6
- 48
- 102
2
votes
2 answers
Array-aggregation across a link-table in Opaleye
I'm trying to construct an Opaleye query that matches the following SQL:
select * ,
(select array_agg(tags.tagname)
from articles_tags
inner join tags on tags.id = articles_tags.tag_fk
where articles_tags.article_fk =…

Ulrich Schuster
- 1,670
- 15
- 24
2
votes
1 answer
Examples of Cartesian (Profunctor)?
I'm going through following code sample and found it hard to figure out how to use (->) and (Star f) once they implemented 'first' and became a member of Cartisian.
Could anyone provide some easy to understand examples for those? Thanks.
--…

Don Klein
- 215
- 2
- 8
2
votes
2 answers
Why is defining an instance of Choice failing with unknown value?
UPDATE: I'm inlining the code here instead.
I'm trying to define an instance of Data.Profunctor.Choice where right is defined by calling left, but for some reason the compiler complains that left is unknown.
newtype StateTrans s i o = ST (Tuple s i…

Regis Kuckaertz
- 991
- 5
- 14