A predicate is a type that describes a property of data. Constructing a value of that type provides a proof that the property holds. section 9.0 section 9.3
Predicates make assumptions explicit in function types. A function can require a proof about its inputs, or return a value paired with a proof about that value, so the type checker checks the contract at the call site. section 9.0 section 9.3
readGuess : IO (x ** ValidInput x) readGuess = do putStr "Guess:" x <- getLine #1 case isValidString (toUpper x) of #2 Yes prf => pure (_ ** prf) #3 No contra => do putStrLn "Invalid guess" readGuess #4
The input reader checks a guess and returns it with a proof that it contains exactly one character; invalid guesses trigger another attempt. section 9.2.3
Predicates can also describe vector membership, whether a property is decidable, and rules about system state. Decidable validation can distinguish a proof of validity from evidence that a value cannot be valid. section 9.0 section 9.3
