How to interpret this function:
friendlyValidityRange
:: CardanoEra era
-> (TxValidityLowerBound era, TxValidityUpperBound era)
-> Aeson.Value
friendlyValidityRange era = \case
ShelleyTtl ttl -> object ["time to live" .= ttl]
(lowerBound, upperBound)
| isLowerBoundSupported || isUpperBoundSupported ->
object
[ ...
]
| otherwise -> Null
where
isLowerBoundSupported = isJust $ validityLowerBoundSupportedInEra era
isUpperBoundSupported = isJust $ validityUpperBoundSupportedInEra era
I thought the friendlyValidityRange
function utilize the partial function concept, but still failed to understand it.
How can friendlyValidityRange
's era
and (lowerBound, upperBound)
parameters be passed in such separated way?
I try to mimic it use follow demo, still unable to finished it.
module Main where
data Age = Child | Adult
-- Function that accept two agrs: Age, (weightMin, weightMax) , and return health description string
weightAnalyse :: Age -> (Int, Int) -> String
weightAnalyse age = \case
Child -> ? -- how to comsume the (min, max) tuple
Adult -> ?
main :: IO ()
main = do
weightAnalyse Child (30, 60)
weightAnalyse Adult (60, 130)