-
Notifications
You must be signed in to change notification settings - Fork 483
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
[Builtins] Fuse 'AsConstant' and 'FromConstant' into 'HasConstantIn' #4417
[Builtins] Fuse 'AsConstant' and 'FromConstant' into 'HasConstantIn' #4417
Conversation
We had to have two classes because of the way costing was aligned, but that has changed, so now we can unite these classes. I also dropped 'HasConstant', because we don't need it.
/benchmark plutus-benchmark:validation |
Comparing benchmark results of 'plutus-benchmark:validation' on '0397f83b8' (base) and 'b1d046796' (PR)
|
Damn it. |
/benchmark plutus-benchmark:validation |
Comparing benchmark results of 'plutus-benchmark:validation' on '0397f83b8' (base) and '41a1f8d29' (PR)
|
^ no change in performance. Good to know that a "harmless" equality constraint can cost us that much. Ready for review. |
-- 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 | ||
:: AsUnliftingError err | ||
=> Maybe cause -> term -> Either (ErrorWithCause err cause) (Some (ValueOf (UniOf term))) | ||
|
||
class FromConstant term where | ||
-- | Wrap a Haskell value as a @term@. | ||
fromConstant :: Some (ValueOf (UniOf term)) -> term |
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.
nit: maybe asConstant
should be toConstant
for symmetry.
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.
I use the convention of calling things that can fail as*
and things that can't to*/from*
. We have that with errors too, AsParseError
, AsTypeError
etc.
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.
Ah I see
We had to have two classes because of the way costing was aligned,
but that has changed, so now we can unite these classes.
I also dropped
HasConstant
, because we don't need it.