IntersectMBO/plutus

Investigate if lambdas not annotated with types fail to compile in Plutus Tx

Open

#6,085 opened on May 22, 2024

View on GitHub
 (2 comments) (0 reactions) (0 assignees)Haskell (1,637 stars) (511 forks)batch import
Good first issueInternalPlinthUser experiencestatus: triaged

Description

James Browning reported this issue.

In an earlier plutus version I was able to compile (\_ _ -> ()) or (\_ _ _ -> ()) but this now produces an error

GHC Core to PLC plugin: Error: Unsupported feature: Kind: forall k. k
Context: Compiling kind: forall k. k
Context: Compiling type: GHC.Types.Any
Context: Compiling expr: \ _ [Occ=Dead] _ [Occ=Dead] -> GHC.Tuple.()

Using a BuiltinData -> BuiltinData -> () function still works. Just wondered why this might be and if we care enough

For example, I used to use

alwaysSucceedPolicy :: MintingPolicy
alwaysSucceedPolicy = mkMintingPolicyScript $$(PlutusTx.compile [|| (\_ _ -> ()) ||])

but now I must do like

mkAlwaysSucceedPolicy :: BuiltinData -> BuiltinData -> ()
mkAlwaysSucceedPolicy _datum _sc = ()
alwaysSucceedPolicy :: SerialisedScript
alwaysSucceedPolicy = serialiseCompiledCode $$(PlutusTx.compile [|| mkAlwaysSucceedPolicy ||])

I think it wouldn’t be surprising if we couldn’t compile a naked \_ _ -> () however mkMintingPolicyScript does constrain the type of each argument bound by a lambda to BuiltinData, so in theory all types are there and GHC should be able to see them. In practice it may of course all be much more complicated than that.

Would be great to make it work, but perhaps not a huge deal if we can’t.

Contributor guide