Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file dsl.ml
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465(*
* Copyright (c) 2019-2020 Craig Ferguson <me@craigfe.io>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)openPpxlib(** This module defines the expected combinators exposed by Repr, and their
correspondences to the types in the standard library. *)letrecdrop_stdlib_prefix=function|(Lident_|Lapply_)asl->l|Ldot(Lident"Stdlib",suffix)->Lidentsuffix|Ldot(l,suffix)->Ldot(drop_stdlib_prefixl,suffix)letbasic=["unit";"bool";"char";"int";"int32";"int63";"int64";"float";"string";"bytes";"list";"array";"option";"result";]letcontainers=["either";"hashtbl";"queue";"seq";"stack"]lettype_in_default_scopename=(Lidentname,name)lettype_in_separate_modulename=(Ldot(Lident(String.capitalize_asciiname),"t"),name)lettype_to_combinator_name:longident->stringoption=letcorrespondences=letassoc=(* Abstract types with equivalent combinator names: *)List.maptype_in_default_scopebasic(* Types named [t] within their own modules: *)@List.maptype_in_separate_module(basic@containers)(* Technically [lazy_t] is not for direct use, but derive anyway: *)@[(Lident"lazy_t","lazy_t");(Ldot(Lident"Lazy","t"),"lazy_t")](* [Int63.t] may be namespaced under [Optint.Int63.t]: *)@[(Ldot(Ldot(Lident"Optint","Int63"),"t"),"int63")]inList.to_seqassoc|>Hashtbl.of_seqinfunlident->Hashtbl.find_optcorrespondences(drop_stdlib_prefixlident)