hackage-db-2.0.1: 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.1-5QSb0jJ3R9hGNrDaAE2wMq" 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

Show TargetData Source # 
Generic TargetData Source # 

Associated Types

type Rep TargetData :: * -> * #

FromJSON TargetData Source # 
type Rep TargetData Source # 
type Rep TargetData = D1 * (MetaData "TargetData" "Distribution.Hackage.DB.MetaData" "hackage-db-2.0.1-5QSb0jJ3R9hGNrDaAE2wMq" False) (C1 * (MetaCons "TargetData" PrefixI True) ((:*:) * (S1 * (MetaSel (Just Symbol "length") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * Int)) (S1 * (MetaSel (Just Symbol "hashes") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Map String String)))))