--
You received this message because you are subscribed to the Google Groups "liquidhaskell" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liquidhaskell+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Ranjit,
Thanks a lot for your detailed explanation. Thus I have a few more follow-up questions and observations.
1. When I define `VecN t N`, the value parameter has to come
after the type parameter (otherwise I get some seemingly
meaningless errors). Is that right?
2. For a same measure, I found 3 different styles of definitions are commonly mentioned.
```
-- (1)
{-@ measure vlen :: Vec t -> Int
vlen Nil = 0
vlen (Cons _ as) = vlen as + 1
@-}
-- (2)
{-@ measure vlen @-}
vlen :: Vec t -> Int
vlen Nil = 0
vlen (Cons _ as) = vlen as + 1
-- (3)
{-@ measure vlen :: v:Vec t -> {a:Int | vlen v = a} @-}
vlen :: Vec t -> Int
vlen Nil = 0
vlen (Cons _ as) = vlen as + 1
```
How do you compare them and what are the use cases for each?
From what I can tell, (1) doesn't require termination proof, but
the definition of out of Haskell's scope as (2) and (3).
In particular, I was wondering what the self-referential (3)
style is for. Also why can't I write {-@ measure
vlen :: v:Vec t -> {a:Nat | vlen v = a} @-} instead in (3)?
It says "Refinement
Type Alias cannot be used in this context".
3. When using default measure `data Vec [vlen] t = ...`, I
have to use record syntax for data constructors, otherwise it
gives an incomprehensible error. Is it just
an implementation limitation?
4. I did a bit more experiments and found that the cause of
my `splitAt` failure was due to "--higherorder". I didn't know
that this flag has some side effects. Is it a bug/feature?
Code is here:
http://goto.ucsd.edu:8090/index.html#?demo=permalink%2F1479272608_18192.hs
Thanks again,
Zilin
1. When I define `VecN t N`, the value parameter has to come after the type parameter (otherwise I get some seemingly meaningless errors). Is that right?
2. For a same measure, I found 3 different styles of definitions are commonly mentioned.
```
-- (1)
{-@ measure vlen :: Vec t -> Int
vlen Nil = 0
vlen (Cons _ as) = vlen as + 1
@-}
-- (2)
{-@ measure vlen @-}
vlen :: Vec t -> Int
vlen Nil = 0
vlen (Cons _ as) = vlen as + 1
-- (3)
{-@ measure vlen :: v:Vec t -> {a:Int | vlen v = a} @-}
vlen :: Vec t -> Int
vlen Nil = 0
vlen (Cons _ as) = vlen as + 1
```
3. When using default measure `data Vec [vlen] t = ...`, I have to use record syntax for data constructors, otherwise it gives an incomprehensible error. Is it just
an implementation limitation?
4. I did a bit more experiments and found that the cause of my `splitAt` failure was due to "--higherorder". I didn't know that this flag has some side effects. Is it a bug/feature?
Code is here: http://goto.ucsd.edu:8090/index.html#?demo=permalink%2F1479272608_18192.hs