Advertisement
Guest User

Untitled

a guest
Sep 13th, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.84 KB | None | 0 0
  1.   open Js_of_ocaml
  2.   open BatPervasives
  3.   open Eliom_content
  4.  
  5.   module MatchCapture = struct
  6.     type buyCapture = {
  7.       buyId : int;
  8.       quantity : int;
  9.     } [@@deriving yojson]
  10.  
  11.     type t = {
  12.       sellId : int;
  13.       buyCaptures : buyCapture list;
  14.     } [@@deriving yojson]
  15.  
  16.     let buyOrder (buyId, quantity) = {buyId=buyId; quantity=quantity}
  17.  
  18.     let of_tuple (sellId, buyCaptures) = {sellId=sellId; buyCaptures=buyCaptures}
  19.  
  20.     let of_dom sellId buy_tuples =
  21.       let buyOrder (buyId, quantity_input) =
  22.         let quantity_input' = Eliom_content.Html.To_dom.of_input quantity_input in
  23.         let order_quantity = (int_of_string % Js.to_string) quantity_input'##.value
  24.         in buyOrder (buyId, order_quantity) in
  25.  
  26.       let buyOrders = List.map buyOrder buy_tuples
  27.       in of_tuple (sellId, buyOrders)
  28.   end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement