-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Factor out class ShelleyBasedBlock
and type family ShelleyBlockLedgerEra
#1073
Conversation
class | ||
( ShelleyBasedEra (ShelleyBlockLedgerEra blk) | ||
, blk ~ ShelleyBlock (BlockProtocol blk) (ShelleyBlockLedgerEra blk) | ||
) => ShelleyBasedBlock blk | ||
|
||
instance ( proto ~ BlockProtocol (ShelleyBlock proto era) | ||
, ShelleyBasedEra era | ||
) => ShelleyBasedBlock (ShelleyBlock proto era) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could give this class "more power", ie make its superclass constraints stronger, eg use ShelleyCompatible
instead of just ShelleyBasedEra
:
class | |
( ShelleyBasedEra (ShelleyBlockLedgerEra blk) | |
, blk ~ ShelleyBlock (BlockProtocol blk) (ShelleyBlockLedgerEra blk) | |
) => ShelleyBasedBlock blk | |
instance ( proto ~ BlockProtocol (ShelleyBlock proto era) | |
, ShelleyBasedEra era | |
) => ShelleyBasedBlock (ShelleyBlock proto era) | |
class | |
( ShelleyCompatible (BlockProtocol blk) (ShelleyBlockLedgerEra blk) | |
, blk ~ ShelleyBlock (BlockProtocol blk) (ShelleyBlockLedgerEra blk) | |
) => ShelleyBasedBlock blk | |
instance ( proto ~ BlockProtocol (ShelleyBlock proto era) | |
, ShelleyCompatible proto era | |
) => ShelleyBasedBlock (ShelleyBlock proto era) |
This might come in handy in a future use case where we want to call a function that requires ShelleyCompatible
and not just ShelleyBasedEra
in an SOP combinator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also proposed the same. I do wonder if this is not equivalent to requiring it in the constructors? as in:
data ShelleyBlock proto era where
ShelleyBlock :: ShelleyCompatible proto era =>
{ ... } -> ShelleyBlock proto era
leaving that aside, it might be intereseting to provide instances for Header (ShelleyBlock ...)
and LedgerState (ShelleyBlock ...)
? I feel like this might simplify some aux classes we might have around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think one should prefer function constraints, not constraints on constructors. They are not entirely equivalent
Most of the places where I use constraints inside constructors is when dealing with existentials or Dict
s
Pending change from #934 (comment)