What is the meaning of the Extend type class in Haskell?

Haskell has a class like Extend .

The class is defined as

class Functor w => Extend w where
    extended :: (w a -> b) -> w a -> w b

Each instance of a class Extendmust have the following properties:

extended f . extended g = extended (f . extended g)

I see his resemblance to Functor. In particular, the property is Functor fmap f . fmap g == fmap (f . g)similar to Extend.

How would you interpret Extend? What is its significance? Is it easy to do? What abstractions are performed when used Extend?

+4
source share
1 answer

Extend Comonad extract. " comonad", . , " ". , -, , , Extend . Neighborhood of Infinity comonads .

Monad Applicative, . Bind Monad, return, Apply - Applicative, pure. semigroupoids, .

, comonad, duplicate = tails extract = head. extend f = fmap f . duplicate. , NonEmpty, , extract = head . duplicate Extend, [] Extend, Comonad. ( @phadej !)

+8

Source: https://habr.com/ru/post/1692332/


All Articles