text
stringlengths
0
601k
module Core = struct module Int = struct module T = struct type t = int let compare = compare let ( ) + x y = x + y end include T module Map = Map . Make ( T ) end module Std = struct module Int = Int end end ; ; ; ;
let x = Int . Map . empty ; ;
let y = x + x ; ;
module M = struct type t = A type u = C end
module N = struct type t = B end A ; ; B ; ; C ; ; C ; ;
module L = struct type v = V end V ; ;
module L = struct type v = V end V ; ;
module M1 = struct type u = v and v = t1 end ; ;
module N1 = struct type u = v and v = M1 . v end ; ;
module N2 = struct type u = v and v = M1 . v end ; ;
module type PR6566 = sig type t = string end ; ;
module PR6566 = struct type t = int end ; ;
module PR6566 ' : PR6566 = PR6566 ; ;
module A = struct module B = struct type t = T end end ; ;
module M2 = struct type u = A . B . t type foo = int type v = A . B . t end ; ;
let ( ) = let % foo [ @ foo ] x = 3 and [ @ foo ] y = 4 in ( let module % foo [ @ foo ] M = M in ( ) ) ; ( let open % foo [ @ foo ] M in ( ) ) ; ( fun % foo [ @ foo ] x -> ( ) ) ; ( function % foo [ @ foo ] x -> ( ) ) ; ( try % foo [ @ foo ] ( ) with _ -> ( ) ) ; ( if % foo [ @ foo ] ( ) then ( ) else ( ) ) ; while % f...
type t = ( module % foo [ @ foo ] M )
module M = functor [ @ foo ] ( M : S ) -> ( val [ @ foo ] x ) ( struct [ @ foo ] end )
module type S = functor [ @ foo ] ( M : S ) -> ( module type of [ @ foo ] M ) -> ( sig [ @ foo ] end )
module type % foo [ @ foo ] S = S
module type S = sig val % foo [ @ foo ] x : t external % foo [ @ foo ] x : t = " " type % foo [ @ foo ] t = int and [ @ foo ] t ' = int type % foo [ @ foo ] t += T exception % foo [ @ foo ] X module % foo [ @ foo ] M : S module % foo [ @ foo ] rec M : S and [ @ foo ] M : S module % foo [ @ foo ] M = M module type % foo...
module Rev_deps : sig type t val create : unit -> t val extend_up_to : t -> Dependency . t -> unit val get : t -> Dependency . t -> Dependency . Set . t val add : t -> source : Dependency . t -> target : Dependency . t -> unit val add_alias : t -> source : Dependency . t -> target : Dependency . t -> unit val before : ...
module Origin_range_tbl = struct type ' a t = { mutable envs : ' a list Age . Map . t ; mutable dep_keys : Dependency . Set . t ; deps : ' a list Dependency . Tbl . t ; } let create ( ) = { envs = Age . Map . empty ; dep_keys = Dependency . Set . empty ; deps = Dependency . Tbl . create 0 ; } let add_dependency dep dat...
module Todo = struct module Item = struct type t = | Base of Diff . Item . t | Children of { md : Module . t ; path : Path . t ; seen : Path_set . t ; } | Update of { id : Ident . t ; origin : Origin . t ; } | Forward of { id : Ident . t ; decl : Origin . t ; origin : Origin . t ; } end type t = { mutable table : Item ...
module Forward_path_map : sig type ' a t val empty : ' a t val add : ' a t -> Sort . t -> Path . t -> ' a -> ' a t val find : ' a t -> Path . t -> ' a list val rebase : ' a t -> ' a t -> ' a t val iter_forwards : ( Path . t -> ' a -> unit ) -> ' a t -> Ident . t -> unit val iter_updates : ( Path . t -> ' a -> unit ) ->...
module History : sig module Stamp : Natural . S module Revision : sig type t val stamp : t -> Stamp . t val diff : t -> Diff . t val rev_deps : t -> Rev_deps . t val next : t -> t option end type t val init : Rev_deps . t -> Diff . t -> t val head : t -> Revision . t val commit : t -> Rev_deps . t -> Diff . t -> unit m...
type type_resolution = | Nth of int | Subst of int list | Id
type type_result = | Nth of int | Path of int list option * Path . t
type class_type_result = int list option * Path . t
module Shortest = struct module Section = struct type t = { mutable types : Path . t Forward_path_map . t ; mutable class_types : Path . t Forward_path_map . t ; mutable module_types : Path . t Forward_path_map . t ; mutable modules : ( Path . t * Path_set . t ) Forward_path_map . t ; } let create ( ) = let types = For...
module Basis = struct type load = { name : string ; depends : string list ; alias_depends : string list ; desc : Desc . Module . t ; deprecated : Desc . deprecated ; } type t = { mutable next_dep : Dependency . t ; mutable pending_additions : String_set . t ; mutable pending_loads : load list ; mutable assignment : Dep...
type state = | Initial of Basis . t | Unforced of { parent : t ; desc : Desc . t list Lazy . t ; } | Forced of { basis : Basis . t ; shortest : Shortest . env Shortest . t ; }
let rec force t = match ! t with | Initial _ | Forced _ as state -> state | Unforced { parent ; desc } -> let desc = Lazy . force desc in let state = match force parent with | Unforced _ -> assert false | Initial basis -> let shortest = Shortest . env ( Basis . shortest basis ) desc in Forced { basis ; shortest } | For...
let initial basis = ref ( Initial basis )
let add parent desc = ref ( Unforced { parent ; desc } )
type ext_shortest = Shortest : ' k Shortest . t -> ext_shortest
let shortest t = match force t with | Unforced _ -> assert false | Initial basis -> Basis . update basis ; Shortest ( Basis . shortest basis ) | Forced { basis ; shortest } -> Basis . update basis ; Shortest shortest
let find_type t path = let Shortest shortest = shortest t in match Shortest . find_type shortest path with | exception Not_found -> Path ( None , path ) | result -> result
let find_type_resolution t path : type_resolution = let Shortest shortest = shortest t in match Shortest . find_type_resolution shortest path with | exception Not_found -> Id | subst -> subst
let find_type_simple t path = let Shortest shortest = shortest t in match Shortest . find_type_simple shortest path with | exception Not_found -> path | path -> path
let find_class_type t path = let Shortest shortest = shortest t in match Shortest . find_class_type shortest path with | exception Not_found -> ( None , path ) | result -> result
let find_class_type_simple t path = let Shortest shortest = shortest t in match Shortest . find_class_type_simple shortest path with | exception Not_found -> path | path -> path
let find_module_type t path = let Shortest shortest = shortest t in match Shortest . find_module_type shortest path with | exception Not_found -> path | path -> path
let find_module t path = let Shortest shortest = shortest t in match Shortest . find_module shortest path with | exception Not_found -> path | path -> path
module Ident = struct type t = Ident . t let equal t1 t2 = Ident . equal t1 t2 let compare t1 t2 = Ident . compare t1 t2 let name = Ident . name let global name = Ident . create_persistent name end
module Path = struct type t = Path . t = | Pident of Ident . t | Pdot of t * string | Papply of t * t open Path let rec equal t1 t2 = match t1 , t2 with | Pident id1 , Pident id2 -> Ident . equal id1 id2 | Pident _ , Pdot _ -> false | Pident _ , Papply _ -> false | Pdot _ , Pident _ -> false | Pdot ( parent1 , name1 ) ...
module Desc = struct type deprecated = | Deprecated | Not_deprecated module Type = struct type t = | Fresh | Nth of int | Subst of Path . t * int list | Alias of Path . t end module Module_type = struct type t = | Fresh | Alias of Path . t end module Class_type = struct type t = | Fresh | Subst of Path . t * int list |...
module Sort = struct type t = | Defined | Declared of Ident_set . t let application t1 t2 = match t1 , t2 with | Defined , Defined -> Defined | Defined , Declared _ -> t2 | Declared _ , Defined -> t1 | Declared ids1 , Declared ids2 -> Declared ( Ident_set . union ids1 ids2 ) end
module Origin = struct type t = | Dependency of Dependency . t | Dependencies of Dependency . t list | Environment of Age . t let rec deps_add dep deps = match deps with | [ ] -> [ dep ] | dep ' :: rest -> if Dependency . equal dep dep ' then deps else if Dependency . less_than dep dep ' then dep :: deps else dep ' :: ...
let hidden_name name = if name <> " " && name . [ 0 ] = ' _ ' then true else try for i = 1 to String . length name - 2 do if name . [ i ] = ' _ ' && name . [ i + 1 ] = ' _ ' then raise Exit done ; false with Exit -> true
let hidden_ident id = if ! Clflags . unsafe_string && Ident . equal id Predef . ident_bytes then true else hidden_name ( Ident . name id )
let hidden_definition deprecated name = match deprecated with | Desc . Deprecated -> true | Desc . Not_deprecated -> hidden_name name
let hidden_base_definition deprecated id = match deprecated with | Desc . Deprecated -> true | Desc . Not_deprecated -> hidden_ident id
module rec Type : sig type t val base : Origin . t -> Ident . t -> Desc . Type . t option -> Desc . deprecated -> t val child : Module . normalized -> string -> Desc . Type . t option -> Desc . deprecated -> t val declare : Origin . t -> Ident . t -> t val declaration : t -> Origin . t option val origin : Graph . t -> ...
module Printer = struct type ' a t = Format . formatter -> ' a -> unit end
module Printers = Vector ( Printer )
module PrinterSequence = Sequence ( Printers . T )
type ( ' a , ' arity , ' b ) typed_attribute_kind += | Attribute_printer : ( ' a , ' arity , ' a Printer . t ) typed_attribute_kind | Attribute_polyprinter : ( ' a , ' arity , ' arity PrinterSequence . t -> ' a Printer . t ) typed_attribute_kind
type ' kinds value = | Value : { desc : ( ' a , ' structure , ' arity , ' rec_group , ' kinds , ' positive , ' negative , ' direct , ' gadt ) desc ; value : ' a ; printers : ( ' arity , ' direct ) Printers . t ; } -> ' kinds value
let rec pp : type a structure arity rec_group positive negative direct gadt . ( a , structure , arity , rec_group , ' kinds , positive , negative , direct , gadt ) desc -> ( arity , direct ) Printers . t -> a Printer . t = let pp_tuple printers tuple = let pp_tuple_item ( Tuple . Fold { desc ; value ; _ } ) comma = if ...
let show desc printers x = Format . asprintf " % a " ( pp desc printers ) x
let half_ball_radius = ball_radius / 2
let xc x = truncate ( x . * scale ) + x_off
let yc y = truncate ( y . * scale ) + y_off
let floors = ref ( [ | 0 . 0 ] , | [ | 0 . 0 ] ) |
let show_floors ( ) = let ( heights , extents ) = ! floors in let maxidx = min ( Array . length heights ) ( Array . length extents ) in let rec f idx = if ( idx < maxidx ) then ( Graphics . lineto ( Graphics . current_x ( ) ) ( yc heights . ( idx ) ) ; Graphics . lineto ( xc extents . ( idx ) ) ( yc heights . ( idx ) )...
let leave_trace = ref false
let start trace floor_details = Graphics . open_graph " " ; Graphics . resize_window 800 600 ; Graphics . clear_graph ( ) ; floors := floor_details ; show_floors ( ) ; leave_trace := trace
let show last_x last_y x y = if ( not ! leave_trace ) then begin Graphics . set_color Graphics . background ; Graphics . fill_circle ( xc last_x ) ( yc last_y + half_ball_radius ) ball_radius ; show_floors ( ) end ; Graphics . set_color Graphics . red ; Graphics . fill_circle ( xc x ) ( yc y + half_ball_radius ) ball_r...
let stop ( ) = ignore ( Graphics . read_key ( ) ) ; Graphics . close_graph ( ) and printf = Printf . printf in printf ( " \ nFinal Statistics :\ n " ) ; printf " nst = %- 6ld nfe = %- 6ld nsetups = %- 6ld nfeLS = %- 6ld nje = % ld \ n " in_stats . steps in_stats . rhs_evals in_stats . linear_solver_setups ls_stats . rh...
let half_box_size = box_size / 2
let scale = float_of_int height
let x_off = ( width / 2 ) - half_box_size
let hc h = truncate ( h . * scale ) - half_box_size + y_off
let clear ( ) = Graphics . fill_rect 0 0 width height
let start ( ) = Graphics . open_graph " " ; Graphics . resize_window width height ; clear ( )
let draw_box color h = Graphics . set_color color ; Graphics . fill_rect x_off ( hc h ) box_size box_size
let draw_gravity color = Graphics . set_color color ; Graphics . fill_rect 0 0 width 5
let show ( on , last_h1 , last_h2 , h1 , h2 ) = draw_gravity ( if on then Graphics . yellow else background ) ; draw_box background last_h1 ; draw_box background last_h2 ; draw_box Graphics . green h1 ; draw_box Graphics . red h2
let input ( ) = let rec myread v = if not ( Graphics . key_pressed ( ) ) then v else myread ( Some ( Graphics . read_key ( ) ) ) in match myread None with | Some _ -> true | _ -> false
let stop ( ) = ignore ( Graphics . read_key ( ) ) ; Graphics . close_graph ( )
let _ = start ( )
let usage = " Usage : " ^ ( Filename . basename Sys . executable_name ) ^ " [ - solid ] [ - b |- i |- u ] font . ttf [ ptsize ] [ text ] \ n "
let default_text = " The quick brown fox jumps over the lazy dog "
let solid = ref false
let style = ref [ ]
let set_style s ( ) = style := s :: ! style
let spec = [ " - solid " , Arg . Set solid , " render solid " ; " - b " , Arg . Unit ( set_style Sdlttf . BOLD ) , " bold font style " ; " - i " , Arg . Unit ( set_style Sdlttf . ITALIC ) , " italic font style " ; " - u " , Arg . Unit ( set_style Sdlttf . UNDERLINE ) , " underline font style " ]
let usage_error ( ) = Arg . usage spec usage ; exit 1
let initialize file ptsize message = Sdl . init [ ` VIDEO ] ; let screen = set_video_mode ~ w : 640 ~ h : 480 [ ] in fill_rect screen ( map_RGB screen white ) ; update_rect screen ; Sdlttf . init ( ) ; let font = Sdlttf . open_font file ptsize in if ! style <> [ ] then Sdlttf . set_font_style font ! style ; let render ...
let event_loop blit_text = while true do match wait_event ( ) with | MOUSEBUTTONDOWN { mbe_x = x ; mbe_y = y } -> blit_text x y | KEYDOWN _ | QUIT -> Sdl . quit ( ) ; exit 0 | _ -> ( ) done
let showfont file points message = let ptsize = try int_of_string points with Failure " int_of_string " -> usage_error ( ) in event_loop ( initialize file ptsize message )
let main ( ) = let args = ref [ ] in let anon arg = args := ! args @ [ arg ] in Arg . parse spec anon usage ; let ( file , points , message ) = match ! args with | [ file ] -> ( file , default_ptsize , default_text ) | [ file ; points ] -> ( file , points , default_text ) | [ file ; points ; message ] -> ( file , point...
let _ = main ( )
let scale = ref 1 . 0
let obstacle = ref [ ] ||
let pivot = ref ( 400 , 480 )
let xc x = truncate ( x . * ! scale ) + fst ! pivot
let yc y = truncate ( y . * ! scale ) + snd ! pivot
let show_objects ( ) = Graphics . set_color Graphics . blue ; Graphics . fill_poly ! obstacle ; Graphics . set_color Graphics . black ; Graphics . fill_circle ( fst ! pivot ) ( snd ! pivot ) ( ball_radius / 2 )