Skip to content

[#811] Fix deriveRPC's call to customGeneric' so that field ordering is maintained

Description

Problem: deriveRPC procedure adds "RPC" prefix to fields for a type to make it RPC counterpart, before passing the new type to customGeneric' function to derive a generic instance for it. The structure of the RPC type and the shape of its generic representation is supposed to be identical to that of the original type. But the suffixing of "RPC" to the fields cause the sorting order to change, customGeneric' function ends up generating wrong methods in the generated Generic instance.

Solution: When the genericStrategy is passed to customGeneric', modify the field ordering functions to strip the "RPC" suffix before applying the sorting logic. This ensures that the field ordering remains the same as how it was in the original type.

Related issue(s)

Resolves: #811 (closed)

Checklist for your Merge Request

Related changes (conditional)

  • Tests (see short guidelines)

    • If I added new functionality, I added tests covering it.
    • If I fixed a bug, I added a regression test to prevent the bug from silently reappearing again.
  • Documentation

    • I checked whether I should update the docs and did so if necessary:
    • I updated changelog files of all affected packages released to Hackage if my changes are externally visible.

Stylistic guide (mandatory)

Edited by Sandeep.C.R

Merge request reports