Closed mniip closed 2 months ago
After some thought I realized the function can actually be extracted from existing profunctors
code like so:
generalizeTraversal
:: Profunctor p
=> (forall f. Traversable f => p (f a) (f b)) -> Traversal s t a b -> p s t
generalizeTraversal p trav = dimap Identity runIdentity
$ runCofreeTraversing $ wander trav $ CofreeTraversing p
The library has a
Traversing
typeclass with two methods:These two methods have default implementations in terms of each other doing some rather non-trivial manipulations with Bazaar-the-Applicative and Bazaar-the-Traversable.
However these manipulations are rather useful in other contexts, for concrete
a
,b
, andp
which need not beTraversing
itself, e.g. defining these two functions in terms of each other:One way is straightforward:
To define
bulkOf
in terms ofbulk
we need an "inverse" of($ traverse)
:Then we have:
Some things up to discussion:
lens
package instead; however this package already makes use of the mechanism; however it has to reimplement its own versions of bazaars for this? maybe bazaars have to come here altogether?generalizeTraversal
could take the monomorphicp (Baz t b a) (Baz t b b)
or the quantified(forall f. Traversable f => p (f a) (f b))
to hide the nature of its operation.generalizeTraversal
may not be a good name