Skip to content

Commit a21bd66

Browse files
Merge pull request #2495 from typhonshambo/develop
docs: Update AssumeReflect.md
2 parents 1d133ad + 941a235 commit a21bd66

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

docs/mkDocs/docs/specifications.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,3 +1026,22 @@ Or in a Haskell source file:
10261026
- No support for abstract refinements. All abstract refinements are erased before relational typechecking. Notably, this happens for the standard list `[a]` and tuple `(a, b)` types!
10271027

10281028
- Limited support for higher-order relational signatures. Use `!=>` instead of `:=>` after the function arguments to enable higher-order checking.
1029+
1030+
## Lazy Variables
1031+
1032+
A variable can be specified as `lazyvar` to defer its checking until it is used. This is useful in cases where a variable is defined in a `where` clause and should only be checked in the context where it is used.
1033+
1034+
For example, consider the following code:
1035+
1036+
```haskell
1037+
{-@ safeDiv :: Int -> {v:Int | v /= 0} -> Int @-}
1038+
safeDiv :: Int -> Int -> Int
1039+
safeDiv x y
1040+
| y == 0 = help
1041+
| otherwise = x `div` y
1042+
where
1043+
{-@ lazyvar help @-}
1044+
help = error "lol"
1045+
```
1046+
1047+
In this example, the `lazyvar` annotation on `help` ensures that the check for `help` is deferred until it is used. Without this annotation, LiquidHaskell would incorrectly report an error like `Error: Liquid Type Mismatch`.

0 commit comments

Comments
 (0)