Docs GODI Archive
Projects Blog Link DB

Search GODI:


More options
File lib/ocaml/pkg-lib/lua-ml/lua.mli GODI Package godi-lua-ml
Library lua-ml
 
   lua.cmi_pretty    lua.mli    Sources  

# 22 "lua.nw"
module type VALUE = sig
  type 'a userdata'
  type srcloc
  type initstate
  type value =
    | Nil
    | Number   of float
    | String   of string
    | Function of srcloc * func
    | Userdata of userdata
    | Table    of table
  and func  = value list -> value list
  and table = (value, value) Luahash.t
  and userdata  = value userdata'
  and state = { globals : table
              ; fallbacks : (string, value) Hashtbl.t
              ; mutable callstack : activation list
              ; mutable currentloc : Srcmap.location option (* supersedes top of stack *)
              ; startup : initstate
              }
  and activation = srcloc * Srcmap.location option

  val caml_func : func -> value (* each result unique *)
  val lua_func  : file:string -> linedefined:int -> func -> value
  val srcloc    : file:string -> linedefined:int -> srcloc (* must NOT be reused *)
  val eq        : value -> value -> bool
  val to_string : value -> string
  val activation_strings : state -> activation -> string list
  type objname = Fallback of string | Global of string | Element of string * value
  val objname : state -> value -> objname option
     (* 'fallback', 'global', or 'element', name *)

  val state : unit -> state (* empty state, without even fallbacks *)
  val at_init : state -> string list -> unit  (* run code at startup time *)
  val initcode : state -> (string -> unit) -> unit (* for the implementation only *)

# 64 "lua.nw"
  module Table : sig
    val create : int -> table
    val find   : table -> key:value -> value
    val bind   : table -> key:value -> data:value -> unit
    val of_list : (string * value) list -> table
  end

# 79 "lua.nw"
  exception Projection of value * string
  val projection : value -> string -> 'a
  type ('a, 'b, 'c) ep = ('a, 'b, 'c) Luavalue.ep
    = { embed : 'a -> 'b; project : 'b -> 'a; is : 'c -> bool }
  type 'a map  = ('a, value, value) ep
  type 'a mapf  (* used to build function maps that curry/uncurry *)

# 88 "lua.nw"
  val float    : float  map
  val int      : int    map
  val bool     : bool   map
  val string   : string map
  val userdata : userdata map
  val unit     : unit   map

# 99 "lua.nw"
  val option : 'a map -> 'a option map

# 104 "lua.nw"
  val default : 'a -> 'a map -> 'a map

# 114 "lua.nw"
  val list    : 'a map -> 'a list map   (* does not project nil *)
  val optlist : 'a map -> 'a list map   (* projects nil to empty list *)

# 120 "lua.nw"
  val value  : value map
  val table  : table map

# 126 "lua.nw"
  val record : 'a map -> (string * 'a) list map

# 135 "lua.nw"
  val enum   : string -> (string * 'a) list -> 'a map

# 155 "lua.nw"
  val ( -->  ) : 'a map  -> 'b map  -> ('a -> 'b) map
  val ( **-> ) : 'a map  -> 'b mapf -> ('a -> 'b) mapf
  val result   : 'a map  -> 'a mapf
  val resultvs : value list mapf                   (* functions returning value lists*)
  val resultpair:'a map  -> 'b map  -> ('a * 'b)       mapf
  val dots_arrow:'a map  -> 'b map  -> ('a list -> 'b) mapf     (* varargs functions *)
  val results  : ('a -> value list) -> (value list -> 'a) -> 'a mapf  
                                    (* 'a represents multiple results (general case) *)
  val func     : 'a mapf -> 'a map                 (* function *)
  val closure  : 'a mapf -> 'a map                 (* function or table+apply method *)
  val efunc    : 'a mapf -> 'a -> value            (* efunc f = (closure f).embed *)

# 172 "lua.nw"
  type alt                              (* an alternative *)
  val alt    : 'a mapf -> 'a -> alt     (* create an alternative *)
  val choose : alt list -> value        (* dispatch on type/number of args *)

# 195 "lua.nw"
  val ( <|> ) : 'a map -> 'a map -> 'a map 
  val ( <@  ) : 'a map -> ('a -> 'b) -> 'b map   (* apply continuation after project *)
end

# 204 "lua.nw"
module type USERDATA = sig
  type 'a t                             (* type parameter will be Lua value *)
  val tname : string  (* name of this type, for projection errors *)
  val eq : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
  val to_string : ('a -> string) -> 'a t -> string
end

# 219 "lua.nw"
module type AST = Luaast.S
module Parser : sig
  type token = Luaparser.token
  module type S =
    sig
      type chunk
      val chunks : (Lexing.lexbuf  -> token) -> Lexing.lexbuf -> chunk list
    end
  module type MAKER = functor (Ast : AST) -> S with type chunk = Ast.chunk
  module MakeStandard : MAKER
end

# 239 "lua.nw"
module Lib : sig
  
  # 273 "lua.nw"
  module type USERTYPE = sig
    type 'a t                             (* type parameter will be Lua value *)
    val tname : string  (* name of this type, for projection errors *)
    val eq : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
    val to_string : ('a -> string) -> 'a t -> string
  end
  
  # 294 "lua.nw"
  module type TYPEVIEW = sig
    type 'a combined
    type 'a t  (* the individual type of which this is a view *)
    val makemap : ('a combined, 'b, 'b) Luavalue.ep -> ('b -> string -> 'a t)
                  -> ('a t, 'b, 'b) Luavalue.ep
  end
  
  # 305 "lua.nw"
  module type COMBINED_CORE = sig
    type 'a also_t
    module type VIEW = TYPEVIEW with type 'a combined = 'a also_t
    module TV1  : VIEW
    module TV2  : VIEW
    module TV3  : VIEW
    module TV4  : VIEW
    module TV5  : VIEW
    module TV6  : VIEW
    module TV7  : VIEW
    module TV8  : VIEW
    module TV9  : VIEW
    module TV10 : VIEW
  end
  module type COMBINED_VIEWS = sig
    type 'a t
    include COMBINED_CORE with type 'a also_t = 'a t
  end
  module type COMBINED_TYPE = sig
    include USERTYPE
    include COMBINED_CORE with type 'a also_t = 'a t
  end
  
  # 332 "lua.nw"
  module type CORE = sig
    module V : Luavalue.S
    val error : string -> 'a  (* error fallback *)
    val getglobal : V.state -> V.value -> V.value
    val fallback : string -> V.state -> V.value list -> V.value list
      (* invoke named fallback on given state and arguments *)
    val setfallback : V.state -> string -> V.value -> V.value
      (* sets fallback, returns previous one *)
    val apply : V.value -> V.state -> V.value list -> V.value list
  
    val register_globals :           (string * V.value) list -> V.state -> unit
      (* registers values as named global variables *)
    val register_module  : string -> (string * V.value) list -> V.state -> unit
      (* register_module t l inserts members of l into global table t, 
         creating t if needed *)
  end
  
  # 367 "lua.nw"
  module type BARECODE = 
    functor (C : CORE) -> sig
      val init : C.V.state -> unit
    end
  
  # 377 "lua.nw"
  module type USERCODE = sig
    type 'a userdata'  (* the userdata' tycon of the core on which lib depends *)
    module M : functor (C : CORE with type 'a V.userdata' = 'a userdata') -> sig
      val init : C.V.state -> unit
    end
  end
  
  # 389 "lua.nw"
  module WithType
    (T : USERTYPE) (L : BARECODE) : USERCODE with type 'a userdata' = 'a T.t
  
  # 395 "lua.nw"
  module Combine : sig
    module T10 (T1 : USERTYPE) (T2 : USERTYPE) (T3 : USERTYPE) (T4 : USERTYPE)
               (T5 : USERTYPE) (T6 : USERTYPE) (T7 : USERTYPE) (T8 : USERTYPE)
               (T9 : USERTYPE) (T10 : USERTYPE)
     : COMBINED_TYPE with type 'a TV1.t = 'a T1.t with type 'a TV2.t = 'a T2.t
                     with type 'a TV3.t = 'a T3.t with type 'a TV4.t = 'a T4.t
                     with type 'a TV5.t = 'a T5.t with type 'a TV6.t = 'a T6.t
                     with type 'a TV7.t = 'a T7.t with type 'a TV8.t = 'a T8.t
                     with type 'a TV9.t = 'a T9.t with type 'a TV10.t = 'a T10.t
    
    # 635 "lua.nw"
    module T1 (T1 : USERTYPE)  : COMBINED_TYPE
     with type 'a TV1.t = 'a T1.t
    module T2 (T1 : USERTYPE) (T2 : USERTYPE)  : COMBINED_TYPE
     with type 'a TV1.t = 'a T1.t with type 'a TV2.t = 'a T2.t
    module T3 (T1 : USERTYPE) (T2 : USERTYPE) (T3 : USERTYPE)  : COMBINED_TYPE
     with type 'a TV1.t = 'a T1.t with type 'a TV2.t = 'a T2.t with type 'a TV3.t = 'a T3.t
    module T4 (T1 : USERTYPE) (T2 : USERTYPE) (T3 : USERTYPE) (T4 : USERTYPE)  : COMBINED_TYPE
     with type 'a TV1.t = 'a T1.t with type 'a TV2.t = 'a T2.t with type 'a TV3.t = 'a T3.t with type 'a TV4.t = 'a T4.t
    module T5 (T1 : USERTYPE) (T2 : USERTYPE) (T3 : USERTYPE) (T4 : USERTYPE) (T5 : USERTYPE)  : COMBINED_TYPE
     with type 'a