Skip to content

Conversation

@fpringle
Copy link
Owner

@fpringle fpringle commented Mar 20, 2025

Re-implement gcaseR, by converting gcase (which uses Chains) to a new type ChainsR. This looks
similar to the original implementation here, but without trying to do the recursion directly via ChainsR (which seems
to be impossible with the current implementation).

The important commits are:
b79ced2 - Generalise Chains to have different return types in the inner and outer chains
5a17f25 - ChainsR is basically the same as Chains, with the arguments in a different order
48058f8 - Finally we can re-implement gcaseR

Note

This is undoubtedly more ergonomic, since it allows us to use partial application nicely:

let maybeToEither err = maybeR (Left err) Right
in  ...

However, this carries a slight performance impact. It will always be faster to use 'gcase', so if performance is critical in your use-case, use that. Then again, if performance is really critical, you'll always be better off writing your analysis function manually; or just pattern-matching directly.

Note to self

Update Changelog before merging.

@fpringle fpringle self-assigned this Mar 20, 2025
@fpringle fpringle marked this pull request as ready for review March 20, 2025 11:36
@fpringle fpringle merged commit 6437f29 into main Apr 8, 2025
10 checks passed
@fpringle fpringle deleted the gcaseR branch April 8, 2025 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants