text
stringlengths
0
601k
module Make ( H : Hashtbl . HashedType ) HashedType = MakeTbl ( MakeTblArrayLeaf ( MakeTblArrayLeafH ) MakeTblArrayLeafH ) MakeTblArrayLeafH
module StringContentsHash = struct type t = Bytes . t tagged let equal x1 x2 = let s1 = untag x1 in let s2 = untag x2 in if Bytes . length s1 <> Bytes . length s2 then false else let rec loop i = if i < 0 then true else if Bytes . get s1 i <> Bytes . get s2 i then false else loop ( i - 1 ) 1 in loop ( Bytes . length s1...
let bytes_hash v = let rec loop i sum = if i < 0 then sum else let a = Char . code ( Bytes . get v i ) i in let sum = sum lsr 7 lxor crc_tbl ( . sum lxor a land 0x7f ) 0x7f in loop ( i - 1 ) 1 sum in loop ( Bytes . length v - 5 ) 5 0
module BoolLeaf = struct type elt = bool type t = Bytes . t let level = 0 module Pool = Weak . Make ( StringContentsHash ) StringContentsHash let pool = Pool . create 256 let hashcons s = let n = bytes_hash s in let x = Tag ( s , n ) n in try Pool . find pool x with Not_found -> Pool . add pool x ; x let make_raw def =...
module Bool = struct module BoolTbl = MakeTbl ( BoolLeaf ) BoolLeaf include BoolTbl let of_set s = untag ( BoolTbl . of_set 0 false s true ) true let get tbl n = let lev = Array . unsafe_get tbl ( byte3 n ) n in let lev = Array . unsafe_get lev ( byte2 n ) n in let lev = Array . unsafe_get lev ( byte1 n ) n in let k = ...
module CharLeaf = struct type elt = char type t = Bytes . t let level = 0 module Pool = Weak . Make ( StringContentsHash ) StringContentsHash let pool = Pool . create 256 let hashcons s = let n = bytes_hash s in let x = Tag ( s , n ) n in try Pool . find pool x with Not_found -> Pool . add pool x ; x let make_raw c = B...
module Char = struct module CharTbl = MakeTbl ( CharLeaf ) CharLeaf include CharTbl let get tbl n = let lev = Array . unsafe_get tbl ( byte3 n ) n in let lev = Array . unsafe_get lev ( byte2 n ) n in let lev = Array . unsafe_get lev ( byte1 n ) n in Bytes . unsafe_get lev ( byte0 n ) n end
module BitsContentsHash = struct type t = Bitsvect . t tagged let equal x1 x2 = let a1 = untag x1 in let a2 = untag x2 in let rec loop i = if i < 0 then true else if Bitsvect . get a1 i = Bitsvect . get a2 i then loop ( i - 1 ) 1 else false in loop 255 let hash = id end
module BitsLeaf = struct type elt = int type t = Bitsvect . t let level = 0 module Pool = Weak . Make ( BitsContentsHash ) BitsContentsHash let pool = Pool . create 256 let hash v = let rec loop i sum = if i < 0 then sum else let a = Bitsvect . get v i in let sum = sum lsr 7 lxor crc_tbl ( . sum lxor a land 0x7f ) 0x7f...
module Bits = struct include MakeTbl ( BitsLeaf ) BitsLeaf let get tbl n = let lev = Array . unsafe_get tbl ( byte3 n ) n in let lev = Array . unsafe_get lev ( byte2 n ) n in let lev = Array . unsafe_get lev ( byte1 n ) n in Bitsvect . unsafe_get lev ( byte0 n ) n end
module BytesContentsHash = struct type t = Bytesvect . t tagged let equal x1 x2 = let a1 = untag x1 in let a2 = untag x2 in let rec loop i = if i < 0 then true else if Bytesvect . get a1 i = Bytesvect . get a2 i then loop ( i - 1 ) 1 else false in loop 255 let hash = id end
module BytesLeaf = struct type elt = int type t = Bytesvect . t let level = 0 module Pool = Weak . Make ( BytesContentsHash ) BytesContentsHash let pool = Pool . create 256 let hash v = let rec loop i sum = if i < 0 then sum else let a = Bytesvect . get v i in let sum = sum lsr 7 lxor crc_tbl ( . sum lxor ( byte3 a ) a...
module Bytes = struct include MakeTbl ( BytesLeaf ) BytesLeaf let get tbl n = let lev = Array . unsafe_get tbl ( byte3 n ) n in let lev = Array . unsafe_get lev ( byte2 n ) n in let lev = Array . unsafe_get lev ( byte1 n ) n in Bytesvect . unsafe_get lev ( byte0 n ) n end
= " mycallback3 " ( ' a -> ' b -> ' c -> ' d -> ' e ) -> ' a -> ' b -> ' c -> ' d -> ' e = " mycallback4 "
let rec tak ( x , y , z as _tuple ) = if x > y then tak ( tak ( x - 1 , y , z ) , tak ( y - 1 , z , x ) , tak ( z - 1 , x , y ) ) else z
let tak2 x ( y , z ) = tak ( x , y , z )
let tak3 x y z = tak ( x , y , z )
let tak4 x y z u = tak ( x , y , z + u )
let raise_exit ( ) = ( raise Exit : unit )
let trapexit ( ) = begin try mycallback1 raise_exit ( ) with Exit -> ( ) end ; tak ( 18 , 12 , 6 )
let tripwire f = let s = String . make 5 ' a ' in f s trapexit ( )
let sighandler signo = ignore ( tak ( 18 , 12 , 6 ) )
let callbacksig ( ) = let pid = unix_getpid ( ) in let s = String . make 5 ' b ' in unix_kill pid Sys . sigusr1 ; let u = ( s , s ) in fst u
let _ = print_int ( mycallback1 tak ( 18 , 12 , 6 ) ) ; print_newline ( ) ; print_int ( mycallback2 tak2 18 ( 12 , 6 ) ) ; print_newline ( ) ; print_int ( mycallback3 tak3 18 12 6 ) ; print_newline ( ) ; print_int ( mycallback4 tak4 18 12 3 3 ) ; print_newline ( ) ; print_int ( trapexit ( ) ) ; print_newline ( ) ; prin...
let tick = Scheduler . schedule ' ( fun ( ) -> return ( ) )
let bind_upon t f = ignore ( t >>= fun a -> f a ; Deferred . unit ) ; ;
let rec bind_loop = function | 0 -> tick | n -> tick >>= fun ( ) -> bind_loop ( n - 1 ) ; ;
let pure_loop n = Deferred . create ( fun i -> let rec f = function | 0 -> Ivar . fill i ( ) | n -> f ( n - 1 ) in f n ) ; ;
let slow_upon_loop n = Deferred . create ( fun i -> let rec f = function | 0 -> Ivar . fill i ( ) | n -> bind_upon tick ( fun ( ) -> f ( n - 1 ) ) in f n ) ; ;
let upon_loop n = Deferred . create ( fun i -> let rec f = function | 0 -> Ivar . fill i ( ) | n -> upon tick ( fun ( ) -> f ( n - 1 ) ) in f n ) ; ;
let loop = if Array . length ( Sys . get_argv ( ) ) < 2 then bind_loop else ( match ( Sys . get_argv ( ) ) . ( 1 ) with | " bind " -> bind_loop | " pure " -> pure_loop | " slow_upon " -> slow_upon_loop | " upon " -> upon_loop | _ -> raise ( Failure " unknown loop " ) ) ; ;
let ( ) = loop 2000000 >>> fun ( ) -> Shutdown . shutdown 0
let ( ) = never_returns ( Scheduler . go ( ) )
let initial_dir = Sys . getcwd ( )
let tmp_dir = Filename . get_temp_dir_name ( )
let call_uname ( ) = let ic = Unix . open_process_in " uname " in let uname = input_line ic in let ( ) = close_in ic in uname
let os : string = match Sys . os_type with | " Win32 " " | Cygwin " -> " Windows " | " Unix " -> begin match call_uname ( ) with | " Linux " -> " Linux " | " Darwin " -> " OSX " | _ -> failwith " cannot get os " | exception _ -> failwith " cannot get os " end | _ -> failwith " cannot get os "
let tryToRun cmd = Sys . chdir tmp_dir ; let result = match Sys . command cmd with | 0 -> true | _ -> false | exception _ -> false in Sys . chdir initial_dir ; result
let getFile ( args : args ) ( ext : FileKind . t ) : string = match ext with | FileKind . ExtOnly e -> args . output ^ " . " ^ e | FileKind . FullName n -> Filename . concat ( Filename . dirname args . output ) n
let writeFiles args files = List . iter ( fun ( text , file ) -> FileIO . write ( getFile args file ) ( Pla . print text ) |> ignore ) files
module CompactType = struct exception Parse_error of string type t = | STOP | TRUE | FALSE | BYTE | I16 | I32 | I64 | DOUBLE | BINARY | LIST | SET | MAP | STRUCT [ @@ deriving show ] let of_int = function | 0x00 -> STOP | 0x01 -> TRUE | 0x02 -> FALSE | 0x03 -> BYTE | 0x04 -> I16 | 0x05 -> I32 | 0x06 -> I64 | 0x07 -> DO...
module type IntSig = sig type t val logor : t -> t -> t val logand : t -> t -> t val logxor : t -> t -> t val shift_left : t -> int -> t val shift_right : t -> int -> t val shift_right_logical : t -> int -> t val neg : t -> t val one : t val zero : t val of_int : int -> t val to_int : t -> int val to_string : t -> stri...
module Int = struct type t = int let logor = ( lor ) let logand = ( land ) let logxor = ( lxor ) let shift_left = ( lsl ) let shift_right = ( asr ) let shift_right_logical = ( lsr ) let neg = ( ) ~- let one = 1 let zero = 0 let of_int i = i let to_int i = i let to_string = string_of_int let equal = ( ) = let max_int = ...
module IntOps ( I : IntSig ) = struct let ( lor ) = I . logor let ( land ) = I . logand let ( lxor ) = I . logxor let ( lsl ) = I . shift_left let ( lsr ) = I . shift_right_logical let ( asr ) = I . shift_right let ( ) ~- = I . neg end
module Buffer = struct include Buffer let add_uint8 b x = let bytes = Bytes . create 1 in NativeEndian . set_int8 bytes 0 x ; Buffer . add_bytes b bytes end
module ReadWriteInt ( I : IntSig ) = struct module Ops = IntOps ( I ) open I open Ops let write_varint trans ( n : I . t ) = let buffer = Buffer . create 8 in let rec write_varint_aux ( i : I . t ) = let b = i land ( of_int 0x7F ) in let i = i lsr 7 in Buffer . add_uint8 buffer @@ to_int @@ if i <> zero then b lor of_i...
module RI64 = ReadWriteInt ( Int64 ) inherit P . t trans val mutable _last_fid = 0 val mutable _bool_fid = None val mutable _bool_value = None val mutable _structs = [ ] val _ibyte = Bytes . create 8 method writeBool b = let comp_type = CompactType . ( if b then TRUE else FALSE ) in match _bool_fid with | Some x -> sel...
module Where_to_connect = struct type ' addr t = { socket_type : ' addr Socket . Type . t ; remote_address : unit -> ' addr Deferred . t ; local_address : ' addr option ; info : Sexp . t } let sexp_of_t _ { info ; _ } = info type inet = Socket . Address . Inet . t t [ @@ deriving sexp_of ] type unix = Socket . Address ...
let close_sock_on_error s f = try_with ~ name " : Tcp . close_sock_on_error " f >>| function | Ok v -> v | Error e -> don ' t_wait_for ( Unix . close ( Socket . fd s ) ) ; raise e ; ;
let reader_writer_of_sock ? buffer_age_limit ? reader_buffer_size ? writer_buffer_size s = let fd = Socket . fd s in ( Reader . create ? buf_len : reader_buffer_size fd , Writer . create ? buffer_age_limit ? buf_len : writer_buffer_size fd ) ; ;
let connect_sock ? socket ? interrupt ( ? timeout = sec 10 . ) ( where_to_connect : _ Where_to_connect . t ) = where_to_connect . remote_address ( ) >>= fun address -> let timeout = Clock . after timeout in let interrupt = match interrupt with | None -> timeout | Some interrupt -> Deferred . any [ interrupt ; timeout ]...
type ' a with_connect_options = ? buffer_age_limit [ : ` At_most of Time . Span . t | ` Unlimited ] -> ? interrupt : unit Deferred . t -> ? reader_buffer_size : int -> ? writer_buffer_size : int -> ? timeout : Time . Span . t -> ' a
let connect ? socket ? buffer_age_limit ? interrupt ? reader_buffer_size ? writer_buffer_size ? timeout where_to_connect = connect_sock ? socket ? interrupt ? timeout where_to_connect >>| fun s -> let r , w = reader_writer_of_sock ? buffer_age_limit ? reader_buffer_size ? writer_buffer_size s in s , r , w ; ;
let collect_errors writer f = let monitor = Writer . monitor writer in ignore ( Monitor . detach_and_get_error_stream monitor : _ Stream . t ) ; choose [ choice ( Monitor . get_next_error monitor ) ( fun e -> Error e ) ; choice ( try_with ~ name " : Tcp . collect_errors " f ) Fn . id ] ; ;
let close_connection_via_reader_and_writer r w = Writer . close w ~ force_close ( : Clock . after ( sec 30 . ) ) >>= fun ( ) -> Reader . close r ; ;
let with_connection ? buffer_age_limit ? interrupt ? reader_buffer_size ? writer_buffer_size ? timeout where_to_connect f = connect_sock ? interrupt ? timeout where_to_connect >>= fun socket -> let r , w = reader_writer_of_sock ? buffer_age_limit ? reader_buffer_size ? writer_buffer_size socket in let res = collect_err...
module Bind_to_address = struct type t = | Address of Unix . Inet_addr . t | All_addresses | Localhost [ @@ deriving sexp_of ] end
module Bind_to_port = struct type t = | On_port of int | On_port_chosen_by_os [ @@ deriving sexp_of ] end
module Where_to_listen = struct type ( ' address , ' listening_on ) t = { socket_type : ' address Socket . Type . t ; address : ' address ; listening_on : ( ' address -> ' listening_on [ @ sexp . opaque ] ) } [ @@ deriving sexp_of , fields ] type inet = ( Socket . Address . Inet . t , int ) t [ @@ deriving sexp_of ] ty...
module Server = struct module Connection = struct type ' address t = { client_socket : ( [ ` Active ] , ' address ) Socket . t ; client_address : ' address } [ @@ deriving fields , sexp_of ] let invariant invariant_address t = Invariant . invariant [ % here ] t [ % sexp_of : _ t ] ( fun ( ) -> let check f = Invariant ....
module Private = struct let close_connection_via_reader_and_writer = close_connection_via_reader_and_writer end
let endian_of = function | 0xa1b2c3d4_l -> Bitstring . BigEndian | 0xd4c3b2a1_l -> Bitstring . LittleEndian | _ -> assert false
let libpcap_header bits = bitmatch bits with | { ( ( 0xa1b2c3d4_l | 0xd4c3b2a1_l ) 0xd4c3b2a1_l as magic ) magic : 32 ; major : 16 : endian ( endian_of magic ) magic ; minor : 16 : endian ( endian_of magic ) magic ; timezone : 32 : endian ( endian_of magic ) magic ; _ : 32 : endian ( endian_of magic ) magic ; snaplen :...
let libpcap_packet e file_header bits = bitmatch bits with | { ts_sec : 32 : littleendian ; ts_usec : 32 : littleendian ; incl_len : 32 : littleendian ; orig_len : 32 : littleendian ; pkt_data : Int32 . to_int incl_len * 8 : bitstring ; rest : - 1 : bitstring } -> ( ts_sec , ts_usec , incl_len , orig_len ) orig_len , p...
let decode_and_print_packet file_header pkt_header pkt_data = let ( ts_sec , ts_usec , _ , orig_len ) orig_len = pkt_header in printf " % ld . % ld % ldB " ts_sec ts_usec orig_len ; ( bitmatch pkt_data with | { d0 : 8 ; d1 : 8 ; d2 : 8 ; d3 : 8 ; d4 : 8 ; d5 : 8 ; s0 : 8 ; s1 : 8 ; s2 : 8 ; s3 : 8 ; s4 : 8 ; s5 : 8 ; _...
let rec main ( ) = if Array . length Sys . argv <= 1 then failwith " libpcap dumpfile " ; let bits = Bitstring . bitstring_of_file Sys . argv ( . 1 ) 1 in let endian , file_header , bits = libpcap_header bits in let rec loop bits = let pkt_header , pkt_data , bits = libpcap_packet endian file_header bits in decode_and_...
let ( ) = main ( )
module WP = functor ( Arg : IncrSolverArg ) -> functor ( S : EqConstrSys ) -> functor ( HM : Hashtbl . S with type key = S . v ) -> struct module Post = PostSolver . MakeList ( PostSolver . ListArgFromStdArg ( S ) ( HM ) ( Arg ) ) include Generic . SolverStats ( S ) ( HM ) module VS = Set . Make ( S . Var ) type solver...
let _ = Selector . add_solver ( " td3 " , ( module WP : GenericEqBoxIncrSolver ) ) ;
let myinit ( ) = let light_ambient = ( 0 . 0 , 0 . 0 , 0 . 0 , 1 . 0 ) and light_diffuse = ( 1 . 0 , 1 . 0 , 1 . 0 , 1 . 0 ) and light_specular = ( 1 . 0 , 1 . 0 , 1 . 0 , 1 . 0 ) and light_position = ( 1 . 0 , 0 . 0 , 0 . 0 , 0 . 0 ) and global_ambient = ( 0 . 75 , 0 . 75 , 0 . 75 , 1 . 0 ) in glLight ( GL_LIGHT 0 ) (...
let display ( ) = let low_ambient = ( 0 . 1 , 0 . 1 , 0 . 1 , 1 . 0 ) and more_ambient = ( 0 . 4 , 0 . 4 , 0 . 4 , 1 . 0 ) and most_ambient = ( 1 . 0 , 1 . 0 , 1 . 0 , 1 . 0 ) in glClear [ GL_COLOR_BUFFER_BIT ; GL_DEPTH_BUFFER_BIT ] ; glMaterial GL_FRONT ( Material . GL_AMBIENT low_ambient ) ; glMaterial GL_FRONT ( Mat...
let reshape ~ width : w ~ height : h = glViewport 0 0 w h ; glMatrixMode GL_PROJECTION ; glLoadIdentity ( ) ; if ( w <= h ) then glOrtho ( - 4 . 0 ) ( 4 . 0 ) ( - 4 . 0 . * ( float h ) . / ( float w ) ) ( 4 . 0 . * ( float h ) . / ( float w ) ) ( - 10 . 0 ) ( 10 . 0 ) else glOrtho ( - 4 . 0 . * ( float w ) . / ( float ...
let keyboard ~ key ~ x ~ y = begin match key with | ' \ 027 ' -> exit 0 ; | _ -> ( ) end ; glutPostRedisplay ( ) ; ; ;
let ( ) = ignore ( glutInit Sys . argv ) ; glutInitDisplayMode [ GLUT_SINGLE ; GLUT_RGB ; GLUT_DEPTH ] ; glutInitWindowSize 500 500 ; ignore ( glutCreateWindow Sys . argv . ( 0 ) ) ; myinit ( ) ; glutReshapeFunc ~ reshape ; glutDisplayFunc ~ display ; glutKeyboardFunc ~ keyboard ; glutMainLoop ( ) ; ; ;
let spinning = ref false
let f2i f = int_of_float f
let i2f i = float_of_int i
let recalcModelView ( ) = GlMat . pop ( ) ; GlMat . push ( ) ; let m = Trackball . build_rotmatrix ! curquat in GlMat . mult m ; GlMat . scale ~ x :! scalefactor ~ y :! scalefactor ~ z :! scalefactor ( ) ; newModel := false ; ; ;
let showMessage x y z message = GlMat . push ( ) ; Gl . disable ` lighting ; GlMat . translate ~ x ~ y ~ z ( ) ; GlMat . scale ~ x : 0 . 005 ~ y : 0 . 005 ~ z : 0 . 005 ( ) ; String . iter ( function c -> Glut . strokeCharacter Glut . STROKE_ROMAN ( int_of_char c ) ) message ; Gl . enable ` lighting ; GlMat . pop ( ) ;...
let redraw ( ) = if ( ! newModel ) then recalcModelView ( ) ; GlClear . clear [ ` color ; ` depth ] ; Glut . solidTeapot 1 . 0 ; showMessage 0 . 0 1 . 0 0 . 0 " Spin me . " ; Glut . swapBuffers ( ) ; ; ;
let update_wh w ' h ' = w := w ' ; h := h ' ; ; ;
let myReshape ~ w ~ h = printf " reshape \ n " ; GlDraw . viewport ~ x : 0 ~ y : 0 ~ w ~ h ; update_wh w h ; ; ;
let mouse ~ button ~ state ~ x ~ y = if ( button = Glut . LEFT_BUTTON && state = Glut . DOWN ) then begin spinning := false ; Glut . idleFunc ( Some ( function ( ) -> ( ) ) ) ; moving := true ; beginx := x ; beginy := y ; scaling := if ( Glut . getModifiers ( ) land Glut . active_shift <> 0 ) then true else false ; end...
let animate ( ) = curquat := Trackball . add_quats ! lastquat ! curquat ; newModel := true ; Glut . postRedisplay ( ) ; ; ;
let motion ~ x ~ y = if ( ! scaling ) then begin scalefactor := ! scalefactor . * ( 1 . 0 . + ( ( float_of_int ( ! beginy - y ) ) . / ( float_of_int ! h ) ) ) ; beginx := x ; beginy := y ; newModel := true ; Glut . postRedisplay ( ) ; end else if ( ! moving ) then begin let x0 = i2f ! beginx and y0 = i2f ! beginy and w...
let lightZeroSwitch = ref true and lightOneSwitch = ref true
let controlLights ~ value = match value with | 1 -> begin lightZeroSwitch := not ! lightZeroSwitch ; if ( ! lightZeroSwitch ) then Gl . enable ` light0 else Gl . disable ` light0 end | 2 -> begin lightOneSwitch := not ! lightOneSwitch ; if ( ! lightOneSwitch ) then Gl . enable ` light1 else Gl . disable ` light1 end | ...
let vis ~ state = if state = Glut . VISIBLE then begin if ! spinning then Glut . idleFunc ( Some animate ) ; end else if ! spinning then Glut . idleFunc ( Some ( function ( ) -> ( ) ) ) ; ; ;
let main ( ) = ignore ( Glut . init Sys . argv ) ; Glut . initDisplayMode ~ alpha : false ~ double_buffer : true ~ depth : true ~ multisample : true ( ) ; ignore ( Glut . createWindow " teaspin " ) ; Glut . displayFunc redraw ; Glut . reshapeFunc myReshape ; Glut . visibilityFunc vis ; Glut . mouseFunc mouse ; Glut . m...
type ( ' flags , ' model , ' msg ) program = { init : ' flags -> ' model * ' msg Tea_cmd . t ; update : ' model -> ' msg -> ' model * ' msg Tea_cmd . t ; view : ' model -> ' msg Vdom . t ; subscriptions : ' model -> ' msg Tea_sub . t ; shutdown : ' model -> ' msg Tea_cmd . t ; }
type ( ' flags , ' model , ' msg ) standardProgram = { init : ' flags -> ' model * ' msg Tea_cmd . t ; update : ' model -> ' msg -> ' model * ' msg Tea_cmd . t ; view : ' model -> ' msg Vdom . t ; subscriptions : ' model -> ' msg Tea_sub . t ; }
type ( ' model , ' msg ) beginnerProgram = { model : ' model ; update : ' model -> ' msg -> ' model ; view : ' model -> ' msg Vdom . t ; }
type ( ' model , ' msg ) pumpInterface = { startup : unit -> unit ; render_string : ' model -> string ; handleMsg : ' model -> ' msg -> ' model ; shutdown : ' msg Tea_cmd . t -> unit ; }
type ' msg programInterface = < pushMsg : ' msg -> unit ; pushMsg ( ' : msg -> unit ) -> shutdown ( : unit -> unit ) -> getHtmlString ( : unit -> string ) -> ' msg programInterface = " " [ @@ bs . obj ]
let programStateWrapper initModel pump shutdown = let open Vdom in let model = ref initModel in let callbacks = ref { enqueue = fun _msg -> Js . log " INVALID enqueue CALL " ! } in let pumperInterfaceC ( ) = pump callbacks in let pumperInterface = pumperInterfaceC ( ) in let pending : ' msg list option ref = ref None i...
let programLoop update view subscriptions initModel initCmd = function | None -> fun callbacks -> let oldSub = ref Tea_sub . none in let handleSubscriptionChange model = let newSub = subscriptions model in oldSub := ( Tea_sub . run callbacks callbacks ! oldSub newSub ) in { startup = ( fun ( ) -> let ( ) = Tea_cmd . ru...
let program : ( ' flags , ' model , ' msg ) program -> Web . Node . t Js . null_undefined -> ' flags -> ' msg programInterface = fun { init ; update ; view ; subscriptions ; shutdown } pnode flags -> let ( ) = Web . polyfills ( ) in let initModel , initCmd = init flags in let opnode = Js . Null_undefined . toOption pno...
let standardProgram : ( ' flags , ' model , ' msg ) standardProgram -> Web . Node . t Js . null_undefined -> ' flags -> ' msg programInterface = fun { init ; update ; view ; subscriptions } pnode args -> program { init = init ; update = update ; view = view ; subscriptions = subscriptions ; shutdown = fun _model -> Tea...
let beginnerProgram : ( ' model , ' msg ) beginnerProgram -> Web . Node . t Js . null_undefined -> unit -> ' msg programInterface = fun { model ; update ; view } pnode ( ) -> standardProgram { init = ( fun ( ) -> ( model , Tea_cmd . none ) ) ; update = ( fun model msg -> ( update model msg , Tea_cmd . none ) ) ; view =...
let map func vnode = Vdom . map func vnode newModel | Some ( parentNode , lastVdom ) -> fun update view initModel msgHandler -> let handler model msg = let newModel , _newCmd = update model msg in let newVdom = view newModel in ( lastVdom := newVdom ) ; newModel in handler