package codept-lib

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

Source file longident_converter.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
module L = Longident

let from_lid x =
  let open Paths.Expr in
  let proj = function
    | [] -> None
    | l -> Some l in
  let rec pathlike acc = function
    | L.Lident s -> pure (s::acc)
    | L.Ldot (lid,s) -> pathlike (s::acc) lid
    | L.Lapply (f,x) ->
      app (pathlike [] f) (pathlike [] x) (proj acc) in
  pathlike [] x

let me_from_lid x =
  let open M2l in
  let rec pathlike acc l : module_expr =
    match l with
    | L.Lident s -> Ident (s::acc)
    | L.Ldot (lid,s) -> pathlike (s::acc) lid
    | L.Lapply (f,x) ->
      let app =  Apply {f=pathlike [] f; x=pathlike [] x} in
      match acc with
        | [] -> app
        | _ :: _ as proj -> Proj {me=app;proj}
  in
  pathlike [] x
OCaml

Innovation. Community. Security.