Opened 3 years ago

Closed 2 months ago

#12005 closed bug (fixed)

Constraint instances not shown in `:info`

Reported by: Iceland_jack Owned by:
Priority: normal Milestone: 8.6.2
Component: Compiler Version: 7.10.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D5182
Wiki Page:

Description

$ ghci -ignore-dot-ghci -XKindSignatures -XRank2Types -XConstraintKinds -XAllowAmbiguousTypes -XInstanceSigs
GHCi, version 8.1.20160428: http://www.haskell.org/ghc/  :? for help
Prelude> import Data.Kind
Prelude Data.Kind> class Defer (p :: Constraint) where defer :: (p => r) -> r
Prelude Data.Kind> instance Defer () where defer :: r -> r; defer = id
Prelude Data.Kind> :i Defer
class Defer (p :: Constraint) where
  defer :: (p => r) -> r
  {-# MINIMAL defer #-}
        -- Defined at <interactive>:2:1

Same happens with the Data.Constraint.Deferrable which defines:

instance (Typeable a, Typeable b)                   => Deferrable (a ~ b) 
instance (Deferrable a, Deferrable b)               => Deferrable (a, b) 
instance (Deferrable a, Deferrable b, Deferrable c) => Deferrable (a, b, c) 

but no instances are shown:

ghci> import Data.Constraint.Deferrable 
ghci> :i Deferrable 
class Deferrable (p :: Constraint) where
  deferEither :: proxy p -> (p => r) -> Either String r
  {-# MINIMAL deferEither #-}
        -- Defined in ‘Data.Constraint.Deferrable’

Change History (7)

comment:1 Changed 3 months ago by harpocrates

You may be interested in :info! which returns a more reliably complete listing of instances.

Prelude Data.Kind> :i Defer
class Defer (p :: Constraint) where
  defer :: (p => r) -> r
  {-# MINIMAL defer #-}
        -- Defined at <interactive>:2:1
instance [safe] Defer (() :: Constraint)
  -- Defined at <interactive>:3:10

The reason instance Defer (() :: Constraint) is filtered out from the output of :info is due to GHC.getInfo. Unless instructed to not filter its output, this last function will check that all names in an instance head are in scope before reporting it. Due to some wrinkles around constraint tuples, () :: Constraint doesn't satisfy this check. I consider this a bug.

comment:2 Changed 3 months ago by simonpj

I consider this a bug.

I think I do too... () is really built-in syntax. Would you like to fix it?

comment:3 Changed 3 months ago by osa1

Differential Rev(s): Phab:D5182
Status: newpatch

comment:4 Changed 2 months ago by Krzysztof Gogolewski <krz.gogolewski@…>

In 21efbc75/ghc:

GHCi should not filter instances involving cTuples

Summary: See the new T12005 test case for an example of this.

Test Plan: make TEST=T12005

Reviewers: bgamari, osa1

Reviewed By: osa1

Subscribers: osa1, rwbarton, carter

GHC Trac Issues: #12005

Differential Revision: https://phabricator.haskell.org/D5182

comment:5 Changed 2 months ago by monoidal

Status: patchmerge

comment:6 Changed 2 months ago by RyanGlScott

Milestone: 8.6.2

Moving to the 8.6.2 milestone, since these tickets were all recently marked as merge.

comment:7 Changed 2 months ago by bgamari

Resolution: fixed
Status: mergeclosed
Note: See TracTickets for help on using tickets.