Questions tagged [liquid-haskell]

For questions pertaining to the LiquidHaskell static verifier.

LiquidHaskell is a static verifier which works with the Haskell language.

LiquidHaskell itself is based upon Liquid Types, and aims to help write memory-safe, but also provably correct programs by allowing users to annotate types with logical constraints which can later be solved using SMT solvers.

37 questions
3
votes
1 answer

Simple liquidhaskell example fails expected behavior

I have recently started playing around with liquid haskell, and from all of the tutorials I could find, I could not find any examples like the following. data MaybePerson = MaybePerson { …
Nathan BeDell
  • 2,263
  • 1
  • 14
  • 25
3
votes
1 answer

Why is Nat type equal to Int in Liquid Haskell?

Why does this pass Liquid Haskell verification? {-@ sub :: Nat -> Nat -> Int @-} sub :: Int -> Int -> Int sub i j = i - j Does it mean that…
RandomB
  • 3,367
  • 19
  • 30
3
votes
2 answers

Is it possible to use one line contracts in Liquid Haskell?

Liquid Haskell uses comments like {-@ ... @-} for contracts block. Is it possible (with command line option, config file) to specify to use one line comments style like -- ... for contracts ?
RandomB
  • 3,367
  • 19
  • 30
3
votes
1 answer

Liquid Haskell: Error with Proof Combinators and Types Refined by Predicates

As a minimal example of the problem I'm having, here's a definition of natural numbers, a doubling function, and a type refined by an even-ness predicate: data Nat' = Z | S Nat' deriving Show {-@ reflect double' @-} double' :: Nat' -> Nat' double'…
Alex Varga
  • 1,752
  • 2
  • 14
  • 17
3
votes
1 answer

Using Liquid Haskell to Check for Valid Tokens

I am doing some experimentation using liquid-haskell to see what kinds of neat things I can do with it and I have hit a bit of a wall. The basic idea is that I have some functions that require an access token that expires after a certain amount of…
ulbrec
  • 65
  • 4
3
votes
1 answer

How to specify a function operating on non-empty data structure with LiquidHaskell?

I am trying to do the first exercise in the LiquidHaskell case study on Lazy Queues module Main where main :: IO () main = putStrLn "hello" {-@ type Nat = {v:Int | 0 <= v} @-} {-@ die :: {v:String | false} -> a @-} die x = error x {-@…
Xavier Shay
  • 4,067
  • 1
  • 30
  • 54
2
votes
0 answers

How to eta-convert tuple of refinement-typed coordinates?

In the following Liquid Haskell program, the definition of c' and z' are separate. This program is accepted by the LH typechecker. {-@ type Digit = { v : _ | 0 <= v && v <= 9 } @-} type Digit = Int {-@ addDigit :: c : Bool -> x : Digit -> y :…
Cactus
  • 27,075
  • 9
  • 69
  • 149
2
votes
0 answers

What language has equational rewrite?

A classic case of inefficiency in functional program is things like the reverse function written from specification import Prelude() [] ++ ys = ys (x:xs) ++ ys = x:(xs ++ ys) reverse [] = [] reverse (x:xs) = (reverse xs) ++ [x] Using…
nicolas
  • 9,549
  • 3
  • 39
  • 83
2
votes
1 answer

How to write a log2 function in Liquid Haskell

I am trying to learn Liquid Haskell from the book. To test my understanding, I wanted to write a function log2 which takes an input of the form 2^n and outputs n. I have the following code: powers :: [Int] powers = map (2^) [0..] {-@ type Powers =…
kishlaya
  • 453
  • 2
  • 14
2
votes
1 answer

Can I define parametric data type where parameters are not equals between in Haskell?

Problem: Let's imagine we have a Passenger with start and end points represented by: data Passenger a = Passenger { start :: a , end :: a } Question: How can I apply a class constraints…
mkUltra
  • 2,828
  • 1
  • 22
  • 47
2
votes
1 answer

Liquid haskell creating a new bytestring with PS

I'm making some bindings to C from Haskell, and trying to make it safer with LiquidHaskell. I'm having some trouble with specifying the length of a bytestring in the LH type annotation. I have an enhanced ByteString type in LiquidHaskell that…
8n8
  • 1,233
  • 1
  • 8
  • 21
2
votes
1 answer

Can I use Liquid Haskell on code that requires GHC 8?

I have a project that is build with stack and requires GHC 8. Is it possible to use Liquid Haskell with my project, given that it requires GHC 8? If so, how should I go about installing and executing Liquid Haskell? Thanks!
the-konapie
  • 601
  • 3
  • 10
1
vote
0 answers

`let` inside a refinement type

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 +…
Cactus
  • 27,075
  • 9
  • 69
  • 149
1
vote
0 answers

Expanding recursive case of function in equational reasoning

Context: I am proving some properties about a Haskell quicksort implementation. The following code is all that is required to define a nondeterministic permute function. Note that I am using LList rather than Haskell's base [] type. The problem area…
1
vote
0 answers

Problem with naming record fields for List data type

For the sake of demonstration, I have two nearly-identical files: ListSuccess.hs and ListFailure.hs: -- File: ListSuccess.hs module ListSuccess where import Prelude hiding ( head …