mlabs-haskell / mlabs-haskell/lambda-buffers

PlutusData typeclass implementation should be unconditionally printed during TyDef

Open
#148 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug codegen plutarch
Dominant language
Haskell
Stars
32
Forks
1
PR merge metrics
No merged PRs in 30d

Description

@t4ccer
Alright, I have first maybe bug. If I have

sum NftMarketplaceRedeemer = Buy | Cancel

and run it through lbf-plutus-to-plutarch and try to compile, I'll get a GHC error saying

    • No instance for (Plutarch.Prelude.PlutusType
                         NftMarketplaceRedeemer)
        arising from the 'deriving' clause of a data type declaration
      Possible fix:
        use a standalone 'deriving instance' declaration,
          so you can specify the instance context yourself
    • When deriving the instance for (Plutarch.Show.PShow
                                        NftMarketplaceRedeemer)
   |
40 |   deriving anyclass Plutarch.Show.PShow
   |                     ^^^^^^^^^^^^^^^^^^

Of course adding derive PlutusData NftMarketplaceRedeemer fixes the issue, but I have a feeling that it should be caught before going to ghc

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the lbf-plutus-to-plutarch path that handles TyDef and inspect how the example sum type is rendered. Compare its generated declarations with the manual derive PlutusData NftMarketplaceRedeemer workaround, then compile the generated output. Done means the needed PlutusData-related declaration is emitted before GHC reports the missing PlutusType instance.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.