News for hackers. Stuff that matters.
Re:Upcoming/proposed breaking changes to Haskell by nerdponx on Wednesday November 17, 2021 @08:57AM (#29252985)
If 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` :)

Re:Upcoming/proposed breaking changes to Haskell by wk_end on Wednesday November 17, 2021 @02:00PM (#29257350)
I 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.

Re:Upcoming/proposed breaking changes to Haskell by mdm12 on Wednesday November 17, 2021 @10:09AM (#29254034)
Your 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-refe...

Re:Upcoming/proposed breaking changes to Haskell by sullyj3 on Wednesday November 17, 2021 @05:39PM (#29259772)
A 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.
Re:Upcoming/proposed breaking changes to Haskell by throwaway81523 on Wednesday November 17, 2021 @02:18PM (#29257587)
GHC has monad comprehensions with an extension, {-# LANGUAGE: MonadComprehensions #-}

GHC has an enormous amount of machinery to infer types and check equality automatically. I wonder if Idris has anywhere near that much. Automatic inference is why Haskell resisted dependent types until quite recently, though there were already some cases that it couldn't do automatically.

As for pure vs return, that's because the typeclass system was rearranged pretty recently. Before that, Monad instances weren't necessarily also Applicative. "return" was kind of cool in that you could write what looked like imperative subroutines that returned values.

!foo in Idris sounds like foo >>= whatever or whatever =<< foo in Haskell.

Re:Upcoming/proposed breaking changes to Haskell by nerdponx on Wednesday November 17, 2021 @03:59PM (#29258747)
> GHC has an enormous amount of machinery to infer types

Idris 2 has more or less no type inference at all. I think maybe type inference for dependent types isn't decidable, or something like that?

But I know that they are interested in adding inference to Idris 2 in certain cases that can be proven to work correctly.

It's definitely a deficiency in the Idris user experience vs the Haskell user experience.

> !foo in Idris sounds like foo >>= whatever or whatever =<< foo in Haskell.

Idris has >>= as well. But see here for a nice demo of ! and other "do"-related syntax: https://idris2.readthedocs.io/en/latest/tutorial/interfaces....

Re:Upcoming/proposed breaking changes to Haskell by sullyj3 on Wednesday November 17, 2021 @05:16PM (#29259581)
Yep, type checking clearly can't be decidable, since the type system is turing complete.

Imo inference is a bit overrated anyway. I find annotations to be very useful.

There's a series of steps here:

- "Static type annotations are too verbose, dynamic languages allow you to avoid the ceremony." - "But Hindler Milner type systems can infer the types, so you usually don't have to write the type annotations!" - "Writing type annotations is useful anyway, because it serves as valuable documentation, makes reasoning about the program easier, and results in more useful type errors."

Thinking about it more now, there's another step: - "If you have good type inference, you can use editor tooling (eg the LSP) to automatically insert the type signatures for you!"

Re:Upcoming/proposed breaking changes to Haskell by throwaway81523 on Wednesday November 17, 2021 @05:48PM (#29259856)
Top level type annotations in Haskell are very helpful, but with no type inference, you would also have to annotate every intermediate term in the program, which would be intolerable. Remember that the programs are essentially typed lambda calculus, so every term must have a type. Normally you let the compiler figure out all or almost all of the types.

Part of the usefulness of top level annotations in Haskell is that if your program has a type error, inference can fail in multiple ways. I.e. the unification algorithm might assign type T to your function F and chug along happily until it runs into a conflict in some unrelated part of the program, then throw an unhelpful error message in the case where T wasn't the type that you intended for F. By annotating F with the type you really want, you get an error message that does a better job pinpointing the problem.

This is less of an issue in ML, since ML's type system is less general than Haskell's, so the inference algorithm can't go as crazy, and you usually get good error messages even without annotations.

Re:Upcoming/proposed breaking changes to Haskell by sullyj3 on Wednesday November 17, 2021 @08:51PM (#29261195)
Yeah, I definitely wouldn't want to argue against having type inference at all. I agree that you don't want to annotate every single local definition (although I'd probably lean towards annotating more often than most).

I'm more saying that I'm fine with type system features that break global inference, as long as there's still local inference that's usually good enough in practice.

Re:Upcoming/proposed breaking changes to Haskell by throwaway81523 on Wednesday November 17, 2021 @09:03PM (#29261256)
Right, but local inference is also complicated. So the question is how much of it Idris manages to do without manual annotations. It's not even limited to local definitions with names. If you fully annotate "a=b+2" you get something like "a:int = a:int +:(int->int->int) 2:int". The compiler makes an expression tree and every node in the tree has to get an annotation, either from the source text (i.e. manually) or through inference.
Re:Upcoming/proposed breaking changes to Haskell by cdsmith on Thursday November 18, 2021 @11:54AM (#29267593)
One of the most important lessons learned by the Haskell community is that we shouldn't worry about whether complete type inference is possible. We should worry about whether type inference can be maintained in the easy cases, while falling back to explicit annotation for the hard cases. All of rank-n types, GADTs, type families, even basic type classes, break complete type inference. The solution has always been to document the limitations, draw as clear a line in the sand as possible, and then go on and introduce those features. This doesn't affect the usability of the language.

What does affect the usability of the language is when (a) the line in the sand isn't very clear from an end-user point of view [see simplified subsumption in GHC 9, for example], or (b) the line is on the wrong side of simple features [see monomorphic local bindings, for example].

I guess what I'm saying is that Idris having minimal type inference is kind of terrible, and the excuse that it's not decidable for dependent types is a flimsy one.

Re:Upcoming/proposed breaking changes to Haskell by sullyj3 on Wednesday November 17, 2021 @05:34PM (#29259730)
There are many things I like about Idris 2. I think I'll be more inclined to take it seriously as a practical language once it has the equivalent of Hackage, hoogle, and cabal. Right now I can't even read the standard library docs, I have to browse the github source. And I have no idea how I'd go about depending on a package. I'm sure I could figure it out, but I assume at this stage it's fairly tedious.
Re:Upcoming/proposed breaking changes to Haskell by kaba0 on Wednesday November 17, 2021 @01:04PM (#29256520)
Isn’t haskell’s list comprehension can be used for monad comprehensions as well with a language extension? I remember using that once.