From functors that are not applicatives:
A type constructor which is a Functor but not an Applicative. A simple example is a pair:
instance Functor ((,) r) where fmap f (x,y) = (x, f y)But there is no way how to define its
Applicativeinstance without imposing additional restrictions onr. In particular, there is no way how to definepure :: a -> (r, a)for an arbitraryr.
Question 1: Why is this so? Here is how pure could work with functions f of type a -> b:
(pure f) (pure x, pure y) = (pure x, pure f y)
From there, the definition of pure :: a -> (r, a) could depend on what r is. For example, if r is Integer, then you could define
pure x = (0 :: Integer, x)
in your instance declaration. So what is the issue?
Question 2: Can we say in general that if F is a functor, then <*> can always be defined, but pure might not always be defined?