Move command errors from era-based to CmdError
module
#188
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changelog
Context
It is often better for errors to live in a module separate from other code.
For command errors in particular this is especially true.
This is because sometimes moving a function that has a error type in its signature, if that function were defined in the same module as the error type and that function needed to move, it is very often the case that the error type has to move with it.
This is especially true with commands that have a strict hierarchical structure and you wanted to push down a command into a subgroup.
If
runX
throwsError
and they both live inParent
and you want to moverunX
toChild
that requires you to move theError
type toChild
as well.If you have
runX
throwsError
andrunY
throwsError
and you wanted to moverunX
toChildX
andrunY
toChildY
,Error
can't move with both of them and you're stuck with having to do a more drastic change.In this case you're forced to move
Error
to a shared module or split theError
type.Perhaps that is one of these is the proper approach, but it doesn't change the fact that a simple move can become a more complicated change and PRs become bigger than we want them to be.
If the
Error
types were in a separate module to start with the problem doesn't arise.Over the course of Conway work, there will be a lot of restructuring of commands. Having command error types live with command functions will be very disruptive to this process and it is better to just move them out of the way to cause less pain going forward.
This PR moves these error types into
CmdError
, this does not mean this is the most ideal home for them. Just that they are not co-inhabiting with command functions and so not be in a position of triggering the bad situation.Checklist
See Running tests for more details
.cabal
files are updatedhlint
. See.github/workflows/check-hlint.yml
to get thehlint
versionstylish-haskell
. See.github/workflows/stylish-haskell.yml
to get thestylish-haskell
versionghc-8.10.7
andghc-9.2.7