8 ms·
The Meaning of Monad in MonadTrans
- bsaul 3y agoAre there any field where haskell is heavily used, beyond PL research ? I may start to look into it as some point for curiosity, but it would be nice if i'd knew that it would be at least a bit useful somewhere.
- hmry 3y agoOne production example I know: GitHub code navigation is written in Haskell https://github.com/github/semantic https://github.com/github/semantic
- runeblaze 3y agoThere are exciting practical FP usage powered by the likes of Vavr and Algebird in the JVM land. I would like to suggest looking at Scala if you are interested in the conventionally practical. For example I found Scio incredibly exciting On a more personal note, learning Haskell is more like learning FP and basic type theory, both of which are transferrable skills to most languages. How "useful" is debatable. Maps and filters you can use almost everywhere, ADTs are lacking in most languages, going into things like optics or type lambdas engineers will start feeling you are crazy but that's not even scratching the surface of PL research [This is a half-joking note. Many real-world programs are written in Haskell and OCaml, but they really are the minority]
- consilient 3y ago> ADTs are lacking in most languages Native support for ADTs is lacking, but most languages can cobble them together out of OO constructs, and they're so useful that it's often worth the inconvenience.
- tsss 3y agoAlgebird is perhaps exciting in the same way as a plane crash. The only "functional" thing about this library is its utterly pointless focus on the simple algebraic structures/typeclasses like monoids and semigroups that are shoe-horned into the API. Yes, it so happens that both HyperLogLog and BloomFilter admit some kind of monoidal structure, but that's hardly the interesting thing about them. What you get is a crappy API centered around the wrong abstraction. The whole thing feels like it was written by an intern who desperately wanted to use some algebra he learned in a freshmen class... Certainly the code quality supports that theory.
- ykonstant 3y agoFor instance, pandoc is written in Haskell: https://github.com/jgm/pandoc https://github.com/jgm/pandoc
- deleted 3y ago[deleted]
- jose_zap 3y agoHaskel is being in used in quite a few fintech companies.
- kajaktum 3y agoI am curious how that is useful at all? I imagine prototyping and the set of libraries that you have is quite limited compared to something like Python. You're also limiting yourself to a much smaller pool of developers which have to intersect both finance and Haskell! I suppose that last point is an advantage of some sort since that filters out a huge portion of "normie" applications.
- fuzzybear3965 3y agoMy understanding is "safety". You need to cover all cases of enums, you can't implicitly coerce a number to a string, you can ensure that there's no side-effects in company code, etc.
- jose_zap 3y agoI work at one of those fintech companies using Haskell in production. Hiring was actually Haskell’s strong side. I managed to hire 6 engineers in only one month. There were more than 50 applicants to the position. Just the idea of using Haskell in production is attractive to many. It’s been a great experience overall. I worked at a python company before this one and it’s been refreshing not having unexpected runtime errors. Moving money around requires more robustness than your typical app.
- Eddygandr 3y agoIOHK uses Haskell in production for the cardano blockchain - I worked there for around 18 months. Irregardless of your thoughts on blockchain tech, it was really fun to work with fairly well known Haskell developers!
- satvikpendem 3y agoHasura, the hosted GraphQL company, is built on Haskell.
- hackandthink 3y agoMaybe just a rumour: https://discourse.haskell.org/t/hasura-migrating-to-rust/6620/2 https://discourse.haskell.org/t/hasura-migrating-to-rust/662...
- iand675 3y agoMercury (https://mercury.com/ https://mercury.com/) uses Haskell extensively for pretty much all of its backend systems. It’s a great general purpose language.
- hiAndrewQuinn 3y agoMan, the FOMO. I had a friend who worked at Mercury and if I had met her just a few years later I'd probably be working as a Haskell dev there now. I had to chomp my way through _HPFFP_ first, though.
- matthews2 3y agoIf anyone else is wondering, it looks like HPFFP is "Haskell Programming from First Principles" :) https://haskellbook.com/ https://haskellbook.com/
- deleted 3y ago[deleted]
- whateveracct 3y agoIt's used professionally in "backend software development" at many companies. It doesn't dominate (it's a niche language), but it works great for that.
- mrkeen 3y agoIt looks like this article jumps right into the deep end. I'll try to speedrun some context: * You have monads in your language: - Optional, Future, Promise, List, Observable, etc. * Your language's type system can't refer to them generally. This is why you don't see the word Monad in your language. If it could, you'd see: - Optional<A> implements Monad<A> - Future<A> implements Monad<A> - etc. * Why is this important? It means you get to reuse the same (familiar!) machinery even when faced with a new library: - Turning a List<Future<A>> into a Future<List<A>> uses the same few standard library functions as: - turning a Vector<Arbitrary<A>> into an Arbitrary<Vector<A>>. * So what's the limitation of Monads? They only compose with their own concrete type: - Optional compose with Optionals. - Futures compose with Futures. - What if you want both, e.g. a FutureOptional<A>? * Monad Transformers let you stack different types of Monads on top of each other, e.g: - FutureT <Optional, A> - OptionalT <Future, A> - EitherT <L, ReaderT<E, State <S>>, R> * This means you can write functions which use features from any of those monads, but importantly, you can reuse any code written for only one of those monads: - An Optional<A> cannot become a Future<A>, but - both Optional<A> and Future<A> can trivially become FutureT <Optional, A>> - This is called lifting.
- Twey 3y agoSemi nit (but semantically quite important): not `Optional<A> implements Monad<A>`, but `Optional implements Monad`. The reason many languages can't encode the `Monad` type class correctly is due to this fact: type constructors like `Optional` (higher-kinded types, in the lingo) are second-class in a lot of languages, so you can't refer to them directly in your type class definitions/implementations. The practical upshot of this is that (similar to what's touched upon in the article) if you have a true `Monad` constraint you can use the `Monad` operations for any choice of `A` without requiring a different constraint for each possible `A` (which you would otherwise need, because there's no guarantee that `Optional<A> implements Monad<A>` implies that also `Optional<B> implements Monad<B>)`. If you have sufficient machinery available (universal constraints, basically) you can hack around the lack of HKTs by using a constraint like `forall A. Optional<A> implements Monad<A>` and having some kind of type-level map function that gets you from `Optional<A>` to `Optional<B>` for any `A` and `B`. This is the trick people use in Rust, for example.
- CyberDildonics 3y agoIf you look at a 30 year old language and people are still trying to explain one of its major mechanics, at what point do you say that it might be taking away from people being able to focus on the programs they want to write?
- worrycue 3y agoI don’t think it will affect people’s ability to write good programs - in fact it probably helps. That said, if a feature is really hard to figure out and it’s a constant pain point for newcomers … maybe it isn’t worth it … No other language seem to bother with monads to the extent Haskell does.
- chongli 3y agoPeople (high school and college students) are still struggling to understand calculus nearly 3 centuries after Newton’s death. Some topics are just difficult for many people. Does that mean we shouldn’t bother teaching them?
- CyberDildonics 3y agoCalculus is necessary. It wasn't invented as a set of restrictions, it was just just discovered and formalized. Haskell is not a discovery of something that already existed. It isn't the only programming language out there. There are dozens of examples of other languages that people use more easily. The problem was something invented, not something that has to do with the underlying principles of programming. If there are easier ways of teaching calculus, maybe those should be used. Actually that is happening now as youtube videos and web pages help visualize concepts.
- epgui 3y agoMonads are a discovery from category theory.
- CyberDildonics 3y ago
- draw_down 3y ago[dead]
- AugustoCAS 3y agoI started learning haskell about 6 months ago and I'm quite enjoying it as it requires a different mental model compared to any C-like language (Java, C#, etc). Learning Haskell has helped me to cut a good amount of BS from technologies (and engineers too). Haskell needs Monads, Transformers and more things that I don't understand yet because sometimes operations need to be sequenced. And on top of it because it's not possible to perform any non-deterministic (IO) action without telling the world about it, as any non-deterministic behaviour is wrapped in IO. I also find it interesting that Haskell feels lot more polymorphic that every statically typed OO language I know, when polymorphism is one of the pillars of OO.
- badpun 3y agoAre monads (I mean more complex than just Option) useful if my program is mostly without side effects? I get how the IO Monad is great, but what I don't really need it?
- mapM 3y agoYou can use monads to track where effects are used, and scope them. This allows you to write pure functions that uses effects in their implementation, but the users of the function need not worry about that. Some monads are also handy for structuring certain kind of code---for example, the non-determinism monad can be handy for writing searches, etc.
- adamddev1 3y agoYes! I think side-effects are just one little use-case for monads. They can be useful any time you want to compose functions together but you want to do something else with the composition and data. As Bartosz Milewski so wonderfully explained here [1], Monads are just "a way of composing special types of functions" or "function composition with some kind of flair!" I was recently writing a Unger-parser-like natural language parser and I wanted to compose functions that took the parse results from one parse function and then parse something else. I noticed that every time I wanted to pass the results to another function I had to do something with the leftover tokens and also coallate the error messages that might have been building up. What if I used monads to automatically handle the resulting tokens and error messages each time I reached for another parse function? I wrote a monadic binding function that handled the tokens and error messages for each parse function, and then I was able to happily compose my parsing functions in a much more clean and concise way. Monads are great anytime you want to do something more along with your function composition other than just passing one piece of data directly from one function to another. "And then you say... What if I used a different kind of composition? Also function composition, but with some kind of flair, something additional. If I redefine composition, I have this one additional degree of freedom in defining composition. If I use this additional degree of freedom, I am using a monad." - Bartosz Milewski [1] [1]: https://youtu.be/i9CU4CuHADQ?t=2363 https://youtu.be/i9CU4CuHADQ?t=2363
- cryptonector 3y ago