allen-0.1.0.0: A monadic way of calculating relations between intervals of time.
MaintainerArchaversine
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Allen.Types

Description

This module provides types that are used throughout the rest of the library. This includes types for intervals, relations, and the interval graph.

Intervals

An Interval is a data type that represents a single interval. It contains an ID of type IntervalID and a map of relations to other intervals of type Map IntervalID RelationBits.

An IntervalID is essentially the same as an Int, but it is helpful to have a dedicated type synonym to distinguish functions that perform operations interval IDs.

Relations

A Relation is a data type that represents a relation between two intervals. It is defined in terms of thirteen constructors, where each constructor represents one of the thirteen possible relations in Allen's interval algebra.

The RelationBits is used to represent a set of possible representation. It is synonymous with a Word16, and is used to represent a set of possible relations. Since there are only thirteen different relations, only 13 of the 16 bits in the Word16 are used.

Interval Graph

An interval graph is a map of IntervalIDs to Intervals. It is used to represent the network of intervals and their relations to each other.

Allen Monad

The Allen monad is a state monad that is used to keep track of the interval graph that is being built up during the computation. Since it is a synonym of the State monad, it is possible to use all of the functions in the Control.Monad.State module.

Synopsis

Documentation

data Interval Source #

An interval is a data type that represents a single interval. It contains an ID of type IntervalID and a map of relations to other intervals of type Map IntervalID RelationBits. It should not be directly used in a computation unless the IntervalGraph is in its final state.

Instances

Instances details
Show Interval Source #

Ex: Interval 3 (d 1, D 2)

Instance details

Defined in Data.Allen.Types

type Allen = State IntervalGraph Source #

A specific instance of the state monad that is used to keep track of the IntervalGraph that is being built up during the computation.

type IntervalID = Int Source #

How intervals are uniquely identified.

type IntervalGraph = Map IntervalID Interval Source #

This is the main type that is used to represent the network of intervals.

data Relation Source #

A type where each constructor represents one of the thirteen relations in Allen's interval algebra.

Constructors

Precedes

In Char form: p

Meets

In Char form: m

Overlaps

In Char form: o

FinishedBy

In Char form: F

Contains

In Char form: D

Starts

In Char form: s

Equals

In Char form: e

StartedBy

In Char form: S

During

In Char form: d

Finishes

In Char form: f

OverlappedBy

In Char form: O

MetBy

In Char form: M

PrecededBy

In Char form: P

Instances

Instances details
Bounded Relation Source # 
Instance details

Defined in Data.Allen.Types

Enum Relation Source # 
Instance details

Defined in Data.Allen.Types

Show Relation Source # 
Instance details

Defined in Data.Allen.Types

Eq Relation Source # 
Instance details

Defined in Data.Allen.Types

type RelationBits = Word16 Source #

A bit representation that acts as a set of possible relations between intervals.

allRelations :: [Relation] Source #

List of all possible relations.

allRelationBits :: RelationBits Source #

Bit representation of all possible relations.

toBits :: Relation -> RelationBits Source #

Convert a Relation type to its bit representation.

fromBits :: RelationBits -> [Relation] Source #

Convert a bit representation to a list of Relation types.

relationUnion :: [RelationBits] -> RelationBits Source #

Calculate the union of a list of relations.

relationIntersection :: [RelationBits] -> RelationBits Source #

Calculate the intersection of a list of relations.

relationToChar :: Relation -> Char Source #

Convert a relation to its Char representation.

fromID :: IntervalID -> Allen Interval Source #

Return the interval given it's ID. Panics if ID doesn't exist.