Hello Community! I’d like to return the result when both arguments are present and evaluate to ‘True’: (1) fixedRate
and otherValueA
, (2) floatingRate
and otherValueB
or (3) error
.
How should this function be represented?:
setInterestRate : CalculationPeriod -> ([Text], CalculationPeriod)
setInterestRate cp
| Some fixedRate <- irp.rateSpecification.fixedRate =
([], cp { fixedRate = Some fixedRate.initialValue })
| Some otherValue <- irp.rateSpecification.otherValue =
([], cp { otherValueA = Some otherValueA.initialValue })
| Some floatingRate <- irp.rateSpecification.floatingRate =
let frDef = get "floatingRateDefinition" cp.floatingRateDefinition
frdNew = FR.calcFloatingRate existingResets floatingRate frDef
in (fst frdNew, cp { floatingRateDefinition = Some (snd frdNew) })
| Some otherValueB <- irp.rateSpecification.otherValueB =
([], cp { otherValueB = Some otherValueB.initialValue })
| otherwise = error "expecting exactly two 'rateSpecification'"