Unable to get the output of an arbitrary constraint as a Haskell value.
The closest thing I can think of if you want to check if the output is what you think is to look at the desugarer output.
ghc -ddump-ds -ddump-to-file A.hs
The relevant part is as follows:
irred :: Show [Int]
[LclId]
irred = GHC.Show.$fShow[] @ Int GHC.Show.$fShowInt
proof :: Dict (Show [Int])
[LclIdX]
proof = Cns.Dict @ (Show [Int]) irred
Another way is to write special classes used to display output, both in types and in values, but, of course, this does not apply to existing type classes.
{-
FlexibleInstances, KindSignatures, MultiParamTypeClasses, RankNTypes,
ScopedTypeVariables, TypeApplications, TypeOperators,
UndecidableInstances
import Data.Typeable
import Data.Kind
data (c :: [Type]) :=> (d :: Type -> Constraint)
class MyShow a d where
myshow :: a -> String
instance (d ~ ('[] :=> MyShow Int)) => MyShow Int d where
instance (MyShow a da, d ~ ('[da] :=> MyShow [a])) => MyShow [a] d where
myshowInstance :: forall a d. (Typeable d, MyShow a d) => TypeRep
myshowInstance = typeRep @_ @d Proxy
main = print (myshowInstance @[Int])
, , TypeRep
, , .
:=> (': * (:=> ('[] *) (MyShow Int)) ('[] *)) (MyShow [Int])