Last active
November 1, 2015 02:53
-
-
Save scturtle/15e724a1c9e7fc6d8fac to your computer and use it in GitHub Desktop.
Extend hoogle database
This file contains hidden or 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
#!/usr/bin/env stack | |
-- stack --resolver global runghc --package turtle | |
{-# LANGUAGE OverloadedStrings #-} | |
import Turtle | |
import qualified Data.Text as T | |
parser :: Parser Text | |
parser = argText "pkg" "Package name" | |
main :: IO () | |
main = sh $ do | |
pkg <- options "Extend hoogle database" parser | |
h <- home | |
p <- pathToText <$> find (has "hoogle" <> suffix "databases") (h </> ".stack") | |
cd . fromText . T.init $ p | |
result <- shell' $ format ("wget https://hackage.haskell.org/package/" | |
%s%"/docs/"%s%".txt") pkg pkg | |
case result of | |
ExitFailure _ -> error "package not found" | |
_ -> return () | |
shell' $ format ("hoogle convert "%s%".txt") pkg | |
shell' $ format ("hoogle combine default.hoo "%s%".hoo -o new.hoo") pkg | |
mv "new.hoo" "default.hoo" | |
where shell' = flip shell empty | |
pathToText = either (error "hoogle databases not found") id . toText |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment