Data Applicative-s can be seen as containers which can be zipped
together. A prime example of data Applicative are vectors of known length
(ZipLists would be, if it were not for the fact that zipping them together
drops values, which we are not allowed to do in a linear container).
In fact, an applicative functor is precisely a functor equipped with (pure
and) liftA2 :: (a %1-> b %1-> c) -> f a %1-> f b %1-> f c. In the case where
f = [], the signature of liftA2 would specialise to that of zipWith.
Intuitively, the type of liftA2 means that Applicatives can be seen as
containers whose "number" of elements is known at compile-time. This
includes vectors of known length but excludes Maybe, since this may
contain either zero or one value. Similarly, ((->) r) forms a Data
Applicative, since this is a (possibly infinitary) container indexed by
r, while lists do not, since they may contain any number of elements.
Remarks for the mathematically inclined
An Applicative is, as in the restricted case, a lax monoidal endofunctor of the category of linear types. That is, it is equipped with
a (linear) function
() %1-> f ()a (linear) natural transformation
(f a, f b) %1-> f (a, b)
It is a simple exercise to verify that these are equivalent to the definition of Applicative. Hence that the choice of linearity of the various arrow is indeed natural.
Instances23Applicative, …
Applicative IdentityDefined in linear-base-0.4.0 · Data.Functor.Linear.Internal.ApplicativeApplicative ReplicatorDefined in linear-base-0.4.0 · Data.Replicator.Linear.Internal.Instances · orphanApplicative ReplicationStreamDefined in linear-base-0.4.0 · Data.Replicator.Linear.Internal.Instances · orphanApplicative UrDefined in linear-base-0.4.0 · Data.Functor.Linear.Internal.ApplicativeApplicative IODefined in linear-base-0.4.0 · System.IO.LinearApplicative RIODefined in linear-base-0.4.0 · System.IO.Resource.Linear.InternalKnownNat n => Applicative (V n)Defined in linear-base-0.4.0 · Data.V.Linear.Internal.Instances · orphanApplicative f => Applicative (Data f)Defined in linear-base-0.4.0 · Control.Functor.Linear.Internal.InstancesApplicative f => Applicative (Yoneda f)Defined in linear-base-0.4.0 · Control.Functor.Linear.Internal.KanApplicative (StateR s)Defined in linear-base-0.4.0 · Data.Functor.Linear.Internal.TraversableMonoid a => Applicative (Tuple2 a)Defined in linear-base-0.4.0 · Data.Functor.Linear.Internal.ApplicativeMonad m => Applicative (StateT s m)Defined in linear-base-0.4.0 · Control.Functor.Linear.Internal.StateApplicative m => Applicative (ReaderT r m)Defined in linear-base-0.4.0 · Data.Functor.Linear.Internal.ApplicativeMonoid x => Applicative (Const x)Defined in linear-base-0.4.0 · Data.Functor.Linear.Internal.Applicative(Functor m, Functor f) => Applicative (Stream f m)Defined in linear-base-0.4.0 · Streaming.Linear.Internal.Type(Applicative m, Dupable r) => Applicative (ReaderT r m)Defined in linear-base-0.4.0 · Control.Functor.Linear.Internal.Reader(Functor g, g ~ h) => Applicative (Curried g h)Defined in linear-base-0.4.0 · Control.Functor.Linear.Internal.Kan(Monoid a, Monoid b) => Applicative (Tuple3 a b)Defined in linear-base-0.4.0 · Data.Functor.Linear.Internal.Applicative(Generic1 f, Functor (Rep1 f), GApplicative ('ShowType f) (Rep1 f)) => Applicative (Generically1 f)Defined in linear-base-0.4.0 · Data.Functor.Linear.Internal.Applicative(Applicative f, Applicative g) => Applicative (Product f g)Defined in linear-base-0.4.0 · Data.Functor.Linear.Internal.Applicative(Applicative f, Applicative g) => Applicative (f :*: g)Defined in linear-base-0.4.0 · Data.Functor.Linear.Internal.Applicative(Monoid a, Monoid b, Monoid c) => Applicative (Tuple4 a b c)Defined in linear-base-0.4.0 · Data.Functor.Linear.Internal.Applicative(Applicative f, Applicative g) => Applicative (Compose f g)Defined in linear-base-0.4.0 · Data.Functor.Linear.Internal.Applicative