[Haskell-beginners] Question on terminology

Rein Henrichs rein.henrichs at gmail.com
Wed Mar 2 23:27:58 UTC 2016


"Co-lift" is not possible for functors generally. Comonads have a method
extract :: Comonad w => w a -> a, which is somewhat related.

Distributing and gathering are both really distributing. The first example
distributes [] over f while the second example distributes f over [].
Neither are possible for functors generally, but Applicative and
Data.Traversable are strong enough to provide sequenceA :: (Traversable t,
Applicative f) => t (f a) -> f (t a). The problem is that the Applicative
and Traversable laws alone are not enough to guarantee that this is well
behaved.

What you actually need is a stronger notion that f (g a) is an
"f-structure" containing "g-structures" *all of the same shape*. If they
aren't, the inner structures won't be distributed properly and some of the
odd shaped bits might get cut off. For example, try to transpose a list of
lists (iow, distribute [] over []) and you'll see that all of the inner
lists must be the same length for your transposition to be well behaved.
Conor McBride covers this in a very interesting way in this StackOverflow
answer: http://stackoverflow.com/a/13100857/2225384

On Wed, Mar 2, 2016 at 2:50 PM Joel Neely <joel.neely at gmail.com> wrote:

> IIUC, one would describe fmap as "lifting" a function g into a functor f,
> in the sense of
>
> Functor f => (g a b) -> g a -> g b
>
>
> Is there an inverse concept (? co-lift ?) that describes
>
> Functor f => (g a -> g b) -> a -> b
>
>
> Similarly is there standard terminology for "distributing" and "gathering"
> in the sense of
>
> Functor f => f [a] -> [f a]
>
>
> and
>
> Functor f => [f a] -> f [a]
>
>
> respectively?
>
> References much appreciated!
> -jn-
>
> --
> Beauty of style and harmony and grace and good rhythm depend on
> simplicity. - Plato
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160302/c79f453a/attachment.html>


More information about the Beginners mailing list