ann: Informative annotations which don't change equality

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

This package introduces a type Ann a to annotate data types with information which doesn't influence the behaviour of your program. These annotations can then be displayed, as assistance to the user.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 1.0.0
Change log ChangeLog.md
Dependencies base (>=4.7 && <5) [details]
License BSD-3-Clause
Copyright 2022 Arnaud Spiwack
Author Arnaud Spiwack
Maintainer arnaud@spiwack.net
Category Data
Home page https://github.com/aspiwack/haskell-ann#readme
Bug tracker https://github.com/aspiwack/haskell-ann/issues
Source repo head: git clone https://github.com/aspiwack/haskell-ann
Uploaded by aspiwack at 2022-06-28T15:30:38Z
Distributions NixOS:1.0.0
Downloads 102 total (1 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2022-06-28 [all 1 reports]

Readme for ann-1.0.0

[back to package description]

Ann

This package introduces a type Ann a to annotate data types with information which doesn't influence the behaviour of your program. These annotations can then be displayed, as assistance to the user.

Examples

Variable names

You are writing a programing language, and representing binder as [de Bruijn indices](https://en.wikipedia.org/wiki/ De_Bruijn_index). Nevertheless you want to keep the variable names written by the user, to be able to interact with them on these terms (e.g. in error messages). With 'Ann' it would look like this:

data Term
  = Var Int
  | App Term Term
  | Lam (Ann String) Term
  deriving (Eq)

Thanks to the 'Ann' type, you can derive the intended equality: the user's choice of variable doesn't change the term (this is called α-equivalence).

Validation monad

The Validation applicative can be made into a monad. Specifically Validation (Ann e) is a monad, as I explained in a Twitter thread.