package reason

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

Module Reason_omp.VersionsSource

Abstracting an OCaml frontend

Sourcemodule type Ast = sig ... end

Abstract view of a version of an OCaml Ast

Sourcetype 'a _types = 'a constraint 'a = < out_value : _ ; out_type : _ ; out_class_type : _ ; out_module_type : _ ; out_sig_item : _ ; out_type_extension : _ ; out_phrase : _ >
Sourcetype 'a get_out_value = 'x constraint 'a _types = < out_value : 'x.. >
Sourcetype 'a get_out_type = 'x constraint 'a _types = < out_type : 'x.. >
Sourcetype 'a get_out_class_type = 'x constraint 'a _types = < out_class_type : 'x.. >
Sourcetype 'a get_out_module_type = 'x constraint 'a _types = < out_module_type : 'x.. >
Sourcetype 'a get_out_sig_item = 'x constraint 'a _types = < out_sig_item : 'x.. >
Sourcetype 'a get_out_type_extension = 'x constraint 'a _types = < out_type_extension : 'x.. >
Sourcetype 'a get_out_phrase = 'x constraint 'a _types = < out_phrase : 'x.. >
Sourcetype _ witnesses = private ..

A version of the OCaml frontend packs the ast with type witnesses so that equalities can be recovered dynamically.

Sourcetype _ migration_info

migration_info is an opaque type that is used to generate migration functions.

Sourcemodule type OCaml_version = sig ... end

An OCaml frontend versions an Ast, version number and some witnesses for conversion.

Representing an ocaml version in type language

Concrete frontend instances

Sourcemodule OCaml_402 : OCaml_version with module Ast = Ast_402
Sourcemodule OCaml_403 : OCaml_version with module Ast = Ast_403
Sourcemodule OCaml_404 : OCaml_version with module Ast = Ast_404
Sourcemodule OCaml_405 : OCaml_version with module Ast = Ast_405
Sourcemodule OCaml_406 : OCaml_version with module Ast = Ast_406
Sourcemodule OCaml_407 : OCaml_version with module Ast = Ast_407
Sourcemodule OCaml_408 : OCaml_version with module Ast = Ast_408
Sourcemodule OCaml_409 : OCaml_version with module Ast = Ast_409
Sourcemodule OCaml_410 : OCaml_version with module Ast = Ast_410
Sourcemodule OCaml_411 : OCaml_version with module Ast = Ast_411
Sourcemodule OCaml_412 : OCaml_version with module Ast = Ast_412
Sourcemodule OCaml_413 : OCaml_version with module Ast = Ast_413
Sourcemodule OCaml_414 : OCaml_version with module Ast = Ast_414
Sourcemodule OCaml_500 : OCaml_version with module Ast = Ast_500
Sourcemodule OCaml_51 : OCaml_version with module Ast = Ast_51
Sourcemodule OCaml_52 : OCaml_version with module Ast = Ast_52
Sourcemodule OCaml_53 : OCaml_version with module Ast = Reason_omp__.Ast_53
Sourcemodule OCaml_current = OCaml_53
Sourceval all_versions : (module OCaml_version) list

Migrating between different versions

Sourcetype ('a, 'b) type_comparison =
  1. | Lt : ('a, 'b) type_comparison
  2. | Eq : ('a, 'a) type_comparison
  3. | Gt : ('a, 'b) type_comparison
Sourceval compare_ocaml_version : 'a ocaml_version -> 'b ocaml_version -> ('a, 'b) type_comparison
Sourcetype ('from, 'to_) migration_functions = {
  1. copy_out_value : 'from get_out_value -> 'to_ get_out_value;
  2. copy_out_type : 'from get_out_type -> 'to_ get_out_type;
  3. copy_out_class_type : 'from get_out_class_type -> 'to_ get_out_class_type;
  4. copy_out_module_type : 'from get_out_module_type -> 'to_ get_out_module_type;
  5. copy_out_sig_item : 'from get_out_sig_item -> 'to_ get_out_sig_item;
  6. copy_out_type_extension : 'from get_out_type_extension -> 'to_ get_out_type_extension;
  7. copy_out_phrase : 'from get_out_phrase -> 'to_ get_out_phrase;
}

A record for migrating each AST construct between two known versions

Sourceval migration_identity : ('a, 'a) migration_functions

Migrating to the same version is no-op

Sourceval migration_compose : ('a, 'b) migration_functions -> ('b, 'c) migration_functions -> ('a, 'c) migration_functions

Migrations can be composed

Represent the next or previous version of an Ast

Sourcetype 'from immediate_migration =
  1. | No_migration : 'from immediate_migration
    (*

    Cannot migrate earliest or latest supported version

    *)
  2. | Immediate_migration : ('from, 'to_) migration_functions * 'to_ ocaml_version -> 'from immediate_migration
    (*

    Pack the migration functions and the new version

    *)
Sourceval immediate_migration : 'types ocaml_version -> [< `Next | `Previous ] -> 'types immediate_migration
Sourceval migrate : 'from ocaml_version -> 'to_ ocaml_version -> ('from, 'to_) migration_functions

Convenience definitions

Sourcemodule Convert (A : OCaml_version) (B : OCaml_version) : sig ... end

Module level migration

OCaml

Innovation. Community. Security.