An applicative functor combines computations that share a context. In Haskell, `Applicative` extends `Functor`: where `fmap` applies an ordinary unary function to a wrapped value, applicative application lets a wrapped function consume wrapped arguments. This makes a fixed sequence of parsers read several pieces of input and assemble one result. section 12.1.3 section 12.3
class Functor f => Applicative f where
pure :: a -> f a
(<*>) :: f (a -> b) -> f a -> f b
liftA2 :: (a -> b -> c) -> f a -> f b -> f c
(*>) :: f a -> f b -> f b
(<*) :: f a -> f b -> f a
{-# MINIMAL pure, ((<*>) | liftA2) #-}
The core API puts a value into a context with `pure` and applies a contextual function with `(<*>)`; `liftA2`, `(*>)`, and `(<*)` support common combinations. section 12.1.3
Use the operators according to which results a sequence should retain:
- Start a construction with `(<$>)` when mapping its first wrapped argument, then add further arguments with `(<*>)`. section 12.1.3
- Use `(*>)` to run a computation and discard its result, or `(<*)` to retain the left result while still running the right computation. section 12.1.3
- Use `pure` to lift a plain value or function into the same context; use `liftA2` for a binary function. section 12.1.3
Build a PNM header parser
A header has a fixed layout: a `P1` marker, spaces, width, more spaces, and height. Map `Header` over the first integer, sequence punctuation with `*>`, and apply the resulting wrapped constructor to the second integer. Each parser consumes input in turn; a failed parser returns its error instead of a header. `Header <$> (string "P1" *> spaces *> integer) <*> (spaces *> integer)` section 12.1.3
Applicative composition is appropriate when the parser’s structure is known before parsing begins. It cannot choose later parsing behavior from an earlier result. For a PNM format whose magic number determines whether a maximum value must be read, use `Monad` and bind instead. section 12.1.5
See failure propagation with `Maybe`
`Just (+1) <*> Just 1` produces `Just 2`, while applying the same function to `Nothing` produces `Nothing`. Chaining `pure add3 <*> Just 1 <*> Just 2 <*> Just 3` builds `Just 6`; any missing argument makes the combined result `Nothing`. section 12.1.3



