GHCi command to solve a constraint
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) Eq Type1 -- Defined in ‘MyModule’
2) Eq a => Eq (Maybe a) -- Defined in ‘GHC.Classes’
3) Eq (Maybe Type1) -- Put a ~ Int in 2) and use 1)
4) Eq Bool -- Defined in ‘GHC.Classes’
5) (Eq a, Eq b) => Eq (a,b) -- Defined in ‘GHC.Classes’
6) 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)