views:

130

answers:

2

Why is the function for lifting a value into a functor named pure in Control.Applicative?

+10  A: 

Think pure as an adjective.

foo <*> pure 4 = "foo" applied on a "pure" value "4".

(As for the exact reason why it's called pure, probably only McBride and Paterson will know.)

KennyTM
Thanks. I was sort of wondering about the *why*, but if I understand you right, that's pretty arbitrary.
Jonathan Sterling
+4  A: 

It's a little like fromInteger. Its argument is always a pure value or function that will be lifted into the functor. Perhaps it should have been fromPure but you know how Haskell people love to shorten names (e.g. fst and snd instead of first and second...).

Neil Bartlett
Note that `first` and `second` are functions too, in `Control.Arrow`. I'm pretty sure they came later though.
John
Hmm. I thought `fst` and `snd` came from ML, but that's based only on the fact that ML is older than Haskell. A quick search reveals a paper ["ML under Unix on the VAX"](http://lucacardelli.name/Papers/MLUnix.pdf) that appears to be from the mid-80s (it cites no references newer than 1983, and tells how to install ML from a tape). The paper uses `fst` and `snd`, so it looks like my assumption wasn't too far off.
Nathan Sanders
`fst` and `snd` have been in Haskell since I started using the language (1992) and Hughes paper introducing arrows came out in 2000. I would name the arrow functions `onFirst` and `onSecond`, I guess.
yatima2975