Safe Haskell | None |
---|---|
Language | Haskell2010 |
AUTHOR
- Dr. Alistair Ward
DESCRIPTION
Describes the availability of some resource.
CAVEAT
- Availability, as defined here, can only be defined for each whole day in any unspecified week, rather than individual time-slots within a day, or sporadic days in the year. This restriction isn't conceptual, but merely for the tractability of the code.
- Resources available for only part of a day, can't be directly accommodated.
Synopsis
- data Availability
- tag :: String
- calculateAvailabilityRatio :: Fractional f => Availability -> f
- countDaysPerWeekAvailable :: Availability -> NDays
- countInternalAvailabilityGaps :: Availability -> NDays
- findIntersection :: Availability -> Availability -> Availability
- findIntersections :: Foldable foldable => foldable Availability -> Availability
- findUnions :: Foldable foldable => foldable Availability -> Availability
- mkAvailability :: [Day] -> Availability
- isFulltime :: Availability -> Bool
- isUnavailable :: Availability -> Bool
- isAvailableOn :: Day -> Availability -> Bool
Types
Data-types
data Availability Source #
The set of days on which an arbitrary resource is available.
Instances
Constants
Functions
calculateAvailabilityRatio :: Fractional f => Availability -> f Source #
Returns the ratio of the available portion of the week, to the whole week (including weekends).
countDaysPerWeekAvailable :: Availability -> NDays Source #
The number of days per week, which can be considered available.
countInternalAvailabilityGaps :: Availability -> NDays Source #
Counts non-terminal blocks of consecutive unavailable days.
findIntersection :: Availability -> Availability -> Availability Source #
Returns the days on which both resources are available.
findIntersections :: Foldable foldable => foldable Availability -> Availability Source #
Returns the days on which all the specified resources are available.
findUnions :: Foldable foldable => foldable Availability -> Availability Source #
Returns the days on which any of the specified resources is available.
Constructor
mkAvailability :: [Day] -> Availability Source #
- Smart constructor.
- Prevents one directly constructing an unavailable resource, though one can indirectly as a result of an operation which returns a new one; e.g.
findIntersection
.
Predicates
isFulltime :: Availability -> Bool Source #
True if the resource is available every day.
isUnavailable :: Availability -> Bool Source #
True
is the resource is available on zero days.- CAVEAT: an
Availability
which is completely unavailable, can't be constructed bymkAvailability
, but it can result fromfindIntersection
.
isAvailableOn :: Day -> Availability -> Bool Source #
True if the unspecified resource is available on the specified day.