Skip to content

Commit

Permalink
Be more explicit about kinds.
Browse files Browse the repository at this point in the history
The aim here is to reduce the likelihood of failures due to kind
mismatch in the future, as well as to help with documentation.
  • Loading branch information
nc6 committed Oct 28, 2020
1 parent 7be688b commit 1b478d6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion shelley-ma/impl/src/Cardano/Ledger/ShelleyMA.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}

Expand All @@ -24,13 +25,14 @@ data MaryOrAllegra = Mary | Allegra
data ShelleyMAEra (ma :: MaryOrAllegra) c

instance
forall c (ma :: MaryOrAllegra).
(Typeable ma, Cardano.Ledger.Crypto.Crypto c) =>
Era (ShelleyMAEra ma c)
where
type Crypto (ShelleyMAEra ma c) = c

type family MAValue (x :: MaryOrAllegra) era :: Type where
MAValue 'Allegra era = Coin
MAValue 'Allegra _ = Coin
MAValue 'Mary era = Value era

type instance Core.Value (ShelleyMAEra m c) = MAValue m (ShelleyMAEra m c)
5 changes: 3 additions & 2 deletions shelley-ma/impl/src/Cardano/Ledger/ShelleyMA/Rules/Utxo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,10 @@ utxoTransition = do
--------------------------------------------------------------------------------

instance
forall c (ma :: MaryOrAllegra).
( CryptoClass.Crypto c,
Typeable ma,
ShelleyBased (ShelleyMAEra (ma :: MaryOrAllegra) c),
ShelleyBased (ShelleyMAEra ma c),
Core.TxBody (ShelleyMAEra ma c) ~ TxBody (ShelleyMAEra ma c)
) =>
STS (UTXO (ShelleyMAEra ma c))
Expand All @@ -277,7 +278,7 @@ instance

instance
(CryptoClass.Crypto c, Typeable ma) =>
Embed (PPUP (ShelleyMAEra ma c)) (UTXO (ShelleyMAEra ma c))
Embed (PPUP (ShelleyMAEra (ma :: MaryOrAllegra) c)) (UTXO (ShelleyMAEra ma c))
where
wrapFailed = UpdateFailure

Expand Down
4 changes: 3 additions & 1 deletion shelley-ma/impl/src/Cardano/Ledger/ShelleyMA/Rules/Utxow.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
Expand All @@ -15,7 +16,7 @@ import qualified Cardano.Ledger.Core as Core
import qualified Cardano.Ledger.Crypto as CryptoClass
import Cardano.Ledger.Mary.Value (PolicyID, Value, policies, policyID)
import Cardano.Ledger.Shelley (ShelleyBased)
import Cardano.Ledger.ShelleyMA (ShelleyMAEra)
import Cardano.Ledger.ShelleyMA (MaryOrAllegra, ShelleyMAEra)
import Cardano.Ledger.ShelleyMA.Rules.Utxo ()
import Cardano.Ledger.ShelleyMA.Scripts ()
import Cardano.Ledger.ShelleyMA.TxBody ()
Expand Down Expand Up @@ -112,6 +113,7 @@ scriptsNeeded u tx =
--------------------------------------------------------------------------------

instance
forall c (ma :: MaryOrAllegra).
( CryptoClass.Crypto c,
Typeable ma,
STS (UTXO (ShelleyMAEra ma c)),
Expand Down

0 comments on commit 1b478d6

Please sign in to comment.