I'm new to Haskell and what really bothers me at the moment is why the people who made the libraries added functions called fst
and snd
instead of using (normal) names like first
and second
. What's wrong with the latter names?
Personally I find these abbreviations ridiculous:
"Why snd
? Why not sec
, scnd
or scd
? Or why not fir
, frst
, ft
or frt
?"
It just lacks style. (But again - that's a personal opinion)
It's clear the names were chosen to be 3 characters long whilst being as clear as possible as to the word - miss out all but the most prominent consonants. A lot of the standard functions have better/easier-to-follow names, but admittedly not all!
It's historical accident, really, what the names were, and there's not a lot we can do about it without annoying a lot of people who have got used to them and have a large code base relying on them. At least Haskell didn't call search grep!
Feel free to write first = fst
and second = snd
at the top of your file - it won't take long to use your preferred name, and ghc -O2
will compile them out.
first
and second
are actually used for something more complicated in Control.Arrow but you don't need to go that deep at this stage.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With