191 points · by chopin · 8y ago · 43 comments
Probably the most countercultural paragraph is the paragraph on recommending you make a fresh type rather than reuse an existing type. I think that you lose so many useful operations eschewing maybe for your uniquely named Maybe [1] that a type alias is probably a much better call there, and also captures what you meant more generically. Further, stuff like Maybe over a more specific instance works much better with valuable tools like Compose.
Similarly, the redundant constraint on Empty is the sort of thing that will only trip you up in the real world.
All in all, great article tho.
[1]: People underestimate the compiler cost of deriving instances. It adds up very fast if you derive lots of functors and foldables in your quest for unique names everywhere.
Seeing knowledgeable people comment on things written by other knowledgeable people seems to be the best way to learn how Haskell is done in the wild (i.e. anything outside the text I’m learning Haskell from at the moment)!
You can certainly do things the way Hedgehog does and it's great. I think many of the nice parts of Hedgehog are not incompatible with quickcheck.
This means these instances must be defined in standalone packages where they're necessarily orphans. The cultural prohibition against orphans means there aren't as many of these orphan instances packages as you'd like so you can end up redefining instances in every consumer project.
With the Hedgehog approach, there's no problem whatsoever with creating separate packages for these instances.
I found it understandable but for me the issue was: all the problems that author pointed out are true but you're not forced to make an instance of Arbitrary. I rarely do in my tests. But some times it really does make sense and in those cases it's nice to have.
Do you pay this price when you derive via a `newtype`? Or does GHC figure out that the instance it would write out would be identical (modulo coercions)?
Even for programs that are meant to be written and compiled once and never maintained, the programmer needs to build in their mind the whole story of the required computation, and put it in words for the compiler to transform it to low-level instructions. The clearer the programming language, the easier will be to reason about that story.
- Donald Knuth
The beauty of a declarative notation is not that you get to ditch representation of state, is that you can represent such state in a much more compact and tractable way than what is required by theoretical representations of imperative machines. Trying to do mathematical reasoning with Hoare logic is a pain in the ass.
When a value is bound in do-notation, the pattern on the
left hand side of <- might not match. In this case, this
class provides a function to recover.
https://hackage.haskell.org/package/base-4.10.1.0/docs/Contr...I'm not really sure of the future of the language. Most of the super committed community members are fans of the Haskell inspired style, which is great (its how I write Scala, personally) but I'm not sure why you'd then choose Scala over Haskell, or if you need the JVM, Eta or even Frege. The majority of 'casual' Scala people seem to use it as Kotlin with implicits more or less, and as more and more libraries and features come up for Kotlin I'm not even sure that it makes sense to use Scala for those people, given the larger backing, better tooling, easier on boarding, etc for Kotlin.