I'm looking for ways of way to bring type information into value level in Haskell.
One way I know to represent any type information as a value is the Language.Haskell.TH.Type
.
Is there any way to implement a function that takes Proxy a
and returns Language.Haskell.TH.Type
(or alternative type to represent any type) of the a
type as follows?
If you have a better idea to bring type information as a value that does not use Language.Haskell.TH.Type
, please tell me that, too.
import Data.Proxy (Proxy)
import Language.Haskell.TH (Type, TypeQ)
-- |
-- >>> amazing (Proxy :: Proxy Bool)
-- ConT GHC.Types.Bool
--
-- >>> amazing (Proxy :: Proxy [String])
-- AppT ListT (ConT GHC.Base.String)
amazing :: Proxy a -> Type
amazing p = undefined
-- |
-- Or if above is impossible, how about this?
amazingQ :: Proxy a -> TypeQ
amazingQ p = undefined