Skip to content

Commit

Permalink
[Builtins] Use 'Either' in 'asConstant' (#4397)
Browse files Browse the repository at this point in the history
  • Loading branch information
effectfully authored Feb 12, 2022
1 parent e8edc83 commit afe6dcd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions plutus-core/plutus-core/src/PlutusCore/Builtin/HasConstant.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ throwNotAConstant
throwNotAConstant = throwingWithCause _UnliftingError "Not a constant"

class AsConstant term where
-- Switching from 'MonadError' to 'Either' here gave us a speedup of 2-4%.
-- | Unlift from the 'Constant' constructor throwing an 'UnliftingError' if the provided @term@
-- is not a 'Constant'.
asConstant
:: (MonadError (ErrorWithCause err cause) m, AsUnliftingError err)
=> Maybe cause -> term -> m (Some (ValueOf (UniOf term)))
:: AsUnliftingError err
=> Maybe cause -> term -> Either (ErrorWithCause err cause) (Some (ValueOf (UniOf term)))

class FromConstant term where
-- | Wrap a Haskell value as a @term@.
Expand Down

0 comments on commit afe6dcd

Please sign in to comment.