2 ms·
Unlike some other features* , pattern matching isn't all that scary, though. "Oh, it's like a switch statement... but it can break things up and check inside...
by silentbicycle 18y ago
Unlike some other features* , pattern matching isn't all that scary, though. "Oh, it's like a switch statement... but it can break things up and check inside... that's pretty cool." You can understand it in terms of other fairly commonplace constructs, and it's relatively clear how useful it is.
It could be presented a bit differently, but the underlying idea seems approachable.
* I'm thinking of monads, in particular; whether they actually are or whether it's just due to the way they've been presented is another question.
- time_management 18y agoMonads aren't that hard. A monad is just like a burrito! Pattern matching is awesome. It makes code immensely more readable.
- silentbicycle 18y agoI started to understand monads when I compared the Maybe monad to the short-circuiting behavior of the Unix pipe. That doesn't mean my insight will work for anybody else, though. Also, having masses of Haskell blog posts saying, "No, monads are actually not that hard, here's (an explanation that probably won't actually make all that much sense)." probably doesn't help to dispel the myth that Haskell is hard / impractical / whatever.
- time_management 18y agoIn understanding monads, I think Maybe and List are the best places to start, because they're familiar data structures. IO is conceptually familiar, but IO as an immutable value representing a series of actions is not.
- silentbicycle 18y agoAgreed, strongly. Trying to understand monads in terms of IO makes things vastly more difficult than necessary.
- time_management 18y agoWell, just as "monads are like burritos", IO is like a delicious but sketchy fish taco. Eating is input. We shan't discuss the output process; we all know how it works and what it looks like. Food poisoning or poor health can lead to usage of standard error. In practice, stdout and stderr are usually redirected to the same buffer, which is flushed shortly after a write.
- ighost 18y agobrilliant.