implementing fromTyThing.
This commit is contained in:
@@ -11,6 +11,7 @@ import GHC
|
||||
import Panic (throwGhcException)
|
||||
import Language.Haskell.GhcMod.Doc (showUnqualifiedPage)
|
||||
import Language.Haskell.GhcMod.GHCApi
|
||||
import Language.Haskell.GhcMod.Gap
|
||||
import Language.Haskell.GhcMod.Types
|
||||
import Name
|
||||
import Outputable
|
||||
@@ -92,12 +93,15 @@ showExport opt minfo e = do
|
||||
justIf _ False = Nothing
|
||||
|
||||
showThing :: DynFlags -> TyThing -> Maybe String
|
||||
showThing dflag (AnId i) = Just $ formatType dflag varType i
|
||||
showThing dflag (ADataCon d) = Just $ formatType dflag dataConRepType d
|
||||
showThing _ (ATyCon t) = unwords . toList <$> tyType t
|
||||
showThing dflag tything = showThing' dflag (fromTyThing tything)
|
||||
|
||||
showThing' :: DynFlags -> GapThing -> Maybe String
|
||||
showThing' dflag (GtI i) = Just $ formatType dflag varType i
|
||||
showThing' dflag (GtD d) = Just $ formatType dflag dataConRepType d
|
||||
showThing' _ (GtT t) = unwords . toList <$> tyType t
|
||||
where
|
||||
toList t' = t' : getOccString t : map getOccString (tyConTyVars t)
|
||||
showThing _ _ = Nothing
|
||||
showThing' _ _ = Nothing
|
||||
|
||||
formatType :: NamedThing a => DynFlags -> (a -> Type) -> a -> String
|
||||
formatType dflag f x = showOutputable dflag (removeForAlls $ f x)
|
||||
|
||||
Reference in New Issue
Block a user