by shermantanktop · 2y ago · 0 comments
The people who do it can’t stop talking about how great it was, but also can’t really explain why it was so great, and when they try it just sounds ridiculous, maybe even to them. And then they finish by saying that you should drop acid too and then you’ll understand.
I like it when
assertTrue (f x) -- passes in test
means that assertTrue (f x) -- passes in prodThe "test/prod" was an unnecessary detail - there's really nothing saying that f(x) will equal f(x) in most languages in most circumstances! It can return different things on repeated calls to it, it can behave differently if two threads call into it at once.
It's a major part of the reason people don't see the appeal of Haskell. They think they already have "type-safety" and "functional stuff" and "generics" and "null-safety" - but it's really not the same.
But I didn't mean purity in that formal sense. I meant that Haskell is plenty pragmatic in its design.
A better example of impurity in Haskell for pragmatic's sake is the trace function, that can be used to print debugging information from pure functions.
you can still have total functions that don't finish in humanly/business reasonable amount of time.
For anyone else reading - you don't need to make a copy if you know your data isn't going to change under your feet.
https://dev.to/kylec32/effective-java-make-defensive-copies-...