REFMT(1)

NAME

refmt - Reason's Parser & Pretty-printer

SYNOPSIS

refmt [OPTION]… [FILENAMES]…

DESCRIPTION

refmt lets you format Reason files, parse them, and convert them between OCaml syntax and Reason syntax.

ARGUMENTS

FILENAMES
    input files; if empty, assume stdin

OPTIONS

-e, --assume-explicit-arity
    if a constructor's argument is a tuple, always interpret it as multiple arguments

-h PATH, --heuristics-file=PATH
    load path as a heuristics file to specify which constructors carry a tuple rather than multiple arguments. Mostly used in removing [@implicit_arity] introduced from OCaml conversion. example.txt: Constructor1 Constructor2

-i BOOL, --interface=BOOL (absent=false)
    parse AST as an interface

--in-place
    reformat a file in-place

-p FORM, --print=FORM (absent=re)
    print AST in FORM, which is one of: (ml | re (default) | binary (for compiler input) | binary_reason (for interchange between Reason versions) | ast (print human readable AST directly) | none)

--parse=FORM
    parse AST in FORM, which is one of: (ml | re | binary (for compiler input) | binary_reason (for interchange between Reason versions))

-r, --recoverable
    enable recoverable parser

-w COLS, --print-width=COLS (absent=80 or REFMT_PRINT_WIDTH env)
    wrapping width for printing the AST

COMMON OPTIONS

--help[=FMT] (default=auto)
    Show this help in format FMT. The value FMT must be one of auto, pager, groff or plain. With auto, the format is pager or plain whenever the TERM env var is dumb or undefined.

--version
    Show version information.

EXIT STATUS

refmt exits with:

0   on success.

123 on indiscriminate errors reported on standard error.

124 on command line parsing errors.

125 on unexpected internal errors (bugs).

ENVIRONMENT

These environment variables affect the execution of refmt:

REFMT_PRINT_WIDTH
    wrapping width for printing the AST

EXAMPLES

1.  Initialise a new project named `foo':

      dune init project foo

2.  Format a Reason implementation file:

      refmt file.re

3.  Format a Reason interface file:

      refmt file.rei

4.  Format interface code from the command line:

      echo 'let x: int' | refmt --interface=true

5.  Convert an OCaml file to Reason:

      refmt file.ml

6.  Convert a Reason file to OCaml:

      refmt file.re --print ml

7.  Convert OCaml from the command line to Reason:

      echo 'let x = 1' | refmt --parse ml