Investigate if lambdas not annotated with types fail to compile in Plutus Tx
#6085 aperta il 22 mag 2024
Metriche repository
- Star
- (1637 star)
- Metriche merge PR
- (Merge medio 15g 11h) (13 PR mergiate in 30 g)
Descrizione
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.