-
Notifications
You must be signed in to change notification settings - Fork 479
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
Add Delay type and use it #5910
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
346 | ||
343 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
{-# LANGUAGE RankNTypes #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
{-# OPTIONS_GHC -Wno-unused-foralls #-} | ||
module PlutusTx.Utils where | ||
|
||
-- We do not use qualified import because the whole module contains off-chain code | ||
import PlutusTx.Builtins.Internal qualified as BI | ||
import Prelude as Haskell | ||
|
||
mustBeReplaced :: String -> a | ||
mustBeReplaced placeholder = | ||
error $ | ||
"The " <> show placeholder <> " placeholder must have been replaced by the \ | ||
\core-to-plc plugin during compilation." | ||
|
||
-- | Delay evalaution of the expression inside the 'Delay' constructor. | ||
newtype Delay a = Delay (forall b. a) | ||
|
||
-- | Force the evaluation of the expression delayed by the 'Delay'. | ||
force :: Delay a -> a | ||
force (Delay a) = a @BI.BuiltinUnit | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mysteriously it compiles without it, but I think it's better to be explicit about doing the type instantiation. |
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.
@michaelpj what is the purpose of
forall b
here? I'd appreciate a comment.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.
Sure.