I found this article, and while I find some of it useful, I found several points completely disingenuous:
From the article:
config <- loadConfig config' <- validateConfig config config'' <- mergeDefaults config'
I would never write that, and I would push back in a code review. I would much rather see:
config <- mergeDefaults =<< validateConfig =<< loadConfig
Rust eliminates this class of errors by design:
enum Person { Student { name: String, university: String }, Worker { name: String, company: String }, } fn get_company(person: &Person) -> Option<&str> { match person { Person::Worker { company, .. } => Some(company), Person::Student { .. } => None, } }
That looks suspiciously like a haskell case
statement. Add {-# LANGUAGE NoFieldSelectors #-}
if you donât want field selectors.
The error handling section is disingenuous as well. You can always turn a possibly error throwing function into an Either
with try
, or an Either
into an exception with either <throw function> id
.
Unit tests as part of source code
Haskell supports this, and HLS will re-evaluate examples on the fly. Maybe the author didnât know, but it seems incredibly lazy to not have checked. You can set up a doctest to verify that the examples continue to match.
I find the section on formatting kind of petty. Pick a formatting tool and possibly a config file for you organization/project and then stick with it. If a team is bikeshedding, that sounds like a team problem instead of a haskell problem.
I donât get the problem with Linked Lists. Hey, this language that was initially built to study lazy functional programming special-cases linked lists. Theyâre slow. OK, then donât use them. Maybe thereâs a valid gripe that the default is bad if youâre both new to haskell and have a poor semantic mismatch about what [1, 2, 3]
means?
I think the gripe about a cabal file being its own syntax is completely unwarranted. If you want a standard format, then use hpack
.
Thereâs a bunch in the article that I think is spot on. I believe that the production issues described were real. I know that the cross compilation story is worse for ghc and is being worked on. I think those correct points would hit with more force if the things that were just plain false were removed, along with the points that were really trivial.