#14897 closed bug (invalid)
QuantifiedConstraints: Can't print type of quantified constraint
Reported by: | Iceland_jack | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Compiler | Version: | 8.5 |
Keywords: | QuantifiedConstraints | Cc: | |
Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
Type of failure: | None/Unknown | Test Case: | |
Blocked By: | Blocking: | ||
Related Tickets: | Differential Rev(s): | ||
Wiki Page: |
Description
{-# Language QuantifiedConstraints, FlexibleInstances, UndecidableInstances, MonoLocalBinds #-} class (forall xx. Functor (f xx)) => Functor' f instance (forall xx. Functor (f xx)) => Functor' f fmap' :: Functor' f => (b -> b') -> (f a b -> f a b') fmap' = fmap
load in ghci and check the type of fmap'
$ ... -ignore-dot-ghci Bug2.hs GHCi, version 8.5.20180128: http://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( Bug2.hs, interpreted ) Ok, one module loaded. *Main> :t fmap' <interactive>:1:1: error: No instance for (Functor (f xx)) arising from a use of ‘fmap'’ *Main>
Simpler example
GHCi, version 8.5.20180128: http://www.haskell.org/ghc/ :? for help Prelude> :set -XRankNTypes -XQuantifiedConstraints Prelude> let a :: (forall xx. Monoid (f xx)) => f a; a = mempty Prelude> :t a <interactive>:1:1: error: No instance for (Monoid (f xx)) arising from a use of ‘a’ Prelude>
I expected the same output as :t +v
Prelude> :t +v a a :: (forall xx. Monoid (f xx)) => f a
Change History (3)
comment:1 Changed 19 months ago by
comment:2 Changed 18 months ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
What :t e
does is to infer the type of the expression e
and print it.
So with a :: (forall xx. Monoid (f xx)) => f a
, it's as if you'd typed the top level decl
foo = a
What happens? We instantiate the type of a
to get a Wanted constraint
[W] forall x. Monoid (f1 x)
and the type f1 a1
, where f1
and a1
are unification variables. Now we try to simplify the constraints and infer the most general type for foo
. Unsurprisingly, we fail with the reported error message.
If, rather than inferring the type of an arbitrary expression, you want to ask for the type (and other info) about an identifier, use :info a
.
comment:3 Changed 16 months ago by
Keywords: | wipT2893 removed |
---|
I know printing isn't the problem, “over-eagerly resolves quantified constraint...” something