package ppx_deriving_hardcaml

  1. Overview
  2. Docs
PPX deriving plugin for HardCaml

Install

Dune Dependency

Authors

Maintainers

Sources

v1.0.0.tar.gz
sha256=eba5532a2d141da42c4d846db610346a60740ad25becd76f9051c641a0680496
md5=9577548c3598f16812ac7011ecd44863

README.md.html

ppx_deriving Plugin for HardCaml

This module implements a plugin for the ppx_deriving rewriter that supports the HardCaml syntax:

  • Provide a record annotation to generate helper functions

  • Provide an optional bits attribute for signals

  • Provide a required width attribute for list and array

Examples

Module interface

Original syntax:

module S : interface
  signal
  signal_list{ }
  signal_array{| |}
end

New syntax:

module S : sig
  type 'a t = {
    signal       : 'a;
    signal_list  : 'a list;
    signal_array : 'a array;
  } [@@deriving hardcaml]
end

Module implementation

Original syntax:

module S = interface
  signal[2]
  signal_list{2}[4]
  signal_array{|2|}[4]
end

New syntax:

module S = struct
  type 'a t = {
    signal       : 'a       [@bits 2];
    signal_list  : 'a list  [@length 2][@bits 4];
    signal_array : 'a array [@length 2][@bits 4];
  } [@@deriving hardcaml]
end
OCaml

Innovation. Community. Security.