    module Hint.Conversions (
          typeToString, kindToString, moduleToString, isSucceeded
    ) where

    import qualified Hint.GHC as GHC

    import Hint.Base

    -- --------- Types / Kinds -----------------------

    typeToString :: MonadInterpreter m => GHC.Type -> m String
    typeToString :: forall (m :: * -> *). MonadInterpreter m => Type -> m String
    typeToString Type
    t
     = do -- Unqualify necessary types
          -- (i.e., do not expose internals)
          unqual <- RunGhc m PrintUnqualified
    forall a. RunGhc m a
    forall (m :: * -> *) a. MonadInterpreter m => RunGhc m a
    runGhc GhcT n PrintUnqualified
    forall {n :: * -> *}.
    (MonadIO n, MonadMask n) =>
    GhcT n PrintUnqualified
    forall (m :: * -> *). GhcMonad m => m PrintUnqualified
    GHC.getPrintUnqual
          withDynFlags $ \DynFlags
    df ->
            -- TODO: get unit state from somewhere?
            String -> m String
    forall a. a -> m a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (String -> m String) -> String -> m String
    forall a b. (a -> b) -> a -> b
    $ DynFlags -> UnitState -> PrintUnqualified -> SDoc -> String
    GHC.showSDocForUser DynFlags
    df UnitState
    GHC.emptyUnitState PrintUnqualified
    unqual (Type -> SDoc
    GHC.pprTypeForUser Type
    t)

    kindToString :: MonadInterpreter m => GHC.Kind -> m String
    kindToString :: forall (m :: * -> *). MonadInterpreter m => Type -> m String
    kindToString Type
    k
     = (DynFlags -> m String) -> m String
    forall (m :: * -> *) a.
    MonadInterpreter m =>
    (DynFlags -> m a) -> m a
    withDynFlags ((DynFlags -> m String) -> m String)
    -> (DynFlags -> m String) -> m String
    forall a b. (a -> b) -> a -> b
    $ \DynFlags
    df ->
         String -> m String
    forall a. a -> m a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (String -> m String) -> String -> m String
    forall a b. (a -> b) -> a -> b
    $ DynFlags -> SDoc -> String
    GHC.showSDoc DynFlags
    df (Type -> SDoc
    GHC.pprTypeForUser Type
    k)

    -- ---------------- Modules --------------------------

    moduleToString :: GHC.Module -> String
    moduleToString :: Module -> String
    moduleToString = ModuleName -> String
    GHC.moduleNameString (ModuleName -> String)
    -> (Module -> ModuleName) -> Module -> String
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Module -> ModuleName
    forall unit. GenModule unit -> ModuleName
    GHC.moduleName

    -- ---------------- Misc -----------------------------

    isSucceeded :: GHC.SuccessFlag -> Bool
    isSucceeded :: SuccessFlag -> Bool
    isSucceeded SuccessFlag
    GHC.Succeeded = Bool
    True
    isSucceeded SuccessFlag
    GHC.Failed    = Bool
    False