Questions: Liquid Types

4 questions to test your understanding

Score: 0 / 4
Question 1 Short Answer

A function is declared with liquid type `incr :: x:{Int | x >= 0} -> {y:Int | y > x}`. What does the type checker verify when this function is called with argument 5?

Think about your answer, then reveal below.
Question 2 Short Answer

Liquid types restrict refinement predicates to a decidable fragment (typically quantifier-free linear arithmetic). Why not allow arbitrary logic like full first-order logic?

Think about your answer, then reveal below.
Question 3 Multiple Choice

Liquid Haskell verifies a function `divide :: x:Nat -> y:{Nat | y != 0} -> Nat`. When type-checking a call `divide(10, 0)`, what happens?

AThe function executes and raises a runtime error
BThe type checker rejects the program at compile time because the argument 0 does not satisfy the liquid type {y:Nat | y != 0}
CThe type checker warns but allows the code to compile
DThe type checker asks the user to provide a proof that 0 != 0
Question 4 Short Answer

Consider a function `sum :: xs:[Int]<{v:Int | v > 0}> -> {n:Int | n > 0}` that sums a non-empty list of positive integers. How would a liquid type checker verify this?

Think about your answer, then reveal below.