Archive for December 6th, 2008

I just noticed something

Saturday, December 6th, 2008

The 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.


  1. I wanted to put pure <*> pure but when I checked this actually worked GHCi shouted at me for the second pure being ambiguous. So bleh.