Skip to content

Instantly share code, notes, and snippets.

@puffnfresh
Created September 12, 2017 11:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save puffnfresh/7f1532035b28674eccec1f218f46061e to your computer and use it in GitHub Desktop.
Save puffnfresh/7f1532035b28674eccec1f218f46061e to your computer and use it in GitHub Desktop.
removeModName :: Name -> Name
removeModName =
filterModName (const False)
removeAllModNames :: Dec -> Dec
removeAllModNames =
transformOnOf (_SigD . _2) typeChildren (typeName %~ removeModName) .
transformOnOf (_ValD . _2 . bodyExp) expChildren (expName %~ removeModName)
simplify :: Dec -> Dec
simplify =
_SigD . _2 %~ removeEmptyForall
renderNoLength :: Ppr a => a -> String
renderNoLength =
HPJ.renderStyle (HPJ.style { HPJ.lineLength = maxBound }) . to_HPJ_Doc . ppr
simplifiedTH :: [Dec] -> ExpQ
simplifiedTH =
stringE . renderNoLength . fmap (simplify . removeAllModNames)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment