Why is the function for lifting a value into a functor named pure
in Control.Applicative?
views:
130answers:
2
+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
2010-08-08 17:31:48
Thanks. I was sort of wondering about the *why*, but if I understand you right, that's pretty arbitrary.
Jonathan Sterling
2010-08-08 20:38:54
+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
2010-08-09 14:13:28
Note that `first` and `second` are functions too, in `Control.Arrow`. I'm pretty sure they came later though.
John
2010-08-09 15:35:27
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
2010-08-10 04:54:46
`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
2010-08-10 09:14:33