Commits

camlspotter committed 315f725

found a nice way to express self constraints of module type!

  • Participants
  • Parent commits 298dba1

Comments (0)

Files changed (2)

File lib/pbase.ml

 open Result
 
 module type S = sig
-  include Planck_intf.S
+
+  module Str : Stream_intf.S
+  type error = Str.Pos.t * string
+  type 'a t = Str.t -> ('a * Str.t, error) Result.t
   val run : 'a t -> Str.t -> ('a * Str.t, error) Result.t
+
+  include Planck_intf.S with module Str := Str and type 'a t := 'a t and type error := error
+
 end
 
 module Make(Str : Stream_intf.S) = struct

File lib/pbase.mli

 (** The basic monadic parser module. See Planck_intf.ml for more details *)
 
 module type S = sig
-  include Planck_intf.S
-(* CR jfuruse: damn it, we cannot restrict signature by components of itself!
-      and  type 'a t = Str.t -> ('a * Str.t, error) Result.t
-*)
+
+  module Str : Stream_intf.S
+  type error = Str.Pos.t * string
+  type 'a t = Str.t -> ('a * Str.t, error) Result.t
   val run : 'a t -> Str.t -> ('a * Str.t, error) Result.t
+
+  include Planck_intf.S with module Str := Str and type 'a t := 'a t and type error := error
+
 end
 
-module Make( Str : Stream_intf.S ) 
-  : S with module Str = Str
-      and  type 'a t = Str.t -> ('a * Str.t, Str.Pos.t * string (* =error *)) Result.t
+module Make( Str : Stream_intf.S ) : S with module Str = Str
 (** Functor [Make] takes a stream implementation [S] and create a monadic parser module for [S].
     The monad is a function type [Str.t -> ('a * Str.t, error) Result.t].
 *)