package biotk

  1. Overview
  2. Docs
Bioinformatics toolkit

Install

Dune Dependency

Authors

Maintainers

Sources

biotk-0.1.0.tbz
sha256=0dfe118d4a2698aec7eb108449a2b63a8c0ebd6dc29809608f75b8fa611dd0a1
sha512=898e0239e6626bb88e00a0080337d8a054d49097be8d2a32b181a5fcf29b925c9bacda5a02ce255a7afd80248eb76a789b80f0e9788906ccff426e5330abef0e

doc/src/biotk_pipes_unix/pipe.ml.html

Source file pipe.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
32
33
34
35
36
37
38
39
40
include Biotk_pipes.Pipe.Make(struct
    type 'a t = 'a
    let return x = x
    let bind x f = f x
  end)

open Monad_infix

let input_string len =
  let buf = Bytes.make len '\000' in
  fun ic ->
    let n = input ic buf 0 len in
    if n = 0 then None
    else Some (Bytes.sub_string buf 0 n)

let from_file ?(buffer_size = 64 * 1024) fn =
  bracket
    (fun () -> open_in fn)
    close_in
    (fun ic ->
       let rec loop () =
         match input_string buffer_size ic with
         | Some i -> yield i >>= loop
         | None -> Done ()
       in
       loop ())

let to_file fn =
  bracket
    (fun () -> open_out fn)
    close_out
    (fun oc ->
       let rec loop () =
         await () >>= function
         | None -> Done ()
         | Some v ->
           output_string oc v ;
           loop ()
       in
       loop ())
OCaml

Innovation. Community. Security.