alignment: Principled functor alignment with leftovers
A principled approach to zipping functors that preserves both matched pairs and leftovers.
The alignment library provides type classes and operations for aligning
two functors into a structure (This) that captures:
Matched pairs where both functors have elements at the same position
Leftovers when one functor is longer than the other
This is more principled than traditional zip which silently discards
extra elements. The library uses functional dependencies (f -> g) to
relate the "paired" functor to the "leftover" functor, ensuring type safety.
Key features:
Semialign,Align, andUnaligntype classes with comprehensive lawsUnalignprovides inverse operation to recover original functorsFull lens/optics integration
Instances for common functors:
[],Maybe,NonEmpty,Vector,Map,Seq, and moreTestable law-checking functions for property-based testing
Complete documentation with 211 doctests
Example:
import Data.Alignment -- Align two lists of different lengths align [1,2,3] [10,20] :: This [] NonEmpty Int Int -- Result: This [(1,10),(2,20)] (Just (Left (3 :| [])))

Flags
Manual Flags
| Name | Description | Default |
|---|---|---|
| dev | Enable -Werror for development | Disabled |
Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info
Downloads
- alignment-0.2.0.0.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
- No Candidates
| Versions [RSS] | 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.0.3, 0.1.0.4, 0.1.0.5, 0.1.0.6, 0.2.0.0, 0.2.0.1 |
|---|---|
| Change log | changelog.md |
| Dependencies | assoc (>=1 && <2), base (>=4.18 && <6), bifunctors (>=5 && <6), containers (>=0.6 && <0.8), deepseq (>=1.4 && <1.6), lens (>=4 && <6), semigroupoids (>=6 && <7), vector (>=0.12 && <0.14) [details] |
| Tested with | ghc ==9.6.7 |
| License | BSD-3-Clause |
| Copyright | Copyright (C) 2022-2026 Tony Morris |
| Author | Tony Morris <oᴉ˙ldɟb@llǝʞsɐɥ> |
| Maintainer | Tony Morris <oᴉ˙ldɟb@llǝʞsɐɥ> |
| Uploaded | by TonyMorris at 2026-05-19T09:29:33Z |
| Category | Data |
| Home page | https://gitlab.com/system-f/code/alignment |
| Bug tracker | https://gitlab.com/system-f/code/alignment/issues |
| Source repo | head: git clone git@gitlab.com:system-f/code/alignment.git |
| Distributions | |
| Downloads | 521 total (32 in the last 30 days) |
| Rating | (no votes yet) [estimated by Bayesian average] |
| Your Rating | |
| Status | Docs available [build log] Last success reported on 2026-05-19 [all 1 reports] |