darcs

Patch 1896 move class ToFromPrim to RepoPatchV2 code

Title move class ToFromPrim to RepoPatchV2 code
Superseder Nosy List ganesh
Related Issues
Status rejected Assigned To
Milestone

Created on 2019-08-27.12:27:33 by ganesh, last changed 2019-09-27.09:07:56 by bfrk.

Files
File name Status Uploaded Type Edit Remove
move-class-tofromprim-to-repopatchv2-code.dpatch ganesh, 2019-08-27.12:27:32 application/x-darcs-patch
patch-preview.txt ganesh, 2019-08-27.12:27:32 text/x-darcs-patch
unnamed ganesh, 2019-08-27.12:27:32 text/plain
See mailing list archives for discussion on individual patches.
Messages
msg21234 (view) Author: ganesh Date: 2019-08-27.12:27:33
For discussion initially.

In principle it seems like a 'toPrim' method might be
a worthwhile part of the API of patches in general, and
I have a feeling I introduced ToFromPrim initially when
abstracting the Prim API in the first place.

But in practice it doesn't seem to be used outside V2,
and it's not obvious that other patch types should
implement it for no actual reason.

1 patch for repository darcs-unstable@darcs.net:screened:

patch f5dab200ee7599dfcb8c41c41d8e129ebf2ff559
Author: Ganesh Sittampalam <ganesh@earth.li>
Date:   Sun Aug 18 19:31:20 BST 2019
  * move class ToFromPrim to RepoPatchV2 code
  
  It's only used there and isn't currently a concept that's
  generally useful in the Darcs code as a whole.
Attachments
msg21238 (view) Author: bfrk Date: 2019-08-27.16:14:05
> In principle it seems like a 'toPrim' method might be
> a worthwhile part of the API of patches in general, and
> I have a feeling I introduced ToFromPrim initially when
> abstracting the Prim API in the first place.
> 
> But in practice it doesn't seem to be used outside V2,
> and it's not obvious that other patch types should
> implement it for no actual reason.
> 
> 1 patch for repository darcs-unstable@darcs.net:screened:
> 
> patch f5dab200ee7599dfcb8c41c41d8e129ebf2ff559
> Author: Ganesh Sittampalam <ganesh@earth.li>
> Date:   Sun Aug 18 19:31:20 BST 2019
>   * move class ToFromPrim to RepoPatchV2 code
>   
>   It's only used there and isn't currently a concept that's
>   generally useful in the Darcs code as a whole.

If it weren't for V2-Duplicates we could use toPrim to detect whether a
patch is conflicted or not. This could then be used to refactor
combineConflicts to have a simpler and more intuitive type. But this is
hypothetical and so I came to a similar conclusion some time ago.

However, a class with only one instance makes no sense. A plain function

  toPrim :: RepoPatchV2 prim wX wY -> prim wX wY

is what I'd go for.
msg21240 (view) Author: ganesh Date: 2019-08-27.16:37:32
On 27/08/2019 17:14, Ben Franksen wrote:

> However, a class with only one instance makes no sense. A plain function
> 
>   toPrim :: RepoPatchV2 prim wX wY -> prim wX wY
> 
> is what I'd go for.

The class/instance combination is needed to break the recursive knot.
The same is true of Nonable. The alternative would be hs-boot files.
msg21243 (view) Author: bfrk Date: 2019-08-27.18:53:48
>> However, a class with only one instance makes no sense. A plain function
>>
>>   toPrim :: RepoPatchV2 prim wX wY -> prim wX wY
>>
>> is what I'd go for.
> 
> The class/instance combination is needed to break the recursive knot.
> The same is true of Nonable. The alternative would be hs-boot files.

I see. But then I wouldn't move the class to RepoPatchV2, just delete
the instances we don't need and remove ToPrim from the superclasses of
RepoPatch. It is cleaner to have a class that could, in principle, be
defined for many patch types inside the general Darcs.Patch section.
(While Nonable is clearly an implementation detail of RepoPatchV2.) Also
means less churn if later we decide we need toPrim for something after all.
msg21626 (view) Author: bfrk Date: 2019-09-27.09:07:56
I have a use for toPrim for the upcoming 'convert darcs-3' command.
History
Date User Action Args
2019-08-27 12:27:33ganeshcreate
2019-08-27 12:27:39ganeshsetstatus: needs-screening -> in-discussion
2019-08-27 16:14:06bfrksetmessages: + msg21238
2019-08-27 16:37:33ganeshsetmessages: + msg21240
2019-08-27 18:53:48bfrksetmessages: + msg21243
2019-09-27 09:07:56bfrksetstatus: in-discussion -> rejected
messages: + msg21626