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

"Specified type does not refine Haskell type" when using type classes #2341

Open
pacastega opened this issue Sep 19, 2024 · 0 comments
Open

Comments

@pacastega
Copy link

When trying to assume the type of a Haskell function involving type classes:

module Fold where
{-@ assume foldl :: (b -> a -> b) -> b -> t a -> b @-}

Liquid Haskell gives the following error:

    Specified type does not refine Haskell type for `Data.Foldable.foldl` (Checked)
The Liquid type
.
    forall t ->
Data.Foldable.Foldable t
-> forall b a -> (t -> t -> t) -> t -> t t -> t
.
is inconsistent with the Haskell type
.
    forall (t :: GHC.Types.Type -> GHC.Types.Type) b a.
Data.Foldable.Foldable t =>
(b -> a -> b) -> b -> t a -> b
.
defined at UnhelpfulNoLocationInfo
.
  |
3 | {-@ assume foldl :: (b -> a -> b) -> b -> t a -> b @-}
  |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

That is,

  1. The type class instance Data.Foldable.Foldable t gets placed before the universals forall b a and
  2. The type variables a and b get incorrectly substituted by t.

This also happens when writing the existentials and type classes explicitly:

{-@ assume foldl :: forall t b a .
                    Foldable t => (b -> a -> b) -> b -> t a -> b @-}
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