Maintainer | Archaversine |
---|---|
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
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 IntervalID
s to Interval
s. 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
- data Interval = Interval {}
- type Allen = State IntervalGraph
- type IntervalID = Int
- type IntervalGraph = Map IntervalID Interval
- data Relation
- = Precedes
- | Meets
- | Overlaps
- | FinishedBy
- | Contains
- | Starts
- | Equals
- | StartedBy
- | During
- | Finishes
- | OverlappedBy
- | MetBy
- | PrecededBy
- type RelationBits = Word16
- allRelations :: [Relation]
- allRelationBits :: RelationBits
- toBits :: Relation -> RelationBits
- fromBits :: RelationBits -> [Relation]
- relationUnion :: [RelationBits] -> RelationBits
- relationIntersection :: [RelationBits] -> RelationBits
- relationToChar :: Relation -> Char
- fromID :: IntervalID -> Allen Interval
Documentation
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.
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.
A type where each constructor represents one of the thirteen relations in Allen's interval algebra.
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
Bounded Relation Source # | |
Enum Relation Source # | |
Show Relation Source # | |
Eq Relation Source # | |
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.