[darcs-devel] Action/Command layer in between Repository and UI

Ganesh Sittampalam ganesh at earth.li
Mon Mar 29 06:51:22 UTC 2021


Hi,

On 28/03/2021 09:20, Ben Franksen wrote:
> [not sending this to the tracker as this is a general design question]
> 
> Am 27.03.21 um 22:43 schrieb Ganesh Sittampalam:
>>
>> Ganesh Sittampalam <ganesh at earth.li> added the comment:
>>
>>> A common theme here is to move stuff that has nothing to do with Repository
>>> mechanics, namely running hooks and tests, from the Repository to the UI
>>> layer, especially since running hooks may involve prompting the user.
>>
>> I see why it doesn't belong in the Repository layer, but the UI layer
>> also feels a bit wrong. Maybe this class of things does justify a new
>> layer? One idea off the top of my head would be "Action", so
>> functionality like hooks and tests could live in Darcs.Action.Hook and
>> Darcs.Action.Test respectively.
> 
> The idea of adding a layer in between Repository and UI is tempting. In
> the long run, this could be the way to provide a better API, too, by
> ridding the UI layer of most of the "semantic" stuff.
> 
> The main problem is that a lot of that is intricately interleaved with
> interactively prompting the user, which is clearly part of the CLI. I
> think we agree that the Action layer (or perhaps Command layer) should
> not have anything to do with that part. (We have talked about this
> before, in a different context.)

I think there are actually be two different concepts here.

Firstly, there's running hooks/tests. Those are fairly self-contained
operations, probably intrinsically in IO, that interact with the machine
rather than with the user. That was the kind of thing I was thinking
about being in Darcs.Action.

Secondly, there's interactive UI. For the CLI that lives in IO but for a
web interface or other GUI, it could well be some different monad. As
you say there is a lot of intricate interleaving here. We might also
need to "suspend" actions waiting for a fresh interaction from a web
browser, maybe in a lighter-weight way than with the CLI. I think that
layer does live in Darcs.UI.<something>.

That said the Darcs.Action layer actually looks like a very small amount
of code. So maybe it just needs a home without spending much time
thinking about it.

Cheers,

Ganesh



More information about the darcs-devel mailing list