# Combining guards and Boolean "and" with two arguments of tuple type

**URL:** <https://forum.canton.network/t/combining-guards-and-boolean-and-with-two-arguments-of-tuple-type/803>\
**Category:** App Development\
**Created:** [July 7, 2020, 8:46pm UTC](https://forum.canton.network/t/combining-guards-and-boolean-and-with-two-arguments-of-tuple-type/803 "2020-07-07T20:46:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_Rivers](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/chris_rivers/32/420_2.png) [@Chris\_Rivers](https://forum.canton.network/u/Chris_Rivers)\
**Post date:** [July 7, 2020, 8:46pm UTC](https://forum.canton.network/t/combining-guards-and-boolean-and-with-two-arguments-of-tuple-type/803/1 "2020-07-07T20:46:28Z")

</div>

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'"
```

---

<div class="post-metadata">

**Author:** ![bernhard](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/bernhard/32/356_2.png) [@bernhard](https://forum.canton.network/u/bernhard)\
**Post date:** [July 8, 2020, 8:12am UTC](https://forum.canton.network/t/combining-guards-and-boolean-and-with-two-arguments-of-tuple-type/803/2 "2020-07-08T08:12:02Z")

</div>

If you want to stick with guards, you can use just combine them:

```haskell
setInterestRate : CalculationPeriod -> ([Text], CalculationPeriod)
setInterestRate cp
  | Some fixedRate <- irp.rateSpecification.fixedRate
  , Some otherValue <- irp.rateSpecification.otherValue 
  = ([], cp { otherValueA = Some otherValueA.initialValue 
            ; fixedRate = Some fixedRate.initialValue })
  
  | Some floatingRate <- irp.rateSpecification.floatingRate
  , Some otherValueB <- irp.rateSpecification.otherValueB
  = let frDef = get "floatingRateDefinition" cp.floatingRateDefinition
        frdNew = FR.calcFloatingRate existingResets floatingRate frDef
     in (fst frdNew, cp { floatingRateDefinition = Some (snd frdNew) 
                        ; otherValueB = Some otherValueB.initialValue })
  
  | otherwise = error "expecting exactly two 'rateSpecification'"

```
