plutus
plutus copied to clipboard
Get rid of prismatic error handling?
We use prisms for error handling a lot, an example:
instance AsEvaluationError UnliftingEvaluationError UnliftingError UnliftingError where
_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 (AsUnliftingError operational, AsUnliftingError structural) =>
AsUnliftingEvaluationError (EvaluationError operational structural) where
_UnliftingEvaluationError = go . coerced where
go =
prism'
(bimap
(review _UnliftingError)
(review _UnliftingError))
(bitraverse
(reoption . matching _UnliftingError)
(reoption . matching _UnliftingError))
{-# INLINE _UnliftingEvaluationError #-}
instance AsUnliftingEvaluationError BuiltinError where
_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?