The problem
I've been very excited playing with LiquidHaskell, however, I don't know to what extent I need to modify my original Haskell code to meet LiquidHaskell's requirements.
Here is a simple example of how Liquid's specifications work well for String type but not for Text type.
For String type it works well
Example
I define a Liquid type where we say that the values of a tuple cannot be the same:
{-@ type NoRouteToHimself = {v:(_, _) | (fst v) /= (snd v)} @-}
Then, for a String type specification it works well as shown below:
{-@ strOk :: NoRouteToHimself @-}
strOk :: (String, String)
strOk = ("AA", "AB")
LiquidHaskel Output >> RESULT: SAFE
{-@ strBad :: NoRouteToHimself @-}
strBad :: (String, String)
strBad = ("AA", "AA")
LiquidHaskel Output >> RESULT: UNSAFE
So far so good, let's define the same function for the Text type.
For the Text type it goes wrong
Example
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.Text as Tx
{-@ foo :: NoRouteToHimself @-}
foo :: (Tx.Text, Tx.Text)
foo = ("AA", "AB")
Expected Result: RESULT: SAFE
LiquidHaskell Output: RESULT: UNSAFE
..Example.hs:102:3-5: Error: Liquid Type Mismatch
102 | foo = ("AA", "AB")
^^^
Inferred type
VV : {v : (Data.Text.Internal.Text, Data.Text.Internal.Text) | x_Tuple22 v == ?a
&& x_Tuple21 v == ?b
&& snd v == ?a
&& fst v == ?b}
not a subtype of Required type
VV : {VV : (Data.Text.Internal.Text, Data.Text.Internal.Text) | fst VV /= snd VV}
In Context
?b : Data.Text.Internal.Text
?a : Data.Text.Internal.Text
Apparently LiquidHaskell cannot evaluate the values of the tuple for this case. Any suggestions?
fromString
might not even be injective. Unfortunately I'm still digging to find out what exactly a spec file is and how to use it (I just started playing with LH today, so don't despair) – Intramuscular