[Haskell-beginners] Is there a name for the following?

Brent Yorgey byorgey at seas.upenn.edu
Mon Jun 2 01:58:20 UTC 2014


Hi Gregory,

On Sun, Jun 01, 2014 at 05:55:21PM -0400, Gregory Malecha wrote:
> Hello --
> 
> I'm wondering if there is any "name" for a functor "F" that has a function
> with the following type:
> 
> (a -> F b) -> F (a -> b)
> 
> or
> 
> (F a -> F b) -> F (a -> b)
> 
> If there is, I would imagine it being related to Applicative in some way,
> though clearly there are many Applicatives that do not have an
> implementation of this.

As for the first type, any distributive/representable functor
(http://hackage.haskell.org/package/distributive-0.4/docs/Data-Distributive.html#t:Distributive,
http://hackage.haskell.org/package/adjunctions-4.0.3/docs/Data-Functor-Rep.html)
will have such a function---that is, when F a is isomorphic to (r ->
a) for some type r.  Then it is just

  (a -> r -> b) -> (r -> a -> b)

I rather suspect that these are the *only* functors that will work,
but I'm not sure how to prove it off the top of my head.  Intuitively,
if F does not have some fixed structure, i.e. it is isomorphic to a
sum type, then (given that 'a' can be infinite) there is no way to
combine the infinitely many F structures resulting from the (a -> F b)
function into a single F structure on the right.

Relatedly, you may be interested in

  http://winterkoninkje.dreamwidth.org/81209.html
  http://hackage.haskell.org/package/countable-0.1/docs/Data-Searchable.html#t:Finite

which are very similar, although they quantify over 'a' rather than 'F'.

I do not have any good intuition about the second type.

-Brent


More information about the Beginners mailing list