سؤال

I have been reading this paper and it is mentioned there that the Applicative class is closed under composition.

What does that actually mean ?

هل كانت مفيدة؟

المحلول

In general, "X is closed under Y" means that if you take some Xs and Y them, the result is an X. For example, "the set of integers is closed under addition" means that if you take two integers and add them, the result is an integer.

Therefore, saying that the class Applicative is closed under composition means that if you take two applicative functors and compose them, the result is also an applicative functor.

نصائح أخرى

The composition of Applicatives f and g is

newtype Compose f g a = Compose { getCompose :: f (g a) }

and "Applicative is closed under composition" means that this newtype itself has an Applicative instance.

http://hackage.haskell.org/package/transformers-0.3.0.0/docs/Data-Functor-Compose.html

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top