I have a Liquid Haskell refinement type that looks like this:
{-@
addDigit ::
c : Bool -> x : Digit -> y : Digit ->
{ v : (Bool, Digit)
| fst v = ((x + y + if c then 1 else 0) > 9)
&& (snd v + (if (fst v) then 10 else 0)) == (x + y + if c then 1 else 0)
}
@-}
Is there a way morally equivalent to let
-bind a name inside the refinement type, so that I can avoid writing x + y + if c then 1 else 0
twice? I.e. something like the following made-up syntax:
{-@
addDigit ::
c : Bool -> x : Digit -> y : Digit ->
{ v : (Bool, Digit)
| let z = x + y + if c then 1 else 0
in fst v = (z > 9)
&& (snd v + (if (fst v) then 10 else 0)) == z
}
@-}