Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meaning of "closed under composition"

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

What does that actually mean ?

like image 582
Sibi Avatar asked Apr 16 '14 08:04

Sibi


2 Answers

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.

like image 163
hammar Avatar answered Nov 20 '22 00:11

hammar


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

like image 12
Tom Ellis Avatar answered Nov 20 '22 01:11

Tom Ellis