Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explanation / hints for "does not refine Haskell type" error in tutorial #1644

Closed
DestyNova opened this issue Apr 13, 2020 · 3 comments
Closed

Comments

@DestyNova
Copy link

DestyNova commented Apr 13, 2020

Hi, I've been working through the tutorial and enjoying it. In chapter 5, I got stuck for quite a long time on the sparse vector plus exercise. I tried many variations, but kept getting the same error:

Error: Specified type does not refine Haskell type for `RefinedDatatypes.plus` (Plugged Init types old)
The Liquid type
 
    (Num a) -> (Sparse a) -> (Sparse a) -> (Sparse a)
 
is inconsistent with the Haskell type
 
    forall p1 p2 a -> p1 -> p2 -> a
 
defined at /home/rjhala/research/stack/liquid/liquid-server/resources/custom/liquidhaskell/sandbox/1586736919_6704.hs:83:1-4
 
Specifically, the Liquid component
 
    (Sparse a)
 
is inconsistent with the Haskell component
 
    p
 
HINT: Use the hole '_' instead of the mismatched component (in the Liquid specification)

I tried replacing parts of the LH type signature with holes as suggested
After some searching, I found issue #1297 which looked very similar. The solution there was to add an explicit Haskell type as well as the LH type, which solved the problem in that issue. I tried the same thing and it immediately solved the problem for me too:

{-@ plus     :: (Num a) =>
    x:Sparse a ->
    SparseN a (spDim x) ->
    SparseN a (spDim x) @-}
plus :: (Num a) => Sparse a -> Sparse a -> Sparse a    -- needed this line
plus x y = undefined

Could I suggest that some text be added to the tutorial (maybe in chapter 5 where it's likely to happen) so that the reader can know what to expect and how to deal with it? I would do a PR myself but I still don't fully understand why it's necessary to add an explicit Haskell type signature here. My mental model was that LH would automatically emit a Haskell type signature similar to the one I inserted above?

@ranjitjhala
Copy link
Member

ranjitjhala commented Apr 13, 2020 via email

@ranjitjhala
Copy link
Member

ranjitjhala commented Apr 13, 2020 via email

@DestyNova
Copy link
Author

Thanks for the helpful explanation 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants