dbmigrations-0.3: An implementation of relational database "migrations"

Database.Schema.Migrations.Dependencies

Description

This module types and functions for representing a dependency graph of arbitrary objects and functions for querying such graphs to get dependency and reverse dependency information.

Synopsis

Documentation

class (Eq a, Ord a) => Dependable a whereSource

Dependable objects supply a representation of their identifiers, and a list of other objects upon which they depend.

Methods

depsOf :: a -> [String]Source

The identifiers of the objects on which a depends.

depId :: a -> StringSource

The identifier of a Dependable object.

data DependencyGraph a Source

A DependencyGraph represents a collection of objects together with a graph of their dependency relationships. This is intended to be used with instances of Dependable.

Constructors

DG 

Fields

depGraphObjectMap :: [(a, Int)]

A mapping of Dependable objects to their graph vertex indices.

depGraphNameMap :: [(String, Int)]

A mapping of Dependable object identifiers to their graph vertex indices.

depGraph :: Gr String String

A directed Gr (graph) of the Dependable objects' dependency relationships, with String vertex and edge labels.

Instances

mkDepGraph :: Dependable a => [a] -> Either String (DependencyGraph a)Source

Build a dependency graph from a list of Dependables. Return the graph on success or return an error message if the graph cannot be constructed (e.g., if the graph contains a cycle).

dependencies :: Dependable d => DependencyGraph d -> String -> [String]Source

Given a dependency graph and an ID, return the IDs of objects that the object depends on. IDs are returned with least direct dependencies first (i.e., the apply order).

reverseDependencies :: Dependable d => DependencyGraph d -> String -> [String]Source

Given a dependency graph and an ID, return the IDs of objects that depend on it. IDs are returned with least direct reverse dependencies first (i.e., the revert order).