package OCanren-ppx

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

Source file ppx_distrib.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
open Base
open Ppxlib
open Printf

let name = "distrib"

let () =
  Ppxlib.Driver.register_transformation
    ~impl:(fun ss ->
        let open Ppx_distrib_expander in
        let m = object(self)
          inherit Ast_traverse.map as super
          method! structure ss = (* TODO: Maybe we don't need this *)
            List.concat @@ List.map ~f:(self#do_structure_item) ss

          method do_structure_item si =
            match si.pstr_desc with
            | Pstr_type (flg,tydecls) ->
              List.concat @@ List.map tydecls
                ~f:(fun tydecl ->
                    if suitable_tydecl tydecl
                    then str_type_decl ~loc:si.pstr_loc (flg, tydecls)
                    else [{si with
                            pstr_desc = Pstr_type (flg, List.map ~f:(super#type_declaration) tydecls)}]
                  )
            | _ -> [super#structure_item si]
        end in
      m#structure ss
    )
    name
OCaml

Innovation. Community. Security.