Skip to content

Commit

Permalink
WIP NoThunks Pulser
Browse files Browse the repository at this point in the history
  • Loading branch information
nfrisby committed Apr 17, 2021
1 parent 5d99102 commit fdbc241
Showing 1 changed file with 12 additions and 5 deletions.
Expand Up @@ -54,7 +54,7 @@ import Data.Set (Set)
import qualified Data.Set as Set
import GHC.Generics (Generic)
import GHC.Records (HasField (..))
import NoThunks.Class (InspectHeapNamed (..), NoThunks (..))
import NoThunks.Class (NoThunks (..), allNoThunks)
import Numeric.Natural (Natural)
import Shelley.Spec.Ledger.BaseTypes
( ActiveSlotCoeff,
Expand Down Expand Up @@ -91,8 +91,9 @@ data RewardAns c
!(Map (Credential 'Staking c) (Set (Reward c)))
!(Map (KeyHash 'StakePool c) Likelihood)
deriving (Show, Eq, Generic)
deriving (NFData)

instance NFData (RewardAns crypto)
instance NoThunks (RewardAns crypto)

instance CC.Crypto c => ToCBOR (RewardAns c) where
toCBOR (RewardAns x y) = toCBOR (x, y)
Expand Down Expand Up @@ -226,8 +227,7 @@ data FreeVars crypto = FreeVars
pp_nOpt :: Natural
}
deriving (Eq, Show, Generic)

deriving via InspectHeapNamed "FreeVars" (FreeVars crypto) instance NoThunks (FreeVars crypto)
deriving (NoThunks)

instance NFData (FreeVars crypto)

Expand Down Expand Up @@ -358,7 +358,14 @@ deriving instance Eq ans => Eq (RewardPulser c m ans)

deriving instance Show ans => Show (RewardPulser c m ans)

deriving via InspectHeapNamed "RewardPulser" (Pulser c) instance NoThunks (Pulser c)
instance NoThunks (Pulser c) where
showTypeOf _ = "RewardPulser"
wNoThunks ctxt (RSLP n free balance ans) = allNoThunks [
noThunks ctxt n
, noThunks ctxt free
, noThunks ctxt balance
, noThunks ctxt ans
]

instance NFData (Pulser c) where
rnf (RSLP n1 c1 b1 a1) = seq (rnf n1) (seq (rnf c1) (seq (rnf b1) (rnf a1)))
Expand Down

0 comments on commit fdbc241

Please sign in to comment.