-
-
Notifications
You must be signed in to change notification settings - Fork 412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add MkHandler
pattern synonym
#1733
Add MkHandler
pattern synonym
#1733
Conversation
This bidirectional pattern synonym makes it easier to build `Handler a` values from `IO (Either ServerError a)` values, and is a complement to the already existing `runHandler` function. Solves haskell-servant#1732.
I think this is a breaking change per PVP, not sure if we are still making changelog.d entries or not. Another maintainer might want to weigh in. |
Yes please produce a changelog.d entry! :) |
Regarding the PVP breaking change, @ysangkok would I love to hear your rationale, this isn't immediately clear to me why it would be such a change. |
Oh you're right @tchoutri , it's not a breaking change according to the PVP flow chart to only add constructors/functions/non-orphan instances. And I suppose a pattern is like a constructor. |
So, in my book, adding a (public) constructor can lead to breakages when consumers do total case matches on the value. Patterns are less prone to provoke breakages when added. |
According to the PVP:
Adding a new constructor to an exported datatype is definitely a breaking change. Exhaustive pattern-matches in client code would suddenly become non-exhaustive. However, I don't think adding a wholly new pattern synonym is a breaking change. Existing pattern-matches will be unaffected. I guess it could be a breaking change, if some existing set of pattern synonyms were declared |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please write a changelog.d entry. :)
yep, that's not our case here :) |
This bidirectional pattern synonym makes it easier to build
Handler a
values fromIO (Either ServerError a)
values, and is a complement to the already existingrunHandler
function.As an alternative to this, I also considered re-exporting the
ExceptT
constructor, but I think it's better to have an explicit pattern synonym.ExceptT
is not exactly an internal implementation detail, but it's sufficiently close to being one.As for naming the pattern synonym, I considered
HandlerT
but it would be a bit misleading becauseHandler
is not really a monad transformer. The prefix isMk
instead ofMake
because other parts of the Servant ecosystem (like safe links) have already settled onMk
.Solves #1732.