[GHC] #9622: GHCi command to solve a constraint

GHC ghc-devs at haskell.org
Sun Sep 21 09:13:07 UTC 2014


#9622: GHCi command to solve a constraint
-------------------------------------+-------------------------------------
       Reporter:  monoidal           |                   Owner:
           Type:  feature request    |                  Status:  new
       Priority:  normal             |               Milestone:
      Component:  Compiler (Type     |                 Version:  7.8.3
  checker)                           |        Operating System:
       Keywords:                     |  Unknown/Multiple
   Architecture:  Unknown/Multiple   |         Type of failure:
     Difficulty:  Unknown            |  None/Unknown
     Blocked By:                     |               Test Case:
Related Tickets:                     |                Blocking:
                                     |  Differential Revisions:
-------------------------------------+-------------------------------------
 It would be nice to have a `:solve` command for ghci that took a class
 constraint and returned either its derivation or an error message. A
 possible interface could look like so:

 {{{
 ghci> :solve Eq (Maybe Type1, Bool)
 1) instance Eq Type1                 -- Defined in ‘MyModule’
 2) instance Eq a => Eq (Maybe a)     -- Defined in ‘GHC.Classes’
 3) instance Eq (Maybe Type1)         -- Put a ~ Int in 2) and use 1)
 4) instance Eq Bool                  -- Defined in ‘GHC.Classes’
 5) instance (Eq a, Eq b) => Eq (a,b) -- Defined in ‘GHC.Classes’
 6) instance Eq (Maybe Type1, Bool)   -- Put a ~ Maybe Type1, b ~ Bool in
 5) and use 3), 4)
 ghci> :solve Eq (Int -> Int)
 No instance for Eq (Int -> Int)
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9622>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list