You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We use prisms for error handling a lot, an example:
instanceAsEvaluationErrorUnliftingEvaluationErrorUnliftingErrorUnliftingErrorwhere
_EvaluationError = coerced
{-# INLINE _EvaluationError #-}
--| An 'UnliftingEvaluationError' /is/ an 'EvaluationError', hence for this instance we only-- require both @operational@ and @structural@ to have '_UnliftingError' prisms, so that we can-- handle both the cases pointwisely.instance (AsUnliftingErroroperational, AsUnliftingErrorstructural) =>AsUnliftingEvaluationError (EvaluationErroroperationalstructural) where
_UnliftingEvaluationError = go . coerced where
go =
prism'
(bimap
(review _UnliftingError)
(review _UnliftingError))
(bitraverse
(reoption . matching _UnliftingError)
(reoption . matching _UnliftingError))
{-# INLINE _UnliftingEvaluationError #-}
instanceAsUnliftingEvaluationErrorBuiltinErrorwhere
_UnliftingEvaluationError = _BuiltinUnliftingEvaluationError . _UnliftingEvaluationError
{-# INLINE _UnliftingEvaluationError #-}
This all is pretty complex and I've got parts of it wrong in the past. Do we really need it? I don't think we use the matching part of any of these prisms anywhere, only the review one? So can we just make those into regular functions?
We'll lose some Template Haskell convenience that comes with prismatic error handling, but given the amount of hand-written code, maybe even that will be net positive.
Or do we use the matching part somewhere?
The text was updated successfully, but these errors were encountered:
I went over the codebase briefly and 99% of the time Prism is used for constructing data. As you said, we can probably just kill prisms entirely and write helpers/throw errors using constructors directly.
looks a lot more straight forward IMO despite it being slightly more verbose.
I also found few wrappers(like UnliftingEvaluationError) that seems extraneous, maybe those can be purged alongside with the prism.
Since error handling spans across very large part of codebase, I want to hear some thoughts. At the moment, I'm inclined to kill all prisms and make all error invocation using raw constructors.
looks a lot more straight forward IMO despite it being slightly more verbose.
It's gonna be the same level of verbosity once we merge #7110.
If you've already started writing code and my PR conflicts with yours, it took me 3 find-and-replaces to make those changes, so feel free to close the PR and make the changes yourself.
I also found few wrappers(like UnliftingEvaluationError) that seems extraneous, maybe those can be purged alongside with the prism.
Please don't change those yet, I'm not convinced it's a good idea. Let's get rid of the prisms first.
Since error handling spans across very large part of codebase, I want to hear some thoughts. At the moment, I'm inclined to kill all prisms and make all error invocation using raw constructors.
This seems to be a fairly uncontroversial opinion, but you may ask the team in Slack.
We use prisms for error handling a lot, an example:
This all is pretty complex and I've got parts of it wrong in the past. Do we really need it? I don't think we use the
matching
part of any of these prisms anywhere, only thereview
one? So can we just make those into regular functions?We'll lose some Template Haskell convenience that comes with prismatic error handling, but given the amount of hand-written code, maybe even that will be net positive.
Or do we use the
matching
part somewhere?The text was updated successfully, but these errors were encountered: