package server-reason-react

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

Module Melange_native_ppx.Js_propertiesSource

[@\@deriving jsProperties] generates a constructor function for record types.

This is a native OCaml implementation compatible with melange's jsProperties deriver.

Basic usage

  type person = { name : string; age : int } [@@deriving jsProperties]

  (* Generates: *)
  let person ~name ~age = { name; age }

Optional fields

Fields marked with [@mel.optional] become optional labeled arguments. When any optional field exists, a trailing unit argument is added:

  type config = { host : string; port : int option [@mel.optional] } [@@deriving jsProperties]

  (* Generates: *)
  let config ~host ?port () = { host; port }

Private types

Private types do not generate a constructor (the type cannot be constructed outside the module).

module Builder = Ppxlib.Ast_builder.Default
Sourceval derive_str : Ppxlib.type_declaration list -> Ppxlib__.Import.structure_item list
Sourceval derive_sig : Ppxlib.type_declaration list -> Ppxlib__.Import.signature_item list
Sourceval str_type_decl : (Ppxlib__.Import.structure_item list, Ppxlib__.Import.rec_flag * Ppxlib.type_declaration list) Ppxlib__Deriving.Generator.t
Sourceval sig_type_decl : (Ppxlib__.Import.signature_item list, Ppxlib__.Import.rec_flag * Ppxlib.type_declaration list) Ppxlib__Deriving.Generator.t
Sourceval deriver : Ppxlib.Deriving.t