Skip to content

Instantly share code, notes, and snippets.

@remi6397
Created March 5, 2018 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save remi6397/e5adb3694385f2fc724de73ef5d229c0 to your computer and use it in GitHub Desktop.
Save remi6397/e5adb3694385f2fc724de73ef5d229c0 to your computer and use it in GitHub Desktop.
open Containers
open Intf
type state_class +=
| Post_hello
let rec hello_world_transform ic oc state =
if List.mem ~eq:(Equal.physical) Post_hello state then
None
else
Lwt_io.write_line "hello";
Some Post_hello
let () =
transforms := hello_world_transform :: transforms
type state_class = ..
type state_data = state_class list
type transform = (Lwt_io.input_channel -> Lwt_io.output_channel -> state_data -> state_class option)
let transforms : (transform list) ref = ref []
(jbuild_version 1)
(executable
((name loader)
(libraries (containers sqlite3 lwt lwt.unix dynlink))))
(library
((name first_plugin)
(libraries (containers lwt lwt.unix))))
open Container
open Lwt
open Intf
exception No_plugins_loaded
let () =
let open Dynlink in
Sys.readdir extdir
|> Array.filter Sys.is_directory
|> Array.iter Dynlink.loadfile;
if List.length !transforms = 0 then raise No_plugins_loaded else ()
(* …cut… *)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment