Skip to content

QuantifiedConstraints: Can't print type of quantified constraint

{-# 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
Trac metadata
Trac field Value
Version 8.5
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information