hackage-db-2.0: Access Hackage's package database via Data.Map

Maintainersimons@cryp.to
Stabilityprovisional
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Distribution.Hackage.DB.MetaData

Description

Types and class instances for parsing the package.json files found in a 01-index.tar tarball from Hackage with Data.Aeson. These parsers mirror the exact structure of those files, but only a small part of it is actually of interest to anyone other than implementors of cabal-install. Everyone else will most likely prefer the functions oferred by Distribution.Hackage.DB.Parsed.

Synopsis

Documentation

parseMetaData :: ByteString -> MetaData Source #

Parse the package.json file found in a 01-index.tar tarball from Hackage with Data.Aeson. This function is a convenience wrapper around eitherDecode that throws an InvalidMetaFile exception to signal failure.

>>> :set -XOverloadedStrings
>>> parseMetaData "{\"signatures\":[],\"signed\":{\"_type\":\"Targets\",\"expires\":null,\"targets\":{\"<repo>/package/jailbreak-cabal-1.3.2.tar.gz\":{\"hashes\":{\"md5\":\"ba42b3e68323ccbeb3ac900cd68f9e90\",\"sha256\":\"212a8bbc3dfc748c4063282414a2726709d651322f3984c9989179d2352950f4\"},\"length\":2269}},\"version\":0}}"
MetaData {signed = SignedMetaData {version = 0, expires = Nothing, _type = "Targets", targets = fromList [("<repo>/package/jailbreak-cabal-1.3.2.tar.gz",TargetData {length = 2269, hashes = fromList [("md5","ba42b3e68323ccbeb3ac900cd68f9e90"),("sha256","212a8bbc3dfc748c4063282414a2726709d651322f3984c9989179d2352950f4")]})]}, signatures = []}
>>> parseMetaData "{}"
*** Exception: InvalidMetaFile "Error in $: key \"signed\" not present"
>>> parseMetaData ""
*** Exception: InvalidMetaFile "Error in $: not enough input"

data MetaData Source #

Constructors

MetaData 

Instances

Show MetaData Source # 
Generic MetaData Source # 

Associated Types

type Rep MetaData :: * -> * #

Methods

from :: MetaData -> Rep MetaData x #

to :: Rep MetaData x -> MetaData #

FromJSON MetaData Source # 
type Rep MetaData Source # 
type Rep MetaData = D1 (MetaData "MetaData" "Distribution.Hackage.DB.MetaData" "hackage-db-2.0-BYHDQQOdcaFFUys8SohKXB" False) (C1 (MetaCons "MetaData" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "signed") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 SignedMetaData)) (S1 (MetaSel (Just Symbol "signatures") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [String]))))

data TargetData Source #

Constructors

TargetData 

Fields

Instances