package bwd

  1. Overview
  2. Docs
Backward lists

Install

Dune Dependency

Authors

Maintainers

Sources

1.0.0.tar.gz
md5=e06992507455ffb10a1c379322d7fb6e
sha512=85066a9866dc90a0d138cc4d0688476a3ca96ce7454dc953fdadee51cb061201d0dc07db0b1c2ff2335f45dbfaaa9cbe53fc7724221f15d58604fd7fa1bbd22d

README.markdown.html

README.markdown

# 🔙 Backward Lists

This OCaml package defines backward lists that are isomorphic to lists. They are useful when one wishes to give a different type to the lists that are semantically in reverse. In our experience, it is easy to miss `List.rev` or misuse `List.rev_append` when both semantically forward and backward lists are present. With backward lists having a different type, it is impossible to make these mistakes.

## Philosophy

The following functions are considered ill-typed.

- `List.rev`
- `List.rev_map`
- `List.rev_map2`
- `List.rev_append`

One should never reverse a list without changing its type.

## How to Use It

```ocaml
open Bwd
open BwdNotation

let b1 = Emp #< 1 #< 2 #< 3
let b2 = BwdLabels.map ~f:(fun x -> x + 1) b1
```
OCaml

Innovation. Community. Security.