8 ms·
Upcoming/proposed breaking changes to Haskell
- jpe90 5y agoI remember wondering why "return" is in the Monad class when you can just use "pure" from Applicative, and why (<>) and "mapped" both exist, so it's cool to read the historical explanations here. They are all logical, but will unfortunately add to the burden of new learners who read books and guides that contain obsolete references. I know a lot of the material I learned with will be confusing when examples start spitting out compile errors. I didn't see if there are efforts to account for this with some custom error messages that notify you why the obsolete code no longer works and suggests how to fix it, but I think that would be helpful. Edit: It looks like that concern was already raised and addressed, glad to see it.
- mdm12 5y agoThe return/pure distinction is due to history, I believe. The Monad typeclass was defined before the Applicative typeclass. Part of the fun of being a research language is that you don't know everything up-front!
- quchen 5y agoMonad and Functor were first, if I remember correctly Applicative made its debut when Parsec became popular. For a long time, the hierarchy was »Functor ===> Applicative, Monad is independent«. We made Applicative a superclass of Monad around 2015, and since then return has been a historical artifact (with a dangerously misleading name).
- 1-more 5y agoty for this history! I write haskell at work but with an honestly middling understanding of the category theory that goes into what typeclasses are supersets of other typeclasses. Mostly because we use an overly verbose version of Prelude. So it's wild to me that these mathy bits were not always set in stone!
- nerdponx 5y agoIf you are interested in "Haskell, but with a nicer standard library", Idris 2 might actually be an interesting choice. The Idris 2 prelude very much feels like a cleaned-up version of the Haskell prelude, and all the fancy dependent and quantitative type stuff is mostly "opt-in". For example, in Idris 2, the `[ foo | x <- bar ]` syntax is not just a "list comprehension", but a "monad comprehension", and `map` is not specialized for lists but it is actually what `fmap` is in Haskell. There is also other interesting shorthand syntax like `!foo` which is equivalent to something like `do x <- foo ; x`. The fact that it compiles to Chez Scheme and has a fairly easy-to-use FFI is even nicer. Would I deploy it in production yet? No. But the language is trying to be fundamentally practical and user-friendly while still being dependently- and quantitatively-typed. And in my opinion, it's succeeding so far! It also has a language server, so you can get advanced interactive editing features in pretty much any code editor that supports LSP. Oh, and there's no `return` in Idris 2, only `pure` :)
- mdm12 5y agoYour description of a monad comprehension in Idris reminds me of computation expressions in F#[1]. Looks like I have one more programming language to dive into! [1] https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/computation-expressions https://docs.microsoft.com/en-us/dotnet/fsharp/language-refe...
- sullyj3 5y agoA closer analogue is probably do-notation, which comprehensions are syntactic sugar for. Comprehensions can be terser for simple expressions, but for anything longer, do notation is generally more readable.
- kaba0 5y agoIsn’t haskell’s list comprehension can be used for monad comprehensions as well with a language extension? I remember using that once.
- wk_end 5y agoI want to like Idris - as a language it does so much right - but I still feel a little burnt. A few years ago were exciting times; Idris 1 had hit 1.0 and was humming along nicely, there was excellent tooling available, & Type-Driven Development with Idris had been published - a real printed book about practical coding with dependent types! Could reliable software be far behind? Would I maybe get to develop somewhere that took software engineering seriously in my lifetime? And then, with the possibility of success on the horizon, the Idris folk(s) got distracted by the QTT hype and decided to abandon ship so they could start on Idris 2. And, like, don't get me wrong - the QTT stuff is cool, and I'm a Rust fan in part because getting to encode linearity in your types is a real superpower - but it's so depressing that the world of practical dependent types feels just as far away now as it did ten years ago, after getting so excited about it five years ago. And it underscores what might be a bigger problem: at the end of the day - and by the Idris FAQ's own admission - Idris is a research project into practical dependent types, and Edwin Brady is an academic. Which means that when he gets interested in some other area of research, he's free to just...do that instead, or start over on Idris n+1, and leave Idris 1, 2, 3 ... n to wither.
- WJW 5y agoWhat I like about Haskell is that it is unashamedly a language for programming language research, by programming language researchers. "This change needs to happens because otherwise the mathematics don't work out" would never fly in golang or Ruby if it broke backwards compatibility, but happens regularly in Haskell. This has a couple of effects: - It does make it harder to maintain code for businesses, since keeping up with language updates means that you will have to do relatively more maintenance work to keep up with these breaking changes. - It slowly makes the core libraries more and more elegant over time and this paves the way for new advances in eg type systems and whatnot. Linear types would have been way harder to add if the existing system had been (even more) a giant mess of hacks to maintain backwards compatibility 20 years back. - The ease of writing GHC extensions makes it so that it is relatively easy to extend the base language in some way and back out if it doesn't turn out to work. This makes experimentation way cheaper than if every core language change has to be "permanent". These changes combined mean that Haskell itself will probably never be a mainstream language for business applications, and that is fine. Because many (most?) programming language implementors have had some exposure to Haskell in university and because they all speak to one another on conferences etc, many of the ideas first explored by Haskell (and its predecessors in academia) are "leaking out" if they are good (like list comprehensions in Python or type classes in Rust) and they don't get taken over if they turn out to have been mistakes (like lazy I/O). The true value of Haskell is having a language in which to experiment with new concepts, so they can be proven useful (or not) before they make their way into the wild.
- yakshaving_jgt 5y ago> It does make it harder to maintain code for businesses, since keeping up with language updates means that you will have to do relatively more maintenance work to keep up with these breaking changes. To be honest — I think even in my 90KLOC Haskell codebase — handling these breaking changes are a cheap and easy change because of the compiler.
- SkyMarshal 5y agoYeah, refactoring the whole codebase in a language like Haskell is, maybe not trivial, but something the language lets you lean into, systematize, and make SOP.
- masklinn 5y agoStill no removal of head and friends eh? Sad. I think elm has shown that it’s ok to avoid functions being partial out of the box, even you’re nowhere near a total language and you certainly allow the user to create partial functions or panic / throw errors.
- dllthomas 5y agoI mostly agree, but will note that I find "head and friends" unobjectionable and sometimes convenient at the ghci prompt. I think the right solution ultimately might be different preludes geared to different things, though doing the right dance around making the right things available in the right places (and unavailable in the wrong ones) while also making it easy to understand (and remember) which context you're working in and also not splitting the community is going to be... delicate.
- sullyj3 5y agoIt could be interesting to have an `Unsafe` convenience module that is imported by default in the repl, but not in source files. Maybe that would be too confusing for beginners though.
- dllthomas 5y agoAgreed, although I don't know that "unsafe" is precisely the line to draw. Anything that is going to be tremendously more useful interactively should be considered.
- mseepgood 5y agoAfter witnessing a country sever its legs with Brexit, we now see a programming language commit suicide via breaking changes. 'Avoid success' at all costs.
- kreetx 5y agoFor those not in the know, a redundant method (/=) is removed from the Eq class and added as a regular function, and, apparently, this is making a few people very angry. (Not sure why though)
- retrac 5y agoI find it delightful, really. a /= b = not (a == b) is the kind of thing that makes Haskell beautiful. Slowly ascending to purity. Didn't break anything of mine, though.
- jez 5y agoThat is already how it's defined in the `base` package right now though: class Eq a where (==), (/=) :: a -> a -> Bool x /= y = not (x == y) x == y = not (x /= y) https://www.stackage.org/haddock/lts-18.17/ghc-prim-0.6.1/src/GHC-Classes.html#Eq https://www.stackage.org/haddock/lts-18.17/ghc-prim-0.6.1/sr... The way this works is that when you implement the `Eq` typeclass for a type, you can provide more specific implementations. A minimal complete implementation is to implement either == or /= for your type, and the other definition will apply. The way this breaks existing code (iiuc) is that as a top-level function, if you have imported the `Eq` type class but haven't imported the `Prelude` module implicitly (on by default but can be turned off), you will not have `/=` in scope anymore. I think people are upset by this less because of how hard it would be to fix, but more because of how it acts as a sort of signaling change ("they're willing to break my code for this, which I didn't want, but not for X which I did"). The most common value of X I've seen is removing or reworking the partial functions in the Prelude (e.g., head / tail on `[a]` raising an exception instead of returning `Maybe a`).
- olliej 5y agothat's a default implementation, however it's not true for every type, hence custom implementations
- 5y ago
- lngnmn2 5y agoApplicative is actually an artificial concept, much more awkward. Anyway, making a hierarchy more consistent with mathematical tradition is a good thing. As for usefulness, without redundant esoteric abstractions Monoid is all we need, and the abstract Monad type-class, of course (for building abstraction barriers at a type level). The problem with Haskell is whole Himalayas of bullshit under which its clarity and principles has been buried. Haskell became the way of "virtue" signalling for narcissistic snowflakes, second only to the Category Theory, which is, buy the way, is "empty" outside of monoidian composition and the notion of an abstract functor.
- throwaway81523 5y agoWow, some of these changes are pretty bold (eliminating ListT), and I would have off the top of my head guessed higher breakage levels than their estimate in some cases. E.g. does removing * as "type" break basically every GADT-syntax type definition everywhere? It would be great if the entries in the list each included a very brief rationale for the change. Yes I can see there is a linked document for each one, but that is a lot more reading, when in many cases a one-liner is probably enough.
- icrbow 5y agoListT removal isn't bold. It was known for a long time that it needs to go and you should use one of the explicit alternatives instead.
- olliej 5y agoI don't get replacing `/=` in Eq with `a \= b = not (a == b)` -- it seems that this would breaking floating point comparisons?