Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The x:xs one is fine as long as it's properly explained in the tutorial - e.g. it's a list of items, with x being the first item and xs being all other items in the list.

The

map :: (a -> b) -> [a] -> [b]

may well be abundantly clear once you understand Haskell's types, but is rather less so when you're first learning. In that particular case, I'm not entirely sure I could come up with a clearer set of names, but there's plenty of times when I was first learning that I really struggled with getting to grips with a concept simply because the naming left me wondering why I was passing an A into a Q to get a list of Zs (or whatever it was).



I'm not sure how specific to Haskell this actually is, though. Think of templates in C++ (esp. template functions) or generics in Java. You use T or whatever as a placeholder for actual types. Any time you need more than one type, you're forced to make a similar decision about how to describe a type about which you know very little.

It's is a heck of a lot more concise than either of those, though. Might this be the actual stumbling block? You're saying a lot about map -- in a very precise way, mind you -- without writing a lot.


C++ templates and generics are relatively advanced features though. I wouldn't be expecting to teach them in lesson 2 of the langauge.

And what you would call a parameter in a production app is not necessarily the same you'd call it in a tutorial.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: