vabal-lib-2.0.0: Core algorithms and datatypes used by vabal

Safe HaskellNone
LanguageHaskell2010

GhcDatabase

Contents

Description

This module contains the GhcDatabase, which is a Map-like type associating to each ghc version its GhcMetadata informations, and utility functions to to manipulate and query it.

Synopsis

Documentation

data GhcMetadata Source #

Metadata associated to a GHC version

Constructors

GhcMetadata 

Fields

data GhcDatabase Source #

Map associating to each GHC version its GhcMetadata

defaultGhcDatabaseURL :: String Source #

The URL from which you can download a ready to be used GhcDatabase

Conversion from/to List

dbFromList :: [(Version, GhcMetadata)] -> GhcDatabase Source #

O(n*log n). Create a GhcDatabase from a list key-value pairs.

The key is the ghc version, the value is the GhcMetadata for that version

dbToList :: GhcDatabase -> [(Version, GhcMetadata)] Source #

O(n). Convert the GhcDatabase to a list of key-value pairs

ghcVersions :: GhcDatabase -> Set Version Source #

O(n). Get all ghc versions contained in the database

Queries

isEmpty :: GhcDatabase -> Bool Source #

O(1). Check whether the GhcDatabase is empty

metadataForGhc :: GhcDatabase -> Version -> Maybe GhcMetadata Source #

O(log n). Get GhcMetadata for a GHC version, if it's in the database

baseVersionForGhc :: GhcDatabase -> Version -> Maybe Version Source #

O(log n). Get base version for a GHC version, if it's in the database

cabalLibRangeForGhc :: GhcDatabase -> Version -> Maybe VersionRange Source #

O(log n). Get Supported Cabal version range for a GHC version, if it's in the databasr

hasGhcVersion :: GhcDatabase -> Version -> Bool Source #

O(log n). Check whether the database contains a GHC version

newest :: GhcDatabase -> Maybe (Version, GhcMetadata) Source #

O(log n). Get newest GHC (and its metadata) found in the database

Parse from CSV file

parseGhcDatabase :: ByteString -> Either String GhcDatabase Source #

Parse a GhcDatabase from a csv string. The format of the csv string must be the following:

The first line is the header, it is expected to contain these three columns: ghcVersion, baseVersion, minCabalVersion Each line must at least contain values for those three columns.

A simple example:

ghcVersion,baseVersion,minCabalVersion
8.6.3,4.12.0.0,2.4

Filter database entries

filterGhcVersions :: GhcDatabase -> Set Version -> GhcDatabase Source #

O(m*log(nm + 1)), m <= n/. Get a restricted database with only a set of GHC versions

excludeGhcVersions :: GhcDatabase -> Set Version -> GhcDatabase Source #

O(m*log(nm + 1)), m <= n/. Exclude all ghc versions in the set from the database

filterBaseVersionIn :: GhcDatabase -> VersionRange -> GhcDatabase Source #

O(n). Filter database entries with base version in the given VersionRange

filterMinCabalVersionIn :: GhcDatabase -> VersionRange -> GhcDatabase Source #

O(n). Filter database entries with supported Cabal version range in the given VersionRange