moonlight-category: Categorical layer for Pale Meridian.

[ library, math ] [ Propose Tags ] [ Report a vulnerability ]

A totalised, explicit-error category abstraction: limits and colimits, a higher-category class tower, runtime-validated finite categories (FinCat), site and path presentations, adhesive and PBPO rewriting witnesses, structured cospans and double categories, an indexed typed-arrow layer, and a simplicial sublibrary for Δ, finite simplicial sets, nerves, and Kan interfaces. . For general indexed category theory, prefer Sjoerd Visscher's data-category package: its typed-arrow calculus is the primary inspiration for this package's indexed modules, and several modules under Moonlight.Category.Indexed are adapted from it. Thank you to Sjoerd Visscher for the design and implementation work in data-category. See THIRD_PARTY_NOTICES.md.


[Skip to Readme]

library moonlight-category

Modules

[Last Documentation]

  • Moonlight
    • Moonlight.Category
      • Moonlight.Category.Indexed
      • Moonlight.Category.Notation
      • Moonlight.Category.Presentation

library moonlight-category:laws

Modules

[Last Documentation]

  • Moonlight
    • Category
      • Effect
        • Fixture
          • Moonlight.Category.Effect.Fixture.FinCat
        • Moonlight.Category.Effect.Harness
          • Moonlight.Category.Effect.Harness.Adhesive
          • Moonlight.Category.Effect.Harness.Algebra
          • Moonlight.Category.Effect.Harness.Category
          • Moonlight.Category.Effect.Harness.Core
          • Moonlight.Category.Effect.Harness.Higher
          • Moonlight.Category.Effect.Harness.Limits
          • Moonlight.Category.Effect.Harness.Site
        • Moonlight.Category.Effect.LawNames
        • Moonlight.Category.Effect.Laws
        • Moonlight.Category.Effect.PathQuotientHarness
        • Moonlight.Category.Effect.SiteGen

library moonlight-category:simplicial

Modules

[Last Documentation]

  • Moonlight
    • Category
      • Pure
        • Simplicial
          • Moonlight.Category.Pure.Simplicial.CategoricalSimplex
          • Moonlight.Category.Pure.Simplicial.Delta
          • Moonlight.Category.Pure.Simplicial.Homotopy
          • Moonlight.Category.Pure.Simplicial.Kan
          • Moonlight.Category.Pure.Simplicial.Nerve
          • Moonlight.Category.Pure.Simplicial.Ordinal
          • Moonlight.Category.Pure.Simplicial.Presheaf
          • Moonlight.Category.Pure.Simplicial.Set
          • Moonlight.Category.Pure.Simplicial.Spaces
          • Moonlight.Category.Pure.Simplicial.TypeLevel
          • Moonlight.Category.Pure.Simplicial.Validation
      • Moonlight.Category.Simplicial

library moonlight-category:indexed

Modules

[Last Documentation]

  • Moonlight
    • Category
      • Pure
        • Indexed
          • Moonlight.Category.Pure.Indexed.Adjunction
          • Moonlight.Category.Pure.Indexed.Category
          • Moonlight.Category.Pure.Indexed.Coproduct
          • Moonlight.Category.Pure.Indexed.Functor
          • Moonlight.Category.Pure.Indexed.KanExtension
          • Moonlight.Category.Pure.Indexed.Limit
          • Moonlight.Category.Pure.Indexed.NaturalTransformation
          • Moonlight.Category.Pure.Indexed.Product
          • Moonlight.Category.Pure.Indexed.Simplex
          • Moonlight.Category.Pure.Indexed.Unit
          • Moonlight.Category.Pure.Indexed.Void

library moonlight-category:site

Modules

[Last Documentation]

  • Moonlight
    • Category
      • Pure
        • Moonlight.Category.Pure.Site
          • Moonlight.Category.Pure.Site.Category
          • Moonlight.Category.Pure.Site.Compile
          • Moonlight.Category.Pure.Site.Core
          • Moonlight.Category.Pure.Site.Graph
          • Moonlight.Category.Pure.Site.Manifest
          • Moonlight.Category.Pure.Site.Quotient

library moonlight-category:finite

Modules

[Last Documentation]

  • Moonlight
    • Category
      • Pure
        • Moonlight.Category.Pure.FinCat
          • Moonlight.Category.Pure.FinCat.Functor
          • Moonlight.Category.Pure.FinCat.Opposite
        • Moonlight.Category.Pure.FinPresentation
        • Finite
          • Moonlight.Category.Pure.Finite.DenseReachability
        • Moonlight.Category.Pure.Invertibility

library moonlight-category:abstract

Modules

[Last Documentation]

  • Moonlight
    • Category
      • Pure
        • Moonlight.Category.Pure.Adhesive
        • Moonlight.Category.Pure.Category
        • Moonlight.Category.Pure.CoveringFamily
        • Moonlight.Category.Pure.CoveringProduct
        • Moonlight.Category.Pure.DecoratedComposition
        • Moonlight.Category.Pure.DecoratedPresentation
        • Moonlight.Category.Pure.DoubleCategory
        • Moonlight.Category.Pure.FiniteComposable
        • Moonlight.Category.Pure.Galois
        • Moonlight.Category.Pure.Higher
        • Moonlight.Category.Pure.Limits
        • Moonlight.Category.Pure.PolynomialFunctor
        • Moonlight.Category.Pure.Poset
        • Moonlight.Category.Pure.StructuredCospan
        • Moonlight.Category.Pure.Thin
        • Moonlight.Category.Pure.Unit

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.1, 1.0.0.0, 1.1.0.0, 1.1.0.1
Change log CHANGELOG.md
Dependencies algebraic-graphs (>=0.8 && <0.9), base (>=4.20 && <5), bytestring (>=0.11 && <0.13), containers (>=0.6 && <0.9), hedgehog (>=1.2 && <1.8), moonlight-category, moonlight-core (>=0.1.0.3 && <0.2), moonlight-pale (>=0.1.0.1 && <0.2), tasty (>=1.4 && <1.6), tasty-quickcheck (>=0.10 && <0.12), vector (>=0.13 && <0.14) [details]
Tested with ghc ==9.10.3, ghc ==9.12.4, ghc ==9.14.1
License MIT AND BSD-3-Clause[multiple license files]
Copyright (c) 2026 Blue Rose
Author Blue Rose
Maintainer rosaliafialkova@gmail.com
Uploaded by bluerose at 2026-08-21T04:22:33Z
Category Math
Home page https://github.com/PaleRoses/moonlight
Bug tracker https://github.com/PaleRoses/moonlight/issues
Source repo head: git clone https://github.com/PaleRoses/moonlight.git(moonlight-category)
this: git clone https://github.com/PaleRoses/moonlight.git(tag moonlight-category-0.1.0.1)(moonlight-category)
Distributions
Downloads 31 total (13 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2026-08-21 [all 2 reports]

Readme for moonlight-category-0.1.0.1

[back to package description]

moonlight-category

Part of Moonlight, the sheaf-theoretic computation layer beneath Melusine and Pale Meridian.

moonlight-category is Moonlight's categorical tier. Building on moonlight-core, it provides a totalised, explicit-error category abstraction together with the finite, runtime-validated categories and site/path presentations the compiler uses to model its own structure.

Relationship to data-category

If you want general indexed category theory in Haskell, prefer Sjoerd Visscher's data-category. Its typed-arrow calculus is the primary inspiration for this package's indexed layer, and several modules under Moonlight.Category.Indexed are adapted from it. Thank you to Sjoerd Visscher for the design and implementation work in data-category.

Full attribution and the upstream BSD-3-Clause license are recorded in THIRD_PARTY_NOTICES.md.

What it provides

  • A category abstraction. The Category class is totalised: objects, morphisms, 2-morphisms, compositors and a category-specific error type are associated types, and every operation returns Either.
  • Limits and colimits. A class tower for products, coproducts, pullbacks, pushouts, equalizers and coequalizers.
  • Higher structure. 2-categories, bicategories, monoidal and enriched categories.
  • Finite categories. FinCat: runtime-validated finite categories with handles, bit-packed thin variants, composable chains and core/automorphism groupoid extraction.
  • Finite-category presentations. Moonlight.Category.Presentation provides a focused authoring EDSL for finite posets and fully enumerated finite categories, compiling down to validated FinCat.
  • Sites and presentations. Site manifests with validation, reachable-closure and import-cycle diagnostics, path categories, quotients, and compilation down to FinCat.
  • Rewriting witnesses. Adhesive and PBPO pushout-complement witnesses, structured cospans, double categories, and decorated composition/presentation.
  • Indexed category theory. The typed-arrow layer adapted from data-category.
  • Simplicial substrate. Runtime-dimensional Δ morphisms, finite truncated simplicial sets, standard/boundary/horn spaces, nerves, Kan interfaces, and connected-component/core-groupoid queries over finite composable categories.

Public modules

Module Surface
Moonlight.Category The broad categorical surface: Category and composition, the limit/colimit and higher-category towers, finite and thin categories, invertibility/groupoids, adhesive & PBPO witnesses, structured cospans, double categories, decorated composition, Galois connections, polynomial functors, covering families, and the site/path layer.
Moonlight.Category.Indexed The indexed, typed-arrow category-theory layer adapted from data-category: indexed categories, functors, natural transformations, adjunctions, (co)limits, Kan extensions, products/coproducts and the simplex category.
Moonlight.Category.Presentation The finite-category authoring surface: named objects, named nonidentity morphisms, strict-order below declarations, identities in equations, and compilation to FinCat.
Moonlight.Category.Notation Scoped query and composition helpers for already-compiled FinCat values.
Moonlight.Category.Simplicial The public simplicial surface: Δ, simplicial sets, nerves, Kan interfaces, homotopy queries, and pure validation.

The Moonlight.Category.Pure.* leaves live in named implementation sublibraries: abstract for generic category theory, finite for FinCat/presentation runtime, site for site and path compilation, indexed for the adapted data-category typed-arrow layer, and simplicial for Δ, simplicial sets, nerves and Kan interfaces. Effectful law harnesses and cross-package test fixtures live in the laws sublibrary rather than the pure production components.

Dependency footprint

Hackage's package-level dependency summary aggregates dependencies from every component in the distribution. Depending on the main moonlight-category library does not select moonlight-category:laws and therefore does not add Tasty, Hedgehog, or moonlight-pale:test-laws. Consumers opt into that reusable law harness explicitly with a dependency on moonlight-category:laws.

Finite-category presentations

Use Moonlight.Category.Presentation to write finite categories declaratively. Compilation always produces the validated runtime representation FinCat.

Finite posets

below declares strict generating inequalities. Compilation takes the transitive closure, rejects cycles, and supplies identities implicitly.

import Moonlight.Category.Presentation

threeChain :: Either FinCatBuildError FinCat
threeChain =
  finCategory $ do
    [a, b, c] <- objects ["A", "B", "C"]
    below a b
    below b c

Fully enumerated finite categories

In the general dialect, each call to arrow declares one actual nonidentity morphism of the resulting category. Equations determine the nonidentity composition table.

import Moonlight.Category.Presentation

commutingTriangle :: Either FinCatBuildError FinCat
commutingTriangle =
  finCategory $ do
    a <- object "A"
    b <- object "B"
    c <- object "C"

    f <- arrow a b "f"
    g <- arrow b c "g"
    h <- arrow a c "h"

    equate (g `after` f) h

Identities may be named inside equations:

inversePair :: Either FinCatBuildError FinCat
inversePair =
  finCategory $ do
    a <- object "A"
    b <- object "B"

    f <- arrow a b "f"
    g <- arrow b a "g"

    equate (g `after` f) (identityAt a)
    equate (f `after` g) (identityAt b)

Longer paths are accepted when their proper intermediate composites are determined elsewhere in the presentation. Equation declaration order is irrelevant.

The presentation dialect accepts declared morphisms and equations over determined composites. An equation such as equate f g for distinct declared morphisms is rejected rather than silently identifying them.

For querying and composing morphisms after compilation, import Moonlight.Category.Notation separately.

Acknowledgements

The representation of finite and finitely-presented categories as concrete, runtime-validated data structures, including FinCat and the site/path presentations that compile down to it, was directly inspired by the AlgebraicJulia ecosystem and the work on attributed C-sets (acsets), whose thesis is precisely that categorical objects can be realised as performant data structures. The implementation here is independent; the conceptual debt is real and gratefully acknowledged.

Evan Patterson, Owen Lynch, and James Fairbanks. "Categorical Data Structures for Technical Computing." arXiv:2106.04703. https://arxiv.org/abs/2106.04703

Thank you to Evan Patterson, Owen Lynch, James Fairbanks, and the AlgebraicJulia community.

License

Moonlight's original code is licensed under MIT; see LICENSE. The indexed modules adapted from data-category remain BSD-3-Clause; their copyright notice, license terms, and attribution are recorded in THIRD_PARTY_NOTICES.md.