4 ms·
I found the paragraph about iterating with list comprehensions very illuminating. As someone who is just starting to learn Haskell, deciding when not to use map
by nocobot 9y ago
I found the paragraph about iterating with list comprehensions very illuminating. As someone who is just starting to learn Haskell, deciding when not to use map / filter is something where my intuitions regularly seem to be off.
- tom_mellior 9y agoI like the fact (that I didn't know before) that you can use refutable patterns in the way shown here, as filters in a list comprehension. That feels almost like logic programming.
- mrkgnao 9y agoThis is a nifty thing made possible by the MonadFail class, which defines how a monad treats or recovers from a failed pattern-match. 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/Control-Monad-Fail.html#t:MonadFail https://hackage.haskell.org/package/base-4.10.1.0/docs/Contr...
- suj1th 9y agoAs somebody who works with Scala, List comprehensions (and associated filters) were indeed a surprise to me as well when I started hacking in Haskell. Their resemblance to logic programming makes it so much more elegant, and so much easier to reason about.
- s4vi0r 9y agoHow do you feel about Scala currently? I'm a Scala dev as well who's kind of been moving away from it over the past few months. 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.
- kod 9y agoThere are plenty of people who use scala as an ML on the JVM, not as a worse Haskell. They just aren't as loud about it. If you're looking for an ML kind of experience, Kotlin is a joke, it doesn't even have pattern matching.
- suj1th 9y ago>If you're looking for an ML kind of experience, Kotlin is a joke, it doesn't even have pattern matching. Can't agree with this more. I just cannot figure the raison d'être of Kotlin.
- s4vi0r 9y agoTo me it seems sorta like reasonable Java. Tons of QoL upgrades that Java hasn't (or won't, due to compatibility issues) implemented over the years make it so that you can write Kotlin without absolutely having to rely on a massive IDE or something like project Lombok. They've got great tooling and a lot of support, and they've been adding in tons of great features (e.g inline classes/value classes coming soon). If I had to build a company today Kotlin would definitely be at the top of my list; I may love other languages much more, but Kotlin and C# are easily at the top of the developer experience imo, since they've got great tooling/ecosystem/support and both are very approachable/average languages that won't really scare anyone away like how Haskell might (despite it being one of the most underrated/most scare monegered/most misunderstood languages out there imo)
- s4vi0r 9y agoWould you care to explain more about your style? It sounds like a nice compromise, and the lack of pattern matching and HKTs in kotlin is definitely a bit of a pain point after having gotten so used to Scala and Haskell. ML on the JVM seems like a nice niche for it, but I'm not sure I really have seen libraries or Scala devs sorta advertise their style/library as ML inspired. I've seen OCaml mentioned as an inspiration to Scala before, but there are some notable differences between the two (e.g. inheritance vs structural typing)