Are there any good examples of Functors which are not Applicatives? By good, I'm seeking non-trivial (not Const Void) examples which don't need appeals to undefined. If there are none is there any method of proving that the space there is uninteresting?
This is similar to Good examples of Not a Functor/Functor/Applicative/Monad?, but it wasn't completely resolved there.
As a follow-up question, are there any interesting examples of Functors which might be left without Applicative instances due to having far too many non-canonical Applicative instances to be meaningful? For instance, "extended Maybe" is a bit boring
data MayB a = Jus a | Nothing1 | Nothing2 | Nothing3 | ...
instance Applicative MayB where
pure = Jus
Jus f <*> Jus x = Jus (f x)
Jus f <*> n = n
n <*> Jus x = n
n1 <*> n2 = methodOfResolvingNothingWhatsoever n1 n2
Are there examples where the variations of the Applicative instance are more material?
data MayB a = Jus a | Nothin IntandNothin n1 <*> Nothin n2 = Nothin $ max n1 n2is how I'd implement it. Then you have a notion of the level of failure where the higher level takes precedence. Not sure where this is useful, but it's easy to encode. - bheklilrCont mis an applicative iffmis a monoid so there's a lot of functors-not-applicatives there. Essentially anything with a lot of "structure" unrelated to the parameter which we've defined functor over is going to have a hard time being an applicative. - Daniel Gratzerdata Eit b a = L b | R awithinstance Monoid b => Applicative (Either b) where L b1 <*> L b2 = L (b1 <> b2). Generally, though, there are just a whole lot of ways to merge failures and "purely applicative Either" is the closest thing I know to a canonical method. - J. AbrahamsonFunctortypeclass and not just anApplicativeone that includesfmap. - J. Abrahamson(a -> m) -> mcan be given anApplicativeinstance (modulo wrapping it in anewtype) for anymthat has an associative binary operation with an identity, not just ones that happen to have been given aMonoidinstance. - Tom Ellis