I just noticed something
Saturday, December 6th, 2008The applicative functor instance for (r ->) is:
instance Applicative ((->) r) where pure = const f <*> g = \x -> f x (g x)
Look familiar? Of course, I is missing, but it’s just pure <*> undefined1 (or id but that’s cheating) anyway.
I dunno what implications this has, other than that you could in theory write a whole program with just pure and (<*>) if you really wanted. But then it is 5.50am so there’s probably something obvious I’m just not seeing.
-
I wanted to put
pure <*> purebut when I checked this actually worked GHCi shouted at me for the secondpurebeing ambiguous. So bleh. ↩
