[darcs-devel] [patch2163] substantial rewrite of 'darcs test'

Ben Franksen bugs at darcs.net
Wed Apr 21 13:24:29 UTC 2021


Ben Franksen <ben.franksen at online.de> added the comment:

>> I find it sad that in order to use the indexed monad in practice we have
>> to convert large parts of the code to continuation passing style.
> 
> Yes, it is a bit unfortunate. I'm not sure if it's fundamental to the
> indexed monad or just the situation in 'test' where we end up
> manipulating a lot f patches with unknown witnesses.

I fear this is a fundamental limitation. We have lots of code handling
patches with (partially) unknown witnesses and in almost all cases this
can be handled simply by wrapping results with some variant of Sealed.
This cannot be done here because we need the hidden result witness to
coincide with one of the monad indices, while still not exposing the
type variable to the outside. I haven't found a way to make this
type-check and neither, it appears, have you.

Perhaps this will improve when the current work on re-adding
impredicativity to ghc
(https://www.microsoft.com/en-us/research/publication/a-quick-look-at-impredicativity/)
becomes available; it may or may not be a coincidence that making it
work with do-notation is one of the remaining stumbling blocks
(https://gitlab.haskell.org/ghc/ghc/-/issues/18126).

> It's worth mentioning that some form of this is happening pretty much
> everywhere in the logic, including in the backoff/bisect
> implementations, e.g. moveHalfNewer etc.

Yes. My concern is that this makes the new code pretty much inscrutable
for the average Haskell programmer, myself included. We'll have to see
how much that affects my ability to make changes to the code e.g. adapt
it to changes I make elsewhere.

> the witnesses have
> defeated me. So I'm just going to document what I have, and of course
> make any other cleanups that occur to me on the way.

Yes, I think ATM this is all we can do.

In the long run I think we may have to re-think the idea of defining
patch application as a monadic action. With a pure apply method that
works over a witness typed ApplyState we wouldn't need an indexed monad
to get the more precise typing we desire. The main question is how to
make this work without keeping too much of the ApplyState in memory.

__________________________________
Darcs bug tracker <bugs at darcs.net>
<http://bugs.darcs.net/patch2163>
__________________________________


More information about the darcs-devel mailing list