Module

BetaCalendars.GridAlgebra

Package
purescript-betacalendars-grid-algebra
Repository
mateopedersen/purescript-betacalendars-grid-algebra

Curated entry point to civil-date, week-origin, grid, paper, and blank surface APIs. Each domain module also remains available for focused use.

Project context: Beta Calendars.

Re-exports from BetaCalendars.GridAlgebra.Blank

#BlankGrid Source

type BlankGrid = { cells :: Array BlankCell, columns :: Int, rows :: Int }

A rectangular undated grid.

#BlankCell Source

type BlankCell = { column :: Int, row :: Int }

A location in an undated blank surface.

#compareBlankLayouts Source

compareBlankLayouts :: LayoutSpec -> LayoutSpec -> Either LayoutError { cellAreaDifference :: Number, first :: LayoutMetrics, second :: LayoutMetrics }

Compare the per-cell area of two valid blank layouts.

#blankWritingArea Source

blankWritingArea :: LayoutMetrics -> Number

Total modeled area available in the grid cells.

#blankLayout Source

blankLayout :: LayoutSpec -> Either LayoutError LayoutMetrics

Compute printable geometry for an undated grid.

#blankGrid Source

blankGrid :: Int -> Int -> Either LayoutError BlankGrid

Construct a 5×7, 6×7, or other positive rectangular blank grid.

#blankCellArea Source

blankCellArea :: LayoutMetrics -> Number

Area of one blank cell in square millimeters.

Re-exports from BetaCalendars.GridAlgebra.Civil

#Year Source

newtype Year

A supported positive Gregorian year.

Instances

#Month Source

data Month

Gregorian month names in calendar order.

Constructors

Instances

#DayOfMonth Source

newtype DayOfMonth

A one-based day number that can be validated against a specific month.

Instances

#CivilDate Source

newtype CivilDate

A validated Gregorian civil date.

Instances

#yearValue Source

yearValue :: Year -> Int

The numeric Gregorian year.

#year Source

year :: Int -> Maybe Year

Construct a supported Gregorian year.

#weekdayOf Source

weekdayOf :: CivilDate -> Weekday

Weekday of a civil date in the proleptic Gregorian calendar.

#previousDate Source

previousDate :: CivilDate -> Maybe CivilDate

Move one civil day backward; returns Nothing before 0001-01-01.

#nextDate Source

nextDate :: CivilDate -> Maybe CivilDate

Advance one civil day; returns Nothing after 9999-12-31.

#monthNumber Source

monthNumber :: Month -> Int

One-based month number.

#monthFromNumber Source

monthFromNumber :: Int -> Maybe Month

Convert a one-based month number into its Gregorian month.

#lastDateOfMonth Source

lastDateOfMonth :: Year -> Month -> CivilDate

The last day of a month.

#isLeapYear Source

isLeapYear :: Year -> Boolean

Gregorian leap-year rule, including century and 400-year exceptions.

#firstDateOfMonth Source

firstDateOfMonth :: Year -> Month -> CivilDate

The first day of a month.

#daysInMonth Source

daysInMonth :: Year -> Month -> Int

Number of days in a Gregorian month.

#dayOfMonthValue Source

dayOfMonthValue :: DayOfMonth -> Int

The numeric day of month.

#dateYear Source

dateYear :: CivilDate -> Year

The year component of a date.

#dateMonth Source

dateMonth :: CivilDate -> Month

The month component of a date.

#dateDay Source

dateDay :: CivilDate -> DayOfMonth

The day component of a date.

#civilDate Source

civilDate :: Year -> Month -> Int -> Maybe CivilDate

Construct a valid date, returning Nothing for an impossible day.

#allMonths Source

allMonths :: Array Month

The twelve months in calendar order.

Re-exports from BetaCalendars.GridAlgebra.Grid

#TopologySignature Source

newtype TopologySignature

Descriptive signature of a month's shape under a selected week origin. This package-specific tuple is useful for comparing shapes; it is not an external calendar standard.

Instances

#MonthTopology Source

type MonthTopology = { days :: Int, firstWeekday :: Weekday, fixedCells :: Int, lastWeekday :: Weekday, leadingCells :: Int, month :: Month, naturalRows :: Int, trailingCells :: Int, year :: Year }

Structural facts about one month under one week origin.

#MonthGrid Source

type MonthGrid = { adjacentPolicy :: AdjacentPolicy, cells :: Array GridCell, columns :: Int, mode :: GridMode, month :: Month, rows :: Int, topology :: MonthTopology, weekStart :: WeekStart, year :: Year }

A complete dated month surface.

#GridMode Source

data GridMode

Natural height or a fixed six-week calendar surface.

Constructors

Instances

#GridCell Source

type GridCell = { date :: Maybe CivilDate, index :: Int, relation :: CellRelation }

One row-major cell in a month grid.

#CellRelation Source

data CellRelation

The relationship of a cell's date to the displayed month.

Constructors

Instances

#AdjacentPolicy Source

data AdjacentPolicy

Whether dates outside the displayed month are rendered in spare cells.

Constructors

Instances

#topologySignature Source

topologySignature :: MonthTopology -> WeekStart -> TopologySignature

Create this package's descriptive topology tuple.

#monthTopology Source

monthTopology :: Year -> Month -> WeekStart -> MonthTopology

Compute month topology without allocating its cells.

#monthGrid Source

monthGrid :: Year -> Month -> WeekStart -> GridMode -> AdjacentPolicy -> MonthGrid

Build a row-major month grid for a validated year and month.

#currentMonthDays Source

currentMonthDays :: MonthGrid -> Int

The number of current-month cells in a grid.

Re-exports from BetaCalendars.GridAlgebra.Paper

#PaperSize Source

data PaperSize

Standard ISO and US paper formats, or a custom width and height.

Constructors

Instances

#Orientation Source

data Orientation

Page orientation.

Constructors

Instances

#Millimeters Source

newtype Millimeters

A non-negative, finite millimeter measurement.

Instances

#Margins Source

type Margins = { bottom :: Millimeters, left :: Millimeters, right :: Millimeters, top :: Millimeters }

Four non-negative page margins.

#LayoutSpec Source

type LayoutSpec = { columns :: Int, margins :: Margins, notesHeight :: Millimeters, orientation :: Orientation, paper :: PaperSize, rows :: Int, titleHeight :: Millimeters, weekdayHeaderHeight :: Millimeters }

Input parameters for a printable grid model.

#LayoutMetrics Source

type LayoutMetrics = { cellArea :: Number, cellHeight :: Millimeters, cellWidth :: Millimeters, gridHeight :: Millimeters, gridWidth :: Millimeters, pageHeight :: Millimeters, pageWidth :: Millimeters, printableHeight :: Millimeters, printableWidth :: Millimeters, writingArea :: Number }

Derived page and cell geometry.

#LayoutError Source

data LayoutError

Failures that prevent a physically meaningful grid calculation.

Constructors

Instances

#paperDimensions Source

paperDimensions :: PaperSize -> Orientation -> { height :: Number, width :: Number }

Dimensions in the requested orientation. Letter and Legal are the US nominal dimensions in millimeters.

#millimeters Source

millimeters :: Number -> Maybe Millimeters

Construct a non-negative finite millimeter value.

#millimeterValue Source

millimeterValue :: Millimeters -> Number

Read the numeric millimeter measurement.

#layoutMetrics Source

layoutMetrics :: LayoutSpec -> Either LayoutError LayoutMetrics

Calculate layout geometry after validating all reserved areas and shape.

#defaultMargins Source

defaultMargins :: Margins

Common model margins used in examples: 10 mm on each side.

Re-exports from BetaCalendars.GridAlgebra.WeekStart

#Weekday Source

data Weekday

A Gregorian weekday, indexed from Monday.

Constructors

Instances

#WeekStart Source

data WeekStart

The weekday shown in the first column of a calendar grid.

Constructors

Instances

#weekdayIndex Source

weekdayIndex :: Weekday -> Int

Monday is 0, Tuesday is 1, and Sunday is 6.

#weekStartWeekday Source

weekStartWeekday :: WeekStart -> Weekday

The weekday corresponding to a week-start setting.

#rotateWeekOrigin Source

rotateWeekOrigin :: WeekStart -> Int -> Weekday

Rotate a week origin by an arbitrary number of days, wrapping every seven.

#relativeWeekdayIndex Source

relativeWeekdayIndex :: WeekStart -> Weekday -> Int

The zero-based column of a weekday under the supplied week origin.

#offsetFromWeekStart Source

offsetFromWeekStart :: WeekStart -> Weekday -> Int

Number of leading grid cells before the first day of a month.

#allWeekdays Source

allWeekdays :: Array Weekday

Every weekday in Monday-first index order.

#allWeekStarts Source

allWeekStarts :: Array WeekStart

Every supported week origin in weekday order.