-
Notifications
You must be signed in to change notification settings - Fork 64
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
Use SOP more #794
Open
kozross
wants to merge
4
commits into
staging
Choose a base branch
from
koz/peither-sop
base: staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Use SOP more #794
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,38 @@ | ||
{-# LANGUAGE UndecidableInstances #-} | ||
|
||
module Plutarch.Pair (PPair (..)) where | ||
|
||
import Data.Kind (Type) | ||
import GHC.Generics (Generic) | ||
import Generics.SOP qualified as SOP | ||
import Plutarch.Internal.Eq (PEq) | ||
import Plutarch.Internal.PlutusType (DPTStrat, DerivePlutusType, PlutusType) | ||
import Plutarch.Internal.ScottEncoding (PlutusTypeScott) | ||
import Plutarch.Internal.PlutusType (PlutusType) | ||
import Plutarch.Internal.Show (PShow) | ||
import Plutarch.Internal.Term (PType, S, Term) | ||
import Plutarch.Internal.Term (S, Term) | ||
import Plutarch.Repr.SOP (DeriveAsSOPStruct (DeriveAsSOPStruct)) | ||
|
||
{- | | ||
Plutus encoding of Pairs. | ||
|
||
Note: This is represented differently than 'BuiltinPair'. It is scott-encoded. | ||
-} | ||
data PPair (a :: PType) (b :: PType) (s :: S) | ||
data PPair (a :: S -> Type) (b :: S -> Type) (s :: S) | ||
= PPair (Term s a) (Term s b) | ||
deriving stock (Generic) | ||
deriving anyclass (PlutusType, PEq, PShow) | ||
deriving stock | ||
( -- | @since WIP | ||
Generic | ||
) | ||
deriving anyclass | ||
( -- | @since WIP | ||
SOP.Generic | ||
, -- | @since WIP | ||
PEq | ||
, -- | @since WIP | ||
PShow | ||
) | ||
|
||
instance DerivePlutusType (PPair a b) where type DPTStrat _ = PlutusTypeScott | ||
-- | @since WIP | ||
deriving via | ||
DeriveAsSOPStruct (PPair a b) | ||
instance | ||
PlutusType (PPair a b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
eq.true.left {"exBudgetCPU":516433,"exBudgetMemory":3001,"scriptSizeBytes":42} | ||
eq.true.right {"exBudgetCPU":516433,"exBudgetMemory":3001,"scriptSizeBytes":42} | ||
eq.false.left-right {"exBudgetCPU":400100,"exBudgetMemory":2600,"scriptSizeBytes":42} | ||
eq.false.left-left {"exBudgetCPU":516433,"exBudgetMemory":3001,"scriptSizeBytes":42} | ||
eq.false.right-right {"exBudgetCPU":516433,"exBudgetMemory":3001,"scriptSizeBytes":42} | ||
eq.true.left {"exBudgetCPU":356433,"exBudgetMemory":2001,"scriptSizeBytes":39} | ||
eq.true.right {"exBudgetCPU":356433,"exBudgetMemory":2001,"scriptSizeBytes":39} | ||
eq.false.left-right {"exBudgetCPU":240100,"exBudgetMemory":1600,"scriptSizeBytes":39} | ||
eq.false.left-left {"exBudgetCPU":356433,"exBudgetMemory":2001,"scriptSizeBytes":39} | ||
eq.false.right-right {"exBudgetCPU":356433,"exBudgetMemory":2001,"scriptSizeBytes":39} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,45 @@ | ||
eq.true.left program | ||
1.0.0 | ||
((\!0 !0 -> | ||
!2 | ||
(\!0 -> !2 (\!0 -> equalsInteger !2 !1) (\!0 -> False)) | ||
(\!0 -> !2 (\!0 -> False) (\!0 -> equalsInteger !2 !1))) | ||
(\!0 !0 -> !2 42) | ||
(\!0 !0 -> !2 42)) | ||
case | ||
!2 | ||
[ (\!0 -> case !2 [(\!0 -> equalsInteger !2 !1), (\!0 -> False)]) | ||
, (\!0 -> case !2 [(\!0 -> False), (\!0 -> equalsInteger !2 !1)]) ]) | ||
(constr 0 [42]) | ||
(constr 0 [42])) | ||
eq.true.right program | ||
1.0.0 | ||
((\!0 !0 -> | ||
!2 | ||
(\!0 -> !2 (\!0 -> equalsInteger !2 !1) (\!0 -> False)) | ||
(\!0 -> !2 (\!0 -> False) (\!0 -> equalsInteger !2 !1))) | ||
(\!0 !0 -> !1 42) | ||
(\!0 !0 -> !1 42)) | ||
case | ||
!2 | ||
[ (\!0 -> case !2 [(\!0 -> equalsInteger !2 !1), (\!0 -> False)]) | ||
, (\!0 -> case !2 [(\!0 -> False), (\!0 -> equalsInteger !2 !1)]) ]) | ||
(constr 1 [42]) | ||
(constr 1 [42])) | ||
eq.false.left-right program | ||
1.0.0 | ||
((\!0 !0 -> | ||
!2 | ||
(\!0 -> !2 (\!0 -> equalsInteger !2 !1) (\!0 -> False)) | ||
(\!0 -> !2 (\!0 -> False) (\!0 -> equalsInteger !2 !1))) | ||
(\!0 !0 -> !2 42) | ||
(\!0 !0 -> !1 42)) | ||
case | ||
!2 | ||
[ (\!0 -> case !2 [(\!0 -> equalsInteger !2 !1), (\!0 -> False)]) | ||
, (\!0 -> case !2 [(\!0 -> False), (\!0 -> equalsInteger !2 !1)]) ]) | ||
(constr 0 [42]) | ||
(constr 1 [42])) | ||
eq.false.left-left program | ||
1.0.0 | ||
((\!0 !0 -> | ||
!2 | ||
(\!0 -> !2 (\!0 -> equalsInteger !2 !1) (\!0 -> False)) | ||
(\!0 -> !2 (\!0 -> False) (\!0 -> equalsInteger !2 !1))) | ||
(\!0 !0 -> !2 24) | ||
(\!0 !0 -> !2 42)) | ||
case | ||
!2 | ||
[ (\!0 -> case !2 [(\!0 -> equalsInteger !2 !1), (\!0 -> False)]) | ||
, (\!0 -> case !2 [(\!0 -> False), (\!0 -> equalsInteger !2 !1)]) ]) | ||
(constr 0 [24]) | ||
(constr 0 [42])) | ||
eq.false.right-right program | ||
1.0.0 | ||
((\!0 !0 -> | ||
!2 | ||
(\!0 -> !2 (\!0 -> equalsInteger !2 !1) (\!0 -> False)) | ||
(\!0 -> !2 (\!0 -> False) (\!0 -> equalsInteger !2 !1))) | ||
(\!0 !0 -> !1 24) | ||
(\!0 !0 -> !1 42)) | ||
case | ||
!2 | ||
[ (\!0 -> case !2 [(\!0 -> equalsInteger !2 !1), (\!0 -> False)]) | ||
, (\!0 -> case !2 [(\!0 -> False), (\!0 -> equalsInteger !2 !1)]) ]) | ||
(constr 1 [24]) | ||
(constr 1 [42])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can be removed