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

liquidhaskell error about merge example #76

Closed
mhwombat opened this issue Jan 6, 2019 · 6 comments · Fixed by #78
Closed

liquidhaskell error about merge example #76

mhwombat opened this issue Jan 6, 2019 · 6 comments · Fixed by #78

Comments

@mhwombat
Copy link

mhwombat commented Jan 6, 2019

Liquidhaskell reports an error with one of the examples:

 /home/amy/liquidhaskell-tutorial/src/05-datatypes.lhs:338:1-5: Error: Liquid Type Mismatch
  
 338 | merge xs  Emp = xs
       ^^^^^
  
   Inferred type
     VV : {v : GHC.Prim.Addr# | v == "/home/amy/liquidhaskell-tutorial/src/05-datatypes.lhs:(338,1)-(342,39)|function merge"}
  
   not a subtype of Required type
     VV : {VV : GHC.Prim.Addr# | 5 < 4}

The code it's complaining about is this:

merge         :: (Ord a) => IncList a -> IncList a -> IncList a
merge xs  Emp = xs    <--- line 338
merge Emp ys  = ys
merge (x :< xs) (y :< ys)
  | x <= y    = x :< merge xs (y :< ys)
  | otherwise = y :< merge (x :< xs) ys
@mhwombat
Copy link
Author

mhwombat commented Jan 6, 2019

You can also see the error on the web page (http://ucsd-progsys.github.io/liquidhaskell-tutorial/05-datatypes.html) if you click the compile button.

@skyzh
Copy link
Contributor

skyzh commented Jan 21, 2019

I encountered the same error, but I found that add a line merge _ _ = Emp makes sense. Here's my code:

merge :: (Ord a) => IncList a -> IncList a -> IncList a
merge Emp ys = ys
merge xs Emp = xs
merge (x :< xs) (y :< ys)
    | x <= y    = x :< (merge xs (y :< ys))
    | otherwise = y :< (merge (x :< xs) ys)
merge _ _ = Emp

This may pass liquid haskell safe check.

@ranjitjhala
Copy link
Member

ranjitjhala commented Jan 21, 2019 via email

@skyzh
Copy link
Contributor

skyzh commented Jan 22, 2019

@ranjitjhala
Copy link
Member

ranjitjhala commented Jan 23, 2019 via email

@skyzh
Copy link
Contributor

skyzh commented Jan 23, 2019

I've already sent #78 yesterday :) @ranjitjhala

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

Successfully merging a pull request may close this issue.

3 participants