package forester

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

Source file Forest_graphs.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
31
(*
 * SPDX-FileCopyrightText: 2024 The Forester Project Contributors
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 *)

open Forester_prelude

open struct
  module T = Types
  module Dl = Datalog_engine
end

module type S = sig
  val dl_db : Dl.db
  val register_uri : URI.t -> unit
end

let init (db : Dl.db) : (module S) =
(module struct
  let dl_db = db

  let register_uri uri =
    let vtx : Vertex.t = T.Uri_vertex uri in
    Dl.db_add_fact dl_db @@ Dl.mk_literal Builtin_relation.is_node [Dl.mk_const vtx];
    let@ host = Option.iter @~ URI.host uri in
    let host_vtx = T.Content_vertex (T.Content [T.Text host]) in
    Dl.db_add_fact dl_db @@ Dl.mk_literal Builtin_relation.in_host [Dl.mk_const vtx; Dl.mk_const host_vtx]
end)

module Make () : S = (val (init @@ Dl.db_create ()))
OCaml

Innovation. Community. Security.