{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} module Byron.Spec.Chain.STS.Rule.Bupi where import Byron.Spec.Ledger.Core (VKey) import Byron.Spec.Ledger.Update (ProtVer, UPIEND, UPIEnv, UPIREG, UPIState, UPIVOTES, UProp, Vote) import Control.State.Transition ( Embed, Environment, PredicateFailure, STS (..), Signal, State, TRC (TRC), TransitionRule, initialRules, judgmentContext, trans, transitionRules, wrapFailed, ) import Data.Data (Data, Typeable) type UpdatePayload = ( Maybe UProp , [Vote] , (ProtVer, VKey) ) data BUPI deriving (Typeable BUPI BUPI -> DataType BUPI -> Constr (forall b. Data b => b -> b) -> BUPI -> BUPI forall a. Typeable a -> (forall (c :: * -> *). (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> a -> c a) -> (forall (c :: * -> *). (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c a) -> (a -> Constr) -> (a -> DataType) -> (forall (t :: * -> *) (c :: * -> *). Typeable t => (forall d. Data d => c (t d)) -> Maybe (c a)) -> (forall (t :: * -> * -> *) (c :: * -> *). Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a)) -> ((forall b. Data b => b -> b) -> a -> a) -> (forall r r'. (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r) -> (forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r) -> (forall u. (forall d. Data d => d -> u) -> a -> [u]) -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u) -> (forall (m :: * -> *). Monad m => (forall d. Data d => d -> m d) -> a -> m a) -> (forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> a -> m a) -> (forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> a -> m a) -> Data a forall u. Int -> (forall d. Data d => d -> u) -> BUPI -> u forall u. (forall d. Data d => d -> u) -> BUPI -> [u] forall r r'. (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BUPI -> r forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BUPI -> r forall (m :: * -> *). Monad m => (forall d. Data d => d -> m d) -> BUPI -> m BUPI forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> BUPI -> m BUPI forall (c :: * -> *). (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c BUPI forall (c :: * -> *). (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> BUPI -> c BUPI forall (t :: * -> *) (c :: * -> *). Typeable t => (forall d. Data d => c (t d)) -> Maybe (c BUPI) forall (t :: * -> * -> *) (c :: * -> *). Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BUPI) gmapMo :: forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> BUPI -> m BUPI $cgmapMo :: forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> BUPI -> m BUPI gmapMp :: forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> BUPI -> m BUPI $cgmapMp :: forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> BUPI -> m BUPI gmapM :: forall (m :: * -> *). Monad m => (forall d. Data d => d -> m d) -> BUPI -> m BUPI $cgmapM :: forall (m :: * -> *). Monad m => (forall d. Data d => d -> m d) -> BUPI -> m BUPI gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BUPI -> u $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BUPI -> u gmapQ :: forall u. (forall d. Data d => d -> u) -> BUPI -> [u] $cgmapQ :: forall u. (forall d. Data d => d -> u) -> BUPI -> [u] gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BUPI -> r $cgmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BUPI -> r gmapQl :: forall r r'. (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BUPI -> r $cgmapQl :: forall r r'. (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BUPI -> r gmapT :: (forall b. Data b => b -> b) -> BUPI -> BUPI $cgmapT :: (forall b. Data b => b -> b) -> BUPI -> BUPI dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *). Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BUPI) $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *). Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BUPI) dataCast1 :: forall (t :: * -> *) (c :: * -> *). Typeable t => (forall d. Data d => c (t d)) -> Maybe (c BUPI) $cdataCast1 :: forall (t :: * -> *) (c :: * -> *). Typeable t => (forall d. Data d => c (t d)) -> Maybe (c BUPI) dataTypeOf :: BUPI -> DataType $cdataTypeOf :: BUPI -> DataType toConstr :: BUPI -> Constr $ctoConstr :: BUPI -> Constr gunfold :: forall (c :: * -> *). (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c BUPI $cgunfold :: forall (c :: * -> *). (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c BUPI gfoldl :: forall (c :: * -> *). (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> BUPI -> c BUPI $cgfoldl :: forall (c :: * -> *). (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> BUPI -> c BUPI Data, Typeable) data BupiPredicateFailure = UPIREGFailure (PredicateFailure UPIREG) | UPIVOTESFailure (PredicateFailure UPIVOTES) | UPIENDFailure (PredicateFailure UPIEND) deriving (BupiPredicateFailure -> BupiPredicateFailure -> Bool forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: BupiPredicateFailure -> BupiPredicateFailure -> Bool $c/= :: BupiPredicateFailure -> BupiPredicateFailure -> Bool == :: BupiPredicateFailure -> BupiPredicateFailure -> Bool $c== :: BupiPredicateFailure -> BupiPredicateFailure -> Bool Eq, Int -> BupiPredicateFailure -> ShowS [BupiPredicateFailure] -> ShowS BupiPredicateFailure -> String forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [BupiPredicateFailure] -> ShowS $cshowList :: [BupiPredicateFailure] -> ShowS show :: BupiPredicateFailure -> String $cshow :: BupiPredicateFailure -> String showsPrec :: Int -> BupiPredicateFailure -> ShowS $cshowsPrec :: Int -> BupiPredicateFailure -> ShowS Show, Typeable BupiPredicateFailure BupiPredicateFailure -> DataType BupiPredicateFailure -> Constr (forall b. Data b => b -> b) -> BupiPredicateFailure -> BupiPredicateFailure forall a. Typeable a -> (forall (c :: * -> *). (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> a -> c a) -> (forall (c :: * -> *). (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c a) -> (a -> Constr) -> (a -> DataType) -> (forall (t :: * -> *) (c :: * -> *). Typeable t => (forall d. Data d => c (t d)) -> Maybe (c a)) -> (forall (t :: * -> * -> *) (c :: * -> *). Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a)) -> ((forall b. Data b => b -> b) -> a -> a) -> (forall r r'. (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r) -> (forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r) -> (forall u. (forall d. Data d => d -> u) -> a -> [u]) -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u) -> (forall (m :: * -> *). Monad m => (forall d. Data d => d -> m d) -> a -> m a) -> (forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> a -> m a) -> (forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> a -> m a) -> Data a forall u. Int -> (forall d. Data d => d -> u) -> BupiPredicateFailure -> u forall u. (forall d. Data d => d -> u) -> BupiPredicateFailure -> [u] forall r r'. (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BupiPredicateFailure -> r forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BupiPredicateFailure -> r forall (m :: * -> *). Monad m => (forall d. Data d => d -> m d) -> BupiPredicateFailure -> m BupiPredicateFailure forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> BupiPredicateFailure -> m BupiPredicateFailure forall (c :: * -> *). (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c BupiPredicateFailure forall (c :: * -> *). (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> BupiPredicateFailure -> c BupiPredicateFailure forall (t :: * -> *) (c :: * -> *). Typeable t => (forall d. Data d => c (t d)) -> Maybe (c BupiPredicateFailure) forall (t :: * -> * -> *) (c :: * -> *). Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BupiPredicateFailure) gmapMo :: forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> BupiPredicateFailure -> m BupiPredicateFailure $cgmapMo :: forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> BupiPredicateFailure -> m BupiPredicateFailure gmapMp :: forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> BupiPredicateFailure -> m BupiPredicateFailure $cgmapMp :: forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> BupiPredicateFailure -> m BupiPredicateFailure gmapM :: forall (m :: * -> *). Monad m => (forall d. Data d => d -> m d) -> BupiPredicateFailure -> m BupiPredicateFailure $cgmapM :: forall (m :: * -> *). Monad m => (forall d. Data d => d -> m d) -> BupiPredicateFailure -> m BupiPredicateFailure gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BupiPredicateFailure -> u $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BupiPredicateFailure -> u gmapQ :: forall u. (forall d. Data d => d -> u) -> BupiPredicateFailure -> [u] $cgmapQ :: forall u. (forall d. Data d => d -> u) -> BupiPredicateFailure -> [u] gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BupiPredicateFailure -> r $cgmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BupiPredicateFailure -> r gmapQl :: forall r r'. (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BupiPredicateFailure -> r $cgmapQl :: forall r r'. (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BupiPredicateFailure -> r gmapT :: (forall b. Data b => b -> b) -> BupiPredicateFailure -> BupiPredicateFailure $cgmapT :: (forall b. Data b => b -> b) -> BupiPredicateFailure -> BupiPredicateFailure dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *). Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BupiPredicateFailure) $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *). Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BupiPredicateFailure) dataCast1 :: forall (t :: * -> *) (c :: * -> *). Typeable t => (forall d. Data d => c (t d)) -> Maybe (c BupiPredicateFailure) $cdataCast1 :: forall (t :: * -> *) (c :: * -> *). Typeable t => (forall d. Data d => c (t d)) -> Maybe (c BupiPredicateFailure) dataTypeOf :: BupiPredicateFailure -> DataType $cdataTypeOf :: BupiPredicateFailure -> DataType toConstr :: BupiPredicateFailure -> Constr $ctoConstr :: BupiPredicateFailure -> Constr gunfold :: forall (c :: * -> *). (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c BupiPredicateFailure $cgunfold :: forall (c :: * -> *). (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c BupiPredicateFailure gfoldl :: forall (c :: * -> *). (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> BupiPredicateFailure -> c BupiPredicateFailure $cgfoldl :: forall (c :: * -> *). (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> BupiPredicateFailure -> c BupiPredicateFailure Data, Typeable) instance STS BUPI where type Environment BUPI = UPIEnv type State BUPI = UPIState type Signal BUPI = UpdatePayload type PredicateFailure BUPI = BupiPredicateFailure initialRules :: [InitialRule BUPI] initialRules = [] transitionRules :: [TransitionRule BUPI] transitionRules = [ do TRC (Environment BUPI _, State BUPI _, (Maybe UProp mProp, [Vote] _, (ProtVer, VKey) _)) <- forall sts (rtype :: RuleType). Rule sts rtype (RuleContext rtype sts) judgmentContext case Maybe UProp mProp of Just UProp prop -> UProp -> TransitionRule BUPI hasProposalRule UProp prop Maybe UProp Nothing -> TransitionRule BUPI noProposalRule ] where hasProposalRule :: UProp -> TransitionRule BUPI hasProposalRule :: UProp -> TransitionRule BUPI hasProposalRule UProp prop = do TRC (Environment BUPI env, State BUPI us, (Maybe UProp _, [Vote] votes, (ProtVer, VKey) end)) <- forall sts (rtype :: RuleType). Rule sts rtype (RuleContext rtype sts) judgmentContext UPIState us' <- forall sub super (rtype :: RuleType). Embed sub super => RuleContext rtype sub -> Rule super rtype (State sub) trans @UPIREG forall a b. (a -> b) -> a -> b $ forall sts. (Environment sts, State sts, Signal sts) -> TRC sts TRC (Environment BUPI env, State BUPI us, UProp prop) UPIState us'' <- forall sub super (rtype :: RuleType). Embed sub super => RuleContext rtype sub -> Rule super rtype (State sub) trans @UPIVOTES forall a b. (a -> b) -> a -> b $ forall sts. (Environment sts, State sts, Signal sts) -> TRC sts TRC (Environment BUPI env, UPIState us', [Vote] votes) UPIState us''' <- forall sub super (rtype :: RuleType). Embed sub super => RuleContext rtype sub -> Rule super rtype (State sub) trans @UPIEND forall a b. (a -> b) -> a -> b $ forall sts. (Environment sts, State sts, Signal sts) -> TRC sts TRC (Environment BUPI env, UPIState us'', (ProtVer, VKey) end) forall (m :: * -> *) a. Monad m => a -> m a return forall a b. (a -> b) -> a -> b $! UPIState us''' noProposalRule :: TransitionRule BUPI noProposalRule :: TransitionRule BUPI noProposalRule = do TRC (Environment BUPI env, State BUPI us, (Maybe UProp _, [Vote] votes, (ProtVer, VKey) end)) <- forall sts (rtype :: RuleType). Rule sts rtype (RuleContext rtype sts) judgmentContext UPIState us' <- forall sub super (rtype :: RuleType). Embed sub super => RuleContext rtype sub -> Rule super rtype (State sub) trans @UPIVOTES forall a b. (a -> b) -> a -> b $ forall sts. (Environment sts, State sts, Signal sts) -> TRC sts TRC (Environment BUPI env, State BUPI us, [Vote] votes) UPIState us'' <- forall sub super (rtype :: RuleType). Embed sub super => RuleContext rtype sub -> Rule super rtype (State sub) trans @UPIEND forall a b. (a -> b) -> a -> b $ forall sts. (Environment sts, State sts, Signal sts) -> TRC sts TRC (Environment BUPI env, UPIState us', (ProtVer, VKey) end) forall (m :: * -> *) a. Monad m => a -> m a return forall a b. (a -> b) -> a -> b $! UPIState us'' instance Embed UPIREG BUPI where wrapFailed :: PredicateFailure UPIREG -> PredicateFailure BUPI wrapFailed = PredicateFailure UPIREG -> BupiPredicateFailure UPIREGFailure instance Embed UPIVOTES BUPI where wrapFailed :: PredicateFailure UPIVOTES -> PredicateFailure BUPI wrapFailed = PredicateFailure UPIVOTES -> BupiPredicateFailure UPIVOTESFailure instance Embed UPIEND BUPI where wrapFailed :: PredicateFailure UPIEND -> PredicateFailure BUPI wrapFailed = PredicateFailure UPIEND -> BupiPredicateFailure UPIENDFailure