recollections: Fixed-size representable (Zippy Applicative) collections.

[ bsd3, data-structures, library ] [ Propose Tags ] [ Report a vulnerability ]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0
Change log CHANGELOG.md
Dependencies base (>=4.18 && <5), template-haskell (>=2.20) [details]
License BSD-3-Clause
Copyright 2026 IC Rainbow
Author IC Rainbow
Maintainer aenor.realm@gmail.com
Uploaded by AlexanderBondarenko at 2026-07-25T23:29:42Z
Category Data Structures
Source repo head: git clone https://gitlab.com/dpwiz/recollections
Distributions
Downloads 4 total (4 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-07-26 [all 1 reports]

Readme for recollections-0.1.0.0

[back to package description]

recollections

The splicing module needs these extensions and imports:

{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE DerivingVia #-}

import GHC.Generics (Generically1(..))

Given an enumeration of things like

data Things
  = This
  | That
  | Something
  | Else
  | Entirely
  deriving (Eq, Ord, Show, Enum, Bounded, Generic)

We can derive a record that will behave like a homogenous zip-list of static size:

mkCollection ''Things

-- data Collection a = Collection
--   { this, that, something, else', entirely :: a
--   }
--   deriving stock (Eq, Show, Generic1, Functor, Foldable, Traversable)
--   deriving Applicative via (Generically1 Collection)

-- Fill the record with its indices
mkIndices ''Things

Kmettoverse-lite

-- Distributive
mkDistribute ''Things
-- collect is 

-- Representable
mkIndex ''Things
mkTabulate ''Things

VS

  • Vanilla monomorphic records: don't have functor/foldable/traversable/applicative goodies.
  • Hand-rolling the functor: be my guest, hand-roll the field enum too, while you're at it.
  • Map Things a: All fields are mandatory, all keys are known -> lookups are total and O(1). The optional fields are recoverable, with Collection (Maybe a).
  • Things -> a: The collection can be stored and loaded.

Gotchas

All the constructors of the tag type must be nullary — anything else is a compile-time error, since a partial Collection would make index partial too.

The generated names (Collection, indices, distribute, index, tabulate) are fixed, so a tag named e.g. Index will clash with them.