0

I have code:

myfun c t = if c == '/' && T.length t > 0 && '/' == T.head t then t else T.singleton c <> t

When I run LH on it (stack exec liquid -- MyFile.hs) I get error:

Error: Liquid Type Mismatch

35 |           rmSlash c t = if c == '/' && T.length t >= 1 && '/' == T.head t then t else T.singleton c <> t
                                                                            ^

Inferred type
    VV : {v : Data.Text.Internal.Text | 0 <= tlen v
                                        && tlen v == stringlen v
                                        && v == t}

not a subtype of Required type
    VV : {VV : Data.Text.Internal.Text | 1 <= tlen VV}

In Context
    t : {t : Data.Text.Internal.Text | 0 <= tlen t
                                        && tlen t == stringlen t}

I am not sure what does it mean, seems that LH thinks the call of T.head is unsafe. But I have a check of the length with T.length t > 0! What is the canonical way to fix this problem, so LH could pass the verification? More interesting is without rewriting of the code, with LH only.

RandomB
  • 3,367
  • 19
  • 30
  • I can't reproduce. With `LiquidHaskell Version 0.8.6.0` it compiles here. – chi Jun 03 '19 at 10:29
  • hm, my installation is too `LiquidHaskell Version 0.8.6.0, Git revision fd35e1c17500ebe706d99260921a8e833561cdde` – RandomB Jun 03 '19 at 10:31
  • Mine prints `no git information`. A cabal file I recently installed asks for commit `574d17ba012dffcff5a736e15cd0a603bf0f558d`. I'm not completely certain, though (why the installed version shows no git info?). – chi Jun 03 '19 at 10:42
  • I am newer even... Very strange – RandomB Jun 03 '19 at 10:48
  • 1
    I don't know what to suggest. Maybe ensure you have a recent Z3 solver, which is exploited by LH. – chi Jun 03 '19 at 11:17
  • Hm, LH does not work with last Z3: `:1:1-1:1: Error crash: SMTLIB2 respSat = Error "line 13 column 13: invalid sort definition, sort already declared/defined"`. Also it does not work with 1st and last CVC4 (broken pipe) and with last MathSat. – RandomB Jun 03 '19 at 12:33
  • 1
    It does appear to be a tooling problem. LH does not work with the latest GHC, preventing me from trying it out right now, but the online system agrees your code is fine (e.g. try here http://goto.ucsd.edu:8090/index.html). – Thomas M. DuBuisson Jun 04 '19 at 03:08

0 Answers0