hackage-processing (empty) → 0.0
raw patch · 4 files changed
+104/−0 lines, 4 filesdep +Cabaldep +basedep +containerssetup-changed
Dependencies added: Cabal, base, containers, hackage-db
Files
- LICENSE +30/−0
- Setup.lhs +3/−0
- hackage-processing.cabal +37/−0
- src/Main.hs +34/−0
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2016, Henning Thielemann++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Henning Thielemann nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.lhs view
@@ -0,0 +1,3 @@+#! /usr/bin/env runhaskell+> import Distribution.Simple+> main = defaultMain
+ hackage-processing.cabal view
@@ -0,0 +1,37 @@+Name: hackage-processing+Version: 0.0+Synopsis: Process 00-index.tar.gz from Hackage+Description:+ Currently it only contains a program+ for fetching contributions of an author to Hackage+ and format it as a LaTeX table.+ .+ > hackage-find-contribution thielemann+Homepage: http://hub.darcs.net/thielema/hackage-processing+License: BSD3+License-File: LICENSE+Author: Henning Thielemann+Maintainer: haskell@henning-thielemann.de+Category: Distribution+Build-Type: Simple+Cabal-Version: >=1.10++Source-Repository this+ Tag: 0.0+ Type: darcs+ Location: http://hub.darcs.net/thielema/hackage-processing++Source-Repository head+ Type: darcs+ Location: http://hub.darcs.net/thielema/hackage-processing++Executable hackage-find-contribution+ Main-Is: Main.hs+ Hs-Source-Dirs: src+ Default-Language: Haskell2010+ GHC-Options: -Wall+ Build-Depends:+ Cabal >=1.22 && <2,+ hackage-db >=1.22 && <1.23,+ containers >=0.4 && <0.6,+ base >=4.5 && <4.9
+ src/Main.hs view
@@ -0,0 +1,34 @@+module Main where++import qualified Distribution.Hackage.DB.Parsed as DB+import qualified Distribution.PackageDescription as Pkg+import Distribution.PackageDescription (GenericPackageDescription)+import Distribution.Text (display)+import System.Environment (getArgs)+import Text.Printf (printf)++import qualified Data.Foldable as Fold+import qualified Data.List as List+import qualified Data.Map as Map+import Data.Char (toLower)+++hasContributor :: String -> GenericPackageDescription -> Bool+hasContributor person =+ let personLC = map toLower person+ contains = List.isInfixOf personLC . map toLower+ in \gpkg ->+ let pkg = Pkg.packageDescription gpkg+ in contains (Pkg.author pkg) || contains (Pkg.maintainer pkg)++main :: IO ()+main = do+ [person] <- getArgs+ db <- DB.readHackage+ let matching =+ Map.mapMaybe+ (fmap fst . Map.maxViewWithKey .+ Map.filter (hasContributor person)) db+ Fold.sequence_ $ flip Map.mapWithKey matching $ \pkgName (version, pkg) ->+ printf "%s & %s & %s \\\\\n"+ pkgName (display version) (Pkg.synopsis (Pkg.packageDescription pkg))