Skip to content

Rewrite deserialiseFromCBOR using asum with Alternative Maybe#1130

Draft
Copilot wants to merge 7 commits intomasterfrom
copilot/sub-pr-1122
Draft

Rewrite deserialiseFromCBOR using asum with Alternative Maybe#1130
Copilot wants to merge 7 commits intomasterfrom
copilot/sub-pr-1122

Conversation

Copy link
Contributor

Copilot AI commented Mar 12, 2026

  • Previous implementation using asum with Alternative Maybe
  • Extract tryNativeScript named helper (point-free)
  • Extract tryPlutusScript named helper (flat do-notation in Maybe monad)
  • Replace maybe (Left ...) Right with maybeToRight combinator
  • Replace either (const Nothing) Just with rightToMaybe combinator
  • Extract error value as named noParseError constant
  • Code review — no issues found

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Jimbo4350 and others added 5 commits March 11, 2026 09:36
Add HasTypeProxy and SerialiseAsCBOR instances for AnyScript era,
enabling CBOR serialisation/deserialisation of both simple and plutus
scripts using the ledger's native Script era encoding format.

Closes #1088
Uses eqT to handle the existential lang in AnyPlutusScript, delegating
to the underlying Eq instances on SimpleScript and PlutusScriptInEra.
Also adds Typeable lang constraint to the AnyPlutusScript constructor.
Adds genAnyScript and genSimpleScriptInEra generators, along with
roundtrip and garbage-input property tests for SerialiseAsCBOR AnyScript.
Co-authored-by: carbolymer <228866+carbolymer@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 12, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • chap.intersectmbo.org
    • Triggering command: /usr/bin/curl /usr/bin/curl REDACTED --output /tmp/transportAdapterGet4053-7 --location --write-out %{http_code} --user-agent cabal-install/3.16.1.0 (linux; x86_64) --silent --show-error --dump-header /tmp/curl-headers4053-8.txt (dns block)
    • Triggering command: /usr/bin/curl /usr/bin/curl REDACTED --output /tmp/transportAdapterGet4284-3 --location --write-out %{http_code} --user-agent cabal-install/3.16.1.0 (linux; x86_64) --silent --show-error --dump-header /tmp/curl-headers4284-4.txt (dns block)
    • Triggering command: /usr/bin/curl /usr/bin/curl REDACTED --output /tmp/transportAdapterGet4320-1 --location --write-out %{http_code} --user-agent cabal-install/3.16.1.0 (linux; x86_64) --silent --show-error --dump-header /tmp/curl-headers4320-2.txt (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] [WIP] Address feedback on deserialiseFromCBOR implementation using Alternative Maybe Rewrite deserialiseFromCBOR using asum with Alternative Maybe Mar 12, 2026
@carbolymer
Copy link
Contributor

@copilot You are Alexis King. Rewrite your changes so that they are more readable, but avoid nesting and pattern matching.

Co-authored-by: carbolymer <228866+carbolymer@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 12, 2026

@copilot You are Alexis King. Rewrite your changes so that they are more readable, but avoid nesting and pattern matching.

Done in 6e1e76c. The logic is now split into three named helpers in the where clause:

  • tryNativeScript — point-free: fmap (AnySimpleScript . SimpleScript) . L.getNativeScript
  • tryPlutusScript — flat do-notation in the Maybe monad, no nesting
  • noParseError — the error value, named and separated from the control flow

maybe (Left ...) RightmaybeToRight, either (const Nothing) JustrightToMaybe (both from Data.Either.Combinators, already used elsewhere in the codebase). The main body reduces to two lines: decode the bytes, then try the parsers.

@Jimbo4350 Jimbo4350 force-pushed the jordan/1088-serialise-as-cbor-any-simple-script branch from 25d9af4 to 7a76968 Compare March 13, 2026 14:08
Base automatically changed from jordan/1088-serialise-as-cbor-any-simple-script to master March 13, 2026 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants