I am trying to write some specifications for a module Data.Ratio. So far I:
module spec Data.Ratio where
import GHC.Real
Data.Ratio.denominator :: GHC.Real.Integral a => r : GHC.Real.Ratio a -> {x:a | x > 0}
The code I'm checking is:
{-@ die :: {v:String | false} -> a @-}
die msg = error msg
main :: IO ()
main = do
let x = 3 % 5
print $ denominator x
if denominator x < 0
then die "bad ending"
else putStrLn "good ending"
The code is considered safe because the denominator never returns a negative value.
I found this strange because I could just write x <= 0as a postcondition, which according to the module documentation is Data.Rationot possible. Obviously, Liquid Haskell does not compare my postcondition with the implementation denominator.
I understand that since the implementation of the function has not been tested, I better use the accept keyword:
assume Data.Ratio.denominator :: GHC.Real.Integral a => r : GHC.Real.Ratio a -> {x:a | x > 0}
However, I get:
Error: Bad Type Specification
assumed type GHC.Real.denominator :: (Ratio a) -> {VV: a | VV> 0}
Sort Error in Refinement: {VV : a_a2kc | VV > 0}
Unbound Symbol a_a2kc
Perhaps you meant: papp5, papp3, papp4, head, papp2, papp7, papp6, papp1, tail
because
The sort a_a2kc is not numeric
- LH
assume , ? - ,
assume? a ? , assume?