-
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
Plutarch.Extra.List
and Plutarch.Extra.Ord
#580
base: master
Are you sure you want to change the base?
Plutarch.Extra.List
and Plutarch.Extra.Ord
#580
Conversation
Test will be added shortly. Added. |
20dfafd
to
ac3413e
Compare
argument returns `PJust`, the value is used in the result. | ||
-} | ||
pmapMaybe :: | ||
forall (ell :: PType -> PType) (b :: PType) (a :: PType) (s :: S). |
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.
ell?
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.
Like the capital letter of the alphabet. Calling to mind 'List'.
_ -> Nothing | ||
|
||
instance PlutusType POrdering where | ||
type PInner POrdering = PInteger |
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.
why
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.
Should this use SocttPlut?
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.
Possibly. I did the first thing that could possibly work, which seemed to perform OK, and actually allowed some optimizations (which I have measurements for).
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.
This is less efficient to match on and not really cheaper to construct. Scott-encoding is probably better.
-- | ||
-- We perform the layer parallelism sequentially; it doesn't affect the | ||
-- semantics, it just makes us sad because it's slow. | ||
psort4 :: |
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.
What's up with all this duplication? Just make a psortN
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.
The N would be a Haskell Integer
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.
It's heavily optimized by @cjay using some sorting network. You wouldn't get that performance without these.
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.
There is a huge amount of code duplication still. It seems like you can encode the sorting network as a table of numbers since the code is mostly the same. You can err for N more than 4.
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.
If you mean a table of numbers on the Haskell level, yeah it could probably be done while generating the same code on the script level, but that seems like a pointless exercise to me, unless you want to work with much larger sorting networks.
If you mean a table on the Plutarch-level, that seems useless if you want to sort arbitrary element types. If you can serialize into bytestrings then yeah, you could work with actual indices. But then you'd have to build the intermediate bytestrings. Maybe it would save significant script size on larger sorting networks, but probably with much higher execution cost.
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.
The former, it's much more succinct than adding a new function every time.
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.
Also, you can have a generic fallback for n > 4.
Do you still want this? |
Yes It would be nice to have, but not urgent. |
This PR should allow edits by maintainers now. It seems like I have to use personal fork to allow this due to some permission issue.
@kozross @peter-mlabs