Skip to content

Commit

Permalink
Make it work
Browse files Browse the repository at this point in the history
  • Loading branch information
effectfully committed May 27, 2024
1 parent 8d136bb commit 5a639ab
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,10 @@ instance tyname ~ TyName => KnownTypeAst tyname DefaultUni Void where
instance UniOf term ~ DefaultUni => MakeKnownIn DefaultUni term Void where
makeKnown = absurd
instance UniOf term ~ DefaultUni => ReadKnownIn DefaultUni term Void where
readKnown _ = throwing _UnliftingError "Can't unlift to 'Void'"
readKnown _ =
throwing
(_BuiltinUnliftingEvaluationError . _StructuralEvaluationError)
"Can't unlift to 'Void'"

data BuiltinErrorCall = BuiltinErrorCall
deriving stock (Show, Eq)
Expand Down
1 change: 1 addition & 0 deletions plutus-core/plutus-core/src/PlutusCore/Builtin/Result.hs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ instance Wrapped UnliftingError

instance AsEvaluationError UnliftingEvaluationError UnliftingError UnliftingError where
_EvaluationError = _UnliftingEvaluationError . _EvaluationError
{-# INLINE _EvaluationError #-}

instance (AsUnliftingError operational, AsUnliftingError structural) =>
AsUnliftingEvaluationError (EvaluationError operational structural) where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ mtraverse makeClassyPrisms
instance structural ~ MachineError fun =>
AsMachineError (EvaluationError operational structural) fun where
_MachineError = _StructuralEvaluationError

-- TODO: state the assumption, rename 'MachineError'
instance AsUnliftingError (MachineError fun) where
__UnliftingError = _UnliftingMachineError

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ import UntypedPlutusCore.Evaluation.Machine.Cek.CekMachineCosts (CekMachineCosts
CekMachineCostsBase (..))
import UntypedPlutusCore.Evaluation.Machine.Cek.StepCounter

import Control.Lens (iso)
import Control.Lens.Review
import Control.Monad (unless, when)
import Control.Monad.Catch
Expand Down Expand Up @@ -405,6 +406,9 @@ data CekUserError
deriving stock (Show, Eq, Generic)
deriving anyclass (NFData)

instance AsUnliftingError CekUserError where
__UnliftingError = iso (UnliftingError . display) (const CekEvaluationFailure)

type CekM :: (GHC.Type -> GHC.Type) -> GHC.Type -> GHC.Type -> GHC.Type -> GHC.Type
-- | The monad the CEK machine runs in.
newtype CekM uni fun s a = CekM
Expand Down

0 comments on commit 5a639ab

Please sign in to comment.