You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Similarly to [Era]Imp type classes we need to create a type class for each era in the testlibs that will be used throughout all of our tests.
In cardano-ledegr-core:testlib we need a new module Test.Cardano.Ledger.Era that will have a single
type class with no methods, but a ton of superclasses for all of the core type families:
Plus whatever other constraints that are common between all eras
It also needs to import any instances that are available for type classes that are listed as superclasses. Specifically Arbitrary and ToExpr
In cardano-ledger-[era]:testlib new module Test.Cardano.Ledger.Shelley.Era that will have a single type class with no methods (for now), but a ton of superclasses for all of era specific type families. Note that superclass constraints for concrete types should usually not be necessary, since such instances are usually defined for all eras anyways (eg. Arbitrary . Very important point here is that we should only include constraints that are tru for current and all subsequent eras. In other words avoid adding any supclass constraints for anything that was or will be deprecated in any of the subsequent eras. Good example is a ShelleyTxCert constraint, which Dijkstra era will not have an instance of. So, it should look something like that:
If you are unsure whether a constraint should be there or not, just avoid adding it, because we can always add the missing ones later whenever we run into them
Uses cases for these type classes are:
they can be used as super class constraints for [Era]EraImp type classes
they can be used to avoid long type signatures like that
They are easier to use at call sites that depend on a lot of nested Arbitrary or ToExpr instances for type families (like the use case above), which means it will be very useful for work in Remove Pretty from cardano-ledger-test #4966
The text was updated successfully, but these errors were encountered:
Similarly to
[Era]Imp
type classes we need to create a type class for each era in thetestlib
s that will be used throughout all of our tests.In
cardano-ledegr-core:testlib
we need a new moduleTest.Cardano.Ledger.Era
that will have a singletype class with no methods, but a ton of superclasses for all of the core type families:
Plus whatever other constraints that are common between all eras
It also needs to import any instances that are available for type classes that are listed as superclasses. Specifically
Arbitrary
andToExpr
In
cardano-ledger-[era]:testlib
new moduleTest.Cardano.Ledger.Shelley.Era
that will have a single type class with no methods (for now), but a ton of superclasses for all of era specific type families. Note that superclass constraints for concrete types should usually not be necessary, since such instances are usually defined for all eras anyways (eg. Arbitrary . Very important point here is that we should only include constraints that are tru for current and all subsequent eras. In other words avoid adding any supclass constraints for anything that was or will be deprecated in any of the subsequent eras. Good example is aShelleyTxCert
constraint, whichDijkstra
era will not have an instance of. So, it should look something like that:If you are unsure whether a constraint should be there or not, just avoid adding it, because we can always add the missing ones later whenever we run into them
Uses cases for these type classes are:
[Era]EraImp
type classesArbitrary
orToExpr
instances for type families (like the use case above), which means it will be very useful for work in RemovePretty
fromcardano-ledger-test
#4966The text was updated successfully, but these errors were encountered: