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

> all you’re going to do is pattern match on its result to check if it’s a Just

Something is eventually going to pattern match on it. But it might well be some handler way way up at the top of my program, and all I want to do right now is `map` and `bind` as normal.



Then you're clearly not using head. For this you can use listToMaybe.

Don't change the meaning of an identifier to something meant for a completely different use. The alternative change involving dependent types or liquid types doesn't break existing code. Changing head so that it returns a Maybe breaks code, because its use case is different.


I'm not using head, because I know Haskell well. But someone new to the language is never, ever, ever going to intuit that you get the head of a list with `listToMaybe` and `head` actually means `unsafeHead` and should almost never be used.

> Changing head so that it returns a Maybe breaks code

Of course. So did `Applicative`. So did `Foldable` and `Traversable`. So will removing (/=) from Eq, whenever that actually gets merged - and that was imo a far, far less problematic wart than having partial functions in Prelude. Breaking changes need to be made very carefully and very slowly: simplified subsumption was terribly handled, if not an outright mistake. But refusing to make them at all is how you get C++.


> But someone new to the language is never, ever, ever going to intuit that you get the head of a list with `listToMaybe`

They don't have to. Pattern matching is one of the first things they will learn, so they can use that instead.

> and `head` actually means `unsafeHead` and should almost never be used.

They don't need to intuit it. The next version of base will have a warning on `head` telling them to use a safer alternative instead.

By the way, the Haskell community is currently struggling to accept that it should make fewer breaking changes, in order to become a more stable platform for industry use. We're definitely not going to start breaking more code!




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

Search: