cardano-ledger icon indicating copy to clipboard operation
cardano-ledger copied to clipboard

Fix `COMPLETE` for all type class based pattern synonyms

Open lehins opened this issue 1 year ago • 1 comments

We have a few type class based pattern synonyms:

  • [ ] - TxCerts
  • [ ] - NativeScripts

All of these cannot have a COMPLETE pragma implemented for them, since ghc-8.10 does not support new syntax with the type. For example that is why we had to reject this RP: https://github.com/IntersectMBO/cardano-ledger/pull/4481/files

Which tried to add an incorrect pattern:

{-# COMPLETE
  RequireSignature
  , RequireAllOf
  , RequireAnyOf
  , RequireMOf
  #-}

since it would disregard timelock's RequireTimeStart and RequireTimeExpire.

Therefore, the correct way to solve this is to specify COMPELTE pragma for each era:

{-# COMPLETE
  RequireSignature
  , RequireAllOf
  , RequireAnyOf
  , RequireMOf :: Shelley
  #-}
{-# COMPLETE
  RequireSignature
  , RequireAllOf
  , RequireAnyOf
  , RequireMOf
  , RequireTimeStart
  , RequireTimeExpire :: Allegra
  #-}

etc.

lehins avatar Sep 09 '24 20:09 lehins

This could be done before we deprecate usage of GHC-8.10 with some CPP

lehins avatar Sep 09 '24 20:09 lehins

Relevant clarification about the currently possible solution: https://github.com/IntersectMBO/cardano-ledger/pull/5053

aniketd avatar May 19 '25 16:05 aniketd

Looks like the only way to solve this ticket is by moving all definitions of era types into separate internal sublibrary in cardano-ledger-core. Here is a task that will unblock this issue when resolved: #5069

lehins avatar May 21 '25 17:05 lehins