In Haskell, you can derive Functor
, Foldable
and Traversable
automatically using deriving
. There is no way to derive Applicative
, though. Considering there is one obvious way to define an Applicative
instance (which would amount to a zipped application), isn't there any way to enable deriving Applicative
?
No, this is not obvious at all. Compare the following Applicative
instances:
[]
ZipList
Data.Sequence.Seq
, whose Applicative
instance declaration runs to several hundred lines.IO
(->) r
parsec
, attoparsec
, regex-applicative
.pipes
package.There very little uniformity here, and most of the instances are non-obvious.
As David Young comments, the []
and ZipList
instances "are both, ultimately, two different, equally valid Applicative
instances for the list type."