3 ms·
The language proudly boasts on its home page that its `head` function has the same wart as Haskell's (i.e., not handling empty lists)? Combining this with an e
by JadeNB 12y ago
The language proudly boasts on its home page that its `head` function has the same wart as Haskell's (i.e., not handling empty lists)? Combining this with an explicit use of the `Option` monad just seems like teasing.
(EDIT: Oops, I meant its "distinctive features" page http://elalang.net/About.aspx#features http://elalang.net/About.aspx#features , under "Algebraic Types".)
(It's just my assumption that it doesn't handle empty lists, because it returns the literal first element of a non-empty one; but neither the Prelude http://elalang.net/docs/Article.aspx?p=lib\prelude.htm http://elalang.net/docs/Article.aspx?p=lib\prelude.htm nor the list module http://elalang.net/docs/Article.aspx?p=lib\list.htm http://elalang.net/docs/Article.aspx?p=lib\list.htm seems explicitly to mention the `head` function on lists (as opposed to strings or sequences) at all, so it's hard to say for sure.)
- tome 12y agoThe "About" page that you linked has the code x = head xs //x is Some 1 which suggests 'head' is of type 'a -> Option a' and does not have the wart you are talking about.
- tel 12y agoThe example is a bit misleading there. To be more clear using types there's xs :: [Maybe Int] head xs :: Maybe Int
- tome 12y agoOh yeah, silly me!
- JadeNB 12y agoAs tel mentioned (https://news.ycombinator.com/item?id=9556393 https://news.ycombinator.com/item?id=9556393), this strange choice of list is why I said that combining `head` with an explicit (and, I think, misleading) use of the `Option` monad seemed like teasing.
- tome 12y agoYou're right. I wasn't looking as carefully as you were. Sorry!