[ghc-steering-committee] #216: Qualified Do again, recommendation: accept the alternative

Simon Peyton Jones simonpj at microsoft.com
Wed May 6 09:08:41 UTC 2020

I have finally devoted some time to thinking about this properly.

TL;DR: I have made my peace with the module-qualified version.

I agree with Arnaud’s points – I have always wanted to group the operations of the builder together – but the module-qualified version is so easy to explain, understand, and implement, that I think it wins.

For me the other alternative would be to do nothing, and wait for a better idea to come along.  E.g. as the proposal points out, we may have other reasons to want fully settled types.   But it is really, really attractive to overload the do-notation for other strange monads.

My only real anxiety is that we really will think of a better plan in a few years, and then be stuck with back-compat stuff of code that uses M.do.   But maybe we should jump that bridge if we come to it.


From: ghc-steering-committee <ghc-steering-committee-bounces at haskell.org> On Behalf Of Spiwack, Arnaud
Sent: 05 May 2020 09:32
To: Joachim Breitner <mail at joachim-breitner.de>
Cc: ]Ghc steering committee <ghc-steering-committee at haskell.org>
Subject: Re: [ghc-steering-committee] #216: Qualified Do again, recommendation: accept the alternative

2. Error messages come up too.


   So you’d either get maybe

      You have qualified the do block in … with Foo.builder, but
      Foo.builder is of type Foo.Builder and the record Builder
      does not have a field named (>>).


      You have qualified the do block in … with Foo, but the module
      Foo does not export a value named (>>).

I want to stress that these, if they read as just as good English sentences, don't mean the same thing. The former says: you are using a construction, in your do notation, that your builder doesn't support. The latter says: you haven't imported the module which export this construction, which may or may not exist.

Let me make up an example. It is not the case in `base`, but let's imagine that `MonadFail` ins in a different module than `Monad`, then would have to import `Control.Monad.Fail` in addition to `Control.Monad` in order to be able to use partial pattern matching. You may argue that it is bad API design. Which would be fair, but it is hard to assume that such an event can't occur, when designing the compiler.

Neither of these arguments refute your underlying preference for
records (which I would absolutely share – if we didn't need this ad-hoc
“fully settled” and odd “any type works as long as it has the right

I think it boils down to whether the goal (records) justify the kludges
(fully settled, a desugaring that looks up some constructor K withoutusing it).

It's also a question of whether one would consider these as kludgy.  Or whether they sound rather natural to your ears. To me: rather natural, evidently. To you, and most other members of the committee, as far as I could gather, they seem to sound weird and somewhat repulsive.

(Can someone maybe just make GetField work with polytypes? Then we
woudn’t have any of this discussion, I guess.)

Cheers to that :-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-steering-committee/attachments/20200506/47ad6f87/attachment-0001.html>

More information about the ghc-steering-committee mailing list