package orsetto

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Support logic for arbitrary Radix-N transcodings.

Overview

This module provides the basis interface for Radix-16, -32 and -64 encodings using arbitrary alphabets.

Note well: the implementation comprises a record type and a function that returns a first-class module, rather than a functor, for internal reasons related to Radix-32 transformations requiring a working accumulator that is either int or int64 depending on the value of Sys.int_size.

Basis Types
type check =
  1. | Digit
  2. | Skip
  3. | Pad
  4. | Invalid

Values of this type are returned by check functions.

type req =
  1. | Must
  2. | Should

Values of this type signal whether pad characters are required or merely recommended.

type basis =
  1. | Basis of {
    1. pad : (req * char) option;
      (*

      Pad characters.

      *)
    2. check : char -> check;
      (*

      Check the kind of character.

      *)
    3. decode : char -> int;
      (*

      Return the digit for a character.

      *)
    4. encode : int -> char;
      (*

      Return the character for a digit.

      *)
    5. radix : int;
      (*

      The radix of the transform.

      *)
    }

Values of this type describe the form of the Radix-N transform.

Composition
type exn += private
  1. | Error

The exception signaling a encoding error.

module type Profile = sig ... end

Modules of this type implement the various transcoding methods.

val create : basis -> (module Profile)

Use create b to make a module that implements the encoding.

OCaml

Innovation. Community. Security.