[Call for Ideas] Forming a Technical Agenda

I actually found elms type errors to be confusing, something felt off and I struggled. Perhaps it’s because I’m so used to GHC’s errors?

Writing broken rust code has overall been a very nice experience though, you usually get a suggestion of “write this instead” and a link to something describing the details.

For GHC: An issue i’ve had when mentoring is the “No instance for” errors where I have to explain that, no, the solution is probably not to write an instance for this type you don’t “own”. Sometimes you do get really nice suggestions though!

    • No instance for (Show (p0 -> p0)) arising from a use of ‘print’
        (maybe you haven't applied a function to enough arguments?)
3 Likes

Yeah i found Elm errors too verbose, so you start to scan them quickly when you reach some intermediate level. The bias towards absolute beginners is maybe too much.
A useful hint (although it is hard to find a correct one sometimes) and a link to a more verbose explanation oriented to beginners could be a good balance.

3 Likes

Is it better for a non-beginner to quickly scan a verbose error message or for a beginner to have a terse message with a link to learn more? I don’t know the answer. My hunch is that a beginner is more likely to ignore the link and get frustrated than the non-beginner is to stop because of verbosity.

I’m not saying that Haskell error messages should look exactly the same as Elm’s, but I’d be more concerned about losing people due to poor quality than whether or not the message is too verbose for some.

5 Likes

why not a flag for “verbose errors with explanations” that adds the context that newer users may want and experienced users may not?

2 Likes

I’d love a flag controlling verbosity, though probably have it default to verbose because new users of a tool often aren’t aware of what they can/can’t do. A more experienced user of Haskell would not only know about the flag to reduce the verbosity of error messages but also have a better understanding of when they do or don’t want to use it.

10 Likes

I don’t think verbosity was the problem in my case. I can see this being an issue if you receive a wall of text with unclear structure, but if there’s a format that GHC sticks to I suspect I would learn to look in the “right” place eventually. E.g. clearly mark the actual error and the offending code.

There is happstack-server-tls, that is based on openssl

2 Likes

This is something i have been thinking for sometime and implemented for internal usage of Purescript (more in hacky way, not exposed outside).

Builds taking more time:

  • In watch mode (using stack), we shouldn’t be recompiling the dependencies if the function signature doesn’t change. This would apply even without watch mode.
    Eg: File1.hs
    add :: Int -> Int
    add = (+) 3
    – has been changed to
    add x = (+) 3 x
    Here, recompiling any dependencies except File1.hs doesn’t really make sense.

This Optimization can be taken forward with few right direction calls and can help in Build times.

I think ghc’s -fomit-interface-pragmas already gets you very close to this. https://downloads.haskell.org/ghc/latest/docs/html/users_guide/using-optimisation.html#ghc-flag--fomit-interface-pragmas

As a newbie (not even at ten weeks, much less ten years), I concur on documentation. I recently updated the Monads tutorial introduction, because I thought, “With so much confusion and despair still fresh in my mind, why don’t I communicate ‘I’ve been there’ before I wake up one morning thinking that monads are blindingly obvious and can no longer understand why anybody has trouble understanding them?”

https://wiki.haskell.org/All_About_Monads#What_is_a_monad.3F

… which is still too wordy, but partly because I wrote around the original text. To be honest, I still don’t quite understand monads.

Yes, the more experience you get, the more you learn what error messages mean. Here’s an example:

I am learning to translate as “add containers to build-depends” by reading MULTIPLE PARAGRAPH ERROR MESSAGES OF MINIMAL USEFULNESS (<- yes, that’s me shouting.)


C:\Users\Michael Turner\aug\app\LockerState.hs:5:1: error:
Could not load module ‘Data.Map’
It is a member of the hidden package ‘containers-0.6.0.1’.
You can run ‘:set -package containers’ to expose it.
(Note: this unloads all the modules in the current scope.)
Use -v to see a list of the files searched for.
|
5 | import qualified Data.Map as Map
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Failed, six modules loaded.

: error:
Could not find module ‘LockerState’
It is not a module in the current program, or in any known package.

As a newbie, sometimes, when I’m a little tired I go back over “Learn You …” and just type in code and run it, to solidify concepts that I didn’t solidify on a first reading. And I run into snags. This one got unsnagged after way too much time, but finally arriving at this:

Which isn’t really about my problem, but I figured, What the hell, give part of the suggested solution a try. (With some trepidation, because I feared I’d end up having to add a version number, but I didn’t, thank God.)

The error message says there’s no such module, but in fact there is – it just didn’t compile for lack of ability to resolve Map. GHC has already seen the module declaration, so this report of “does not exist” is only true in some weird mathematical sense: the module was not well-formed, therefore it is not an element of the set of modules that ghci can see.

I didn’t want to have to do “:set -package containers” every time I got into ghci. Of course, I tried “stack ghci -package containers” but I knew it wouldn’t work, because there’s some trick (which I forgot, and didn’t want to google for again) for passing flags to ghci on the stack command line.

After getting things to work in the ostensibly seamless way you’d think they should, from just following along in the newbie tutorial “Learn You …”, I fumed for a while. Was there any real reason why we can’t just use build tools from The Rest of the World? What problems unique to Haskell do stack and cabal actually solve? Why, as a newbie, must I be slowed down in learning this language by these build tools with no obvious value-added over other build tools, and the error messages stemming from them, error messages that tell you how to work around the problem, but not how to actually solve it in a more satisfactory way?

Now let me really rant:

Somewhere else on this thread, someone remarks that you can’t really learn Haskell without a mentor or two. Now, think about this. I don’t know if that’s what anyone had in mind with “avoid success at all costs”. Still, perhaps it’s an unconscious emergent property caused by that impish nostrum being taken a little too seriously. For a programming language, a virtual requirement of mentorship is ANTI-viral. Infectious diseases that require multiple, persistent sources of infection have an R0 that’s effectively negative. They’ll never become endemic, much less epidemic. And when I’m fuming over some Kafkaesque obstacle (hmm, “cabal”, hey, that’s kinda paranoid for a name, isn’t it, come to think of it?) isn’t sort of like my mental immune system is trying to reject an infection – and almost succeeding?

OK, back to it.

5 Likes

GHC should deeply embrace Rust.

  1. Begin to Convert the GHC Haskell Runtime, Currently Written in C, to Rust.

This would:
-energize/motivate work on the GHC runtime. A new Rust project will draw more community interest than an older C project.
-increase the safety of the runtime. Rust encourages/enforces best practices that can benefit even an expertly written code base
-make future contributions from novices easier to incorporate by increasing the (default) safety of their contributions as the Rust compiler itself guides novices and makes it harder and more conspicuous to write unsafe code
-create a (Rust) code base that is more complementary to Haskell code and more familiar to Haskell programmers in its style, concepts etc.
-bring to light opportunities to improve the code base simply by virtue of re-writing
-provide an opportunity to familiarize new individuals with the code base

  1. Make a First Class Haskell-to-Rust Interface.

Why?
-Advertising an excellent interface to Rust will be a great selling point for Haskell
-Haskell programmers would likely choose Rust as a performance focused language over C
-Rust is extremely complementary to Haskell for performance critical work. It has many of the same or very similar concepts which are absent in C
-Rust has an exploding ecosystem of top-quality code: extremely efficient execution speed, and safer than C [for the record: I think Haskell is more productive for writing applications with its garbage collector, it being highly refactorable, having the simplicity of pure functions, elegant syntax and powerful abstractions.]

3 Likes

No on (1). This makes rust a hard dependency on anything GHC. E.g. instead of any c toolchain, we now depend on rust, and on the platforms rust supports. We’d never be able to support a platform for which we only have C compiler.

Yes on (2). By all means let’s have a good FFI for rust.

3 Likes

GHC’s NCG or LLVM back ends already don’t support all platforms that only have a C compiler, right? And Rust is being added to GCC as a front-end, so I think that means that it will support much more platforms than GHC probably ever will.

1 Like

I’d actually bet that rust code that’s callable from C is already callable from Haskell without much hassle – my understanding is they did a pretty good job on having rust be able to produce functions adhering to the C ABI.

1 Like

That’s basically an alpha stage project that doesn’t even plan to implement the borrow checker anytime soon. It’ll likely be 5 years before this is even usable. I don’t see how that’s relevant right now.

3 Likes

There is also a little know C backend in GHC.

So I’ll remain at my stance. Good Rust FFI, sure. Rust RTS, I don’t see that any time soon. Move more of the RTS into Haskell? Maybe.

1 Like

We’ve had some experiments with this (and I assume it will grow), basically exporting a c interface to the rust libraries and then doing c ffi from haskell. I don’t know if we can have a direct rust ffi, but that’s something I’d rather like to see than a rust rts, which would also make the rust compiler a dependency to build ghc.

1 Like

An honest question: Assuming that portability would be more challenging if the GHC runtime was built with Rust, but that there would be an adequate solution to this within the next 5 years, how do we find out who could be effected in the interim? Is the maximum portability of Haskell essential at all times or could it be less portable for a few years without inconveniencing anyone too much? I honestly don’t know how actively GHC Haskell is ported to other platforms or how disruptive (or inconsequential) a temporary reduction in portability would be.

If Rust approached the portability of C, (by way of the GCC frontend project for example) would you then support having it as a “Hard Dependency”?

If and when rust becomes as ubiquitously available as C, sure we can revisit this topic. Someone is porting (or really refreshing a port) to Haiku right now. There is GHC on AIX.

I just don’t see the benefit of rust outweighing the complexity it introduces.

4 Likes