package biocaml

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

Source file future.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152


module type S = sig

  type how = [ `Parallel | `Sequential | `Max_concurrent_jobs of int ]
  (** [`Max_concurrent_jobs] supported only for Async
  implementation. The Lwt implementation treats this the same as
  [`Parallel]. Blocking implementation treats all as [`Sequential]. *)

  module Deferred : sig
    include Monad.S

    val unit : unit t

    module Result : Monad.S2
      with type ('a, 'b) t = ('a, 'b) Result.t t

    module List : sig
      val fold : 'a list -> init:'b -> f:('b -> 'a -> 'b t) -> 'b t
      val iter : ?how:how -> 'a list -> f:('a -> unit t) -> unit t
      val map : ?how:how -> 'a list -> f:('a -> 'b t) -> 'b list t
      val filter : ?how:how -> 'a list -> f:('a -> bool t) -> 'a list t
    end

    module Or_error : sig
      module List : sig

        val map
          :  ?how:how
          -> 'a list
          -> f:('a -> 'b Or_error.t t)
          -> 'b list Or_error.t t

        val iter
          :  ?how:how
          -> 'a list
          -> f:('a -> unit Or_error.t t)
          -> unit Or_error.t t

      end
    end

  end

  val return : 'a -> 'a Deferred.t
  val (>>=) : 'a Deferred.t -> ('a -> 'b Deferred.t) -> 'b Deferred.t
  val (>>|) : 'a Deferred.t -> ('a -> 'b) -> 'b Deferred.t

  val (>>=?) :
    ('a, 'b) Deferred.Result.t ->
    ('a -> ('c, 'b) Deferred.Result.t) ->
    ('c, 'b) Deferred.Result.t

  val (>>|?) :
    ('a, 'b) Deferred.Result.t ->
    ('a -> 'c) ->
    ('c, 'b) Deferred.Result.t

  (** Difference from Async: Use [fail] instead of [raise]. *)
  val fail : exn -> 'a Deferred.t
  val raise : [> `Use_fail_instead ]

  (** Async supports several extra parameters to this function, which
      we do not currently support. *)
  val try_with : (unit -> 'a Deferred.t) -> ('a, exn) Result.t Deferred.t


  module In_thread : sig
    val run : (unit -> 'a) -> 'a Deferred.t
  end

  module Pipe : sig
    module Reader : sig
      type 'a t
    end

    val read : 'a Reader.t -> [ `Eof | `Ok of 'a ] Deferred.t

    (** Discard one item from the pipe. Do nothing if pipe is already
        fully consumed. Difference from Async: This function is not
        defined. *)
    val junk : 'a Reader.t -> unit Deferred.t

    (** Like [read] but doesn't consume the item. Difference from
        Async: This function is not defined. We don't call this
        function [peek] because that is already another function in
        Async, which has different semantics. *)
    val peek_deferred : 'a Reader.t -> [ `Eof | `Ok of 'a ] Deferred.t

    val map : 'a Reader.t -> f:('a -> 'b) -> 'b Reader.t

    val fold :
      'a Reader.t ->
      init:'accum ->
      f:('accum -> 'a -> 'accum Deferred.t) ->
      'accum Deferred.t

    val iter :
      'a Reader.t ->
      f:('a -> unit Deferred.t) ->
      unit Deferred.t

  end

  module Reader : sig
    module Read_result : sig
      type 'a t = [ `Eof | `Ok of 'a ]
    end

    type t

    (** Difference from Async: implementations should try to use
        [buf_len] but are not required to. *)
    val open_file : ?buf_len:int -> string -> t Deferred.t

    val close : t -> unit Deferred.t

    (** Difference from Async: implementations should try to use
        [buf_len] but are not required to. *)
    val with_file :
      ?buf_len:int ->
      string ->
      f:(t -> 'a Deferred.t) ->
      'a Deferred.t

    val read_line : t -> string Read_result.t Deferred.t
    val read_all : t -> (t -> 'a Read_result.t Deferred.t) -> 'a Pipe.Reader.t
    val lines : t -> string Pipe.Reader.t
    val contents : t -> string Deferred.t
    val file_contents : string -> string Deferred.t
    val file_lines : string -> string list Deferred.t
  end

  module Writer : sig
    type t

    val with_file
      : ?perm:int
      -> ?append:bool
      -> string
      -> f:(t -> 'a Deferred.t)
      -> 'a Deferred.t

    (** Following functions returned a Deferred.t, while in Async they
        return unit. *)
    val write : t -> string -> unit Deferred.t
    val write_char : t -> char -> unit Deferred.t
    val write_line : t -> string -> unit Deferred.t

  end

end
OCaml

Innovation. Community. Security.