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

Question about Chapter 5.3: delmin #108

Open
jllang opened this issue Jul 6, 2021 · 2 comments
Open

Question about Chapter 5.3: delmin #108

jllang opened this issue Jul 6, 2021 · 2 comments

Comments

@jllang
Copy link

jllang commented Jul 6, 2021

The function delmin in Chapter 5.3 seems to have a problem. I get the following error:

~/liquidhaskell-tutorial/src/Tutorial_05_Datatypes.lhs:663:30: error:
    Liquid Type Mismatch
    .
    The inferred type
      VV : {v : [GHC.Types.Char] | v ~~ "Don't say I didn't warn ya!"
                                   && len v == strLen "Don't say I didn't warn ya!"
                                   && len v >= 0
                                   && v == "Don't say I didn't warn ya!"}
    .
    is not a subtype of the required type
      VV : {VV : [GHC.Types.Char] | false}
    .
    |
663 | delMin Leaf            = die "Don't say I didn't warn ya!"
    |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I tried adding this specification {-@ delMin :: (Ord a) => u : {t : BST | t /= Leaf} -> MinPair a @-} but it didn't help. With this specification, I get the following error message:

~/liquidhaskell-tutorial/src/Tutorial_05_Datatypes.lhs:657:15: error:
    • Specified type does not refine Haskell type for `Tutorial_05_Datatypes.delMin` (Plugged Init types old)
The Liquid type
.
    (GHC.Classes.Ord a) -> Tutorial_05_Datatypes.BST -> (Tutorial_05_Datatypes.MinPair a)
.
is inconsistent with the Haskell type
.
    forall a ->
GHC.Classes.Ord a =>
Tutorial_05_Datatypes.BST a -> Tutorial_05_Datatypes.MinPair a
.
defined at src/Tutorial_05_Datatypes.lhs:659:1-6
.
Specifically, the Liquid component
.
    {t : Tutorial_05_Datatypes.BST | t /= Tutorial_05_Datatypes.Leaf}
.
is inconsistent with the Haskell component
.
    (Tutorial_05_Datatypes.BST a)
.

HINT: Use the hole '_' instead of the mismatched component (in the Liquid specification)
    • 
    |
657 | {-@ delMin :: (Ord a) => u : {t : BST | t /= Leaf} -> MinPair a @-}
    |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

It seems to me that the problem is when delmin is applied to Leaf, so it feels natural to require that the BST we're applying delmin to cannot be a leaf. Why is this specification rejected?

@jllang
Copy link
Author

jllang commented Jul 7, 2021

Changing the Leafcase return value to undefined fixes the error, but I feel like that's not the best way to solve this.

@jllang
Copy link
Author

jllang commented Jul 7, 2021

Ah, there seems to be a link to another chapter that supposedly helps to fix the problem with delmin. The link doesn't work for me, though.

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

1 participant