Created
November 4, 2014 02:47
-
-
Save mgsloan/ced0f5532db46d936fd6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | Load all of the hints at compile time. | |
hlintFixities :: [HSE.Fixity] | |
hlintClassifies :: [Classify] | |
hlintBuiltins :: [String] | |
hlintRules :: [HintRule] | |
(hlintFixities, hlintClassifies, hlintBuiltins, hlintRules) = | |
$(do let dataDir = "../learning-site/config/hlint/" | |
(builtin, matches) <- TH.qRunIO $ findSettings dataDir (dataDir </> "HLint.hs") Nothing | |
let (classify, rules) = concat2 $ map readSettings matches | |
-- All of these helpers are copied from HLint | |
concat2 xs = (concat a, concat b) where (a,b) = unzip xs | |
fixities = getFixity =<< moduleDecls =<< matches | |
getFixity :: HSE.Decl a -> [HSE.Fixity] | |
getFixity (HSE.InfixDecl sl a mp ops) = [HSE.Fixity (HSE.sAssoc a) (fromMaybe 9 mp) (HSE.sQName $ HSE.UnQual sl $ f o) | o <- ops] | |
where f (HSE.VarOp _ x) = x | |
f (HSE.ConOp _ x) = x | |
getFixity _ = [] | |
moduleDecls :: HSE.Module HSE.SrcSpanInfo -> [HSE.Decl HSE.SrcSpanInfo] | |
moduleDecls (HSE.Module _ _ _ _ xs) = xs | |
moduleDecls _ = [] -- XmlPage/XmlHybrid | |
(\a b c d -> TH.TupE [a, b, TH.SigE c (TH.AppT TH.ListT (TH.ConT ''String)), d]) | |
<$> TH.lift fixities | |
<*> TH.lift classify | |
<*> TH.lift builtin | |
<*> TH.lift rules) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment