Showing preview only (533K chars total). Download the full file or copy to clipboard to get everything.
Repository: realworldocaml/examples
Branch: master
Commit: 32ea926861a0
Files: 597
Total size: 412.3 KB
Directory structure:
gitextract_jkpspzh6/
├── .gitignore
├── INSTALL.sh
├── Makefile
├── README.md
├── UNLICENSE
└── code/
├── Makefile
├── async/
│ ├── #build_other_searches.sh#
│ ├── #main.topscript#
│ ├── better_echo.ml
│ ├── build_echo.sh
│ ├── build_other_searches.sh
│ ├── echo.ml
│ ├── main-35.rawscript
│ ├── main-38.rawscript
│ ├── main-44.rawscript
│ ├── main-45.rawscript
│ ├── main-46.rawscript
│ ├── main-47.rawscript
│ ├── main.topscript
│ ├── native_code_log_delays.ml
│ ├── pipe_write_break.rawscript
│ ├── pipe_write_break.rawtopscript
│ ├── run_echo.rawsh
│ ├── run_native_code_log_delays.rawsh
│ ├── run_native_code_log_delays_orig.sh
│ ├── run_search.rawsh
│ ├── run_search_orig.sh
│ ├── run_search_with_configurable_server.rawsh
│ ├── run_search_with_configurable_server_orig.errsh
│ ├── run_search_with_error_handling.rawsh
│ ├── run_search_with_error_handling_orig.sh
│ ├── run_search_with_timeout_no_leak.rawsh
│ ├── run_search_with_timeout_no_leak_orig.sh
│ ├── run_thread.sh
│ ├── search.ml
│ ├── search_out_of_order.ml
│ ├── search_with_configurable_server.ml
│ ├── search_with_error_handling.ml
│ ├── search_with_error_handling_deprecated.ml
│ ├── search_with_timeout.ml
│ ├── search_with_timeout_choice.ml
│ ├── search_with_timeout_no_leak.ml
│ ├── search_with_timeout_no_leak_simple.ml
│ ├── search_with_timeout_simple.ml
│ ├── test.txt
│ ├── thread_exp_async_busy_loop.ml
│ ├── thread_exp_async_busy_loop_in_thread.ml
│ ├── thread_exp_async_noalloc_busy_loop.ml
│ ├── thread_exp_async_noalloc_busy_loop_in_thread.ml
│ ├── thread_exp_async_only.ml
│ ├── thread_exp_common.ml
│ ├── thread_experiments.ml
│ └── timeout_search.ml
├── back-end/
│ ├── alternate_list.ml
│ ├── asm_from_compare_mono.sh
│ ├── cmp.S
│ ├── compare_mono.ml
│ ├── compare_mono.s
│ ├── compare_poly.ml
│ ├── compare_poly_asm.S
│ ├── gdb_alternate0.rawsh
│ ├── gdb_alternate1.rawsh
│ ├── gdb_alternate2.rawsh
│ ├── gdb_alternate3.rawsh
│ ├── instr_for_pattern_monomorphic_small.sh
│ ├── lambda_for_pattern_monomorphic_large.sh
│ ├── lambda_for_pattern_monomorphic_small.sh
│ ├── lambda_for_pattern_polymorphic.sh
│ ├── opam_switch.rawsh
│ ├── pattern_monomorphic_large.ml
│ ├── pattern_monomorphic_small.ml
│ ├── pattern_polymorphic.ml
│ ├── perf_record.rawsh
│ └── perf_report.rawsh
├── back-end-bench/
│ ├── bench_patterns.ml
│ ├── bench_poly_and_mono.ml
│ ├── run_alternate_list.sh
│ ├── run_bench_patterns.sh
│ └── run_bench_poly_and_mono.sh
├── back-end-embed/
│ ├── build_embed.sh
│ ├── build_embed_binary.rawsh
│ ├── build_embed_c.sh
│ ├── build_embed_native.rawsh
│ ├── embed_me1.ml
│ ├── embed_me2.ml
│ ├── embed_out.c
│ ├── hello.ml
│ ├── link_custom.rawsh
│ ├── link_dllib.rawsh
│ ├── main.c
│ ├── run_debug_hello.sh
│ ├── xbuild_embed_binary.sh
│ └── xbuild_embed_native.sh
├── classes/
│ ├── Iterator.java
│ ├── binary.topscript
│ ├── binary_larger.ml
│ ├── binary_module.ml
│ ├── build_doc.sh
│ ├── citerator.cpp
│ ├── class_types_stack.ml
│ ├── doc.ml
│ ├── initializer.topscript
│ ├── istack.topscript
│ ├── iter.topscript
│ └── stack.topscript
├── classes-async/
│ ├── build_shapes.sh
│ ├── multiple_inheritance.ml
│ ├── multiple_inheritance_wrong.ml
│ ├── shapes.ml
│ └── verbose_shapes.ml
├── command-line-parsing/
│ ├── _tags
│ ├── basic.topscript
│ ├── basic_md5.ml
│ ├── basic_md5_as_filename.ml
│ ├── basic_md5_sequence.ml
│ ├── basic_md5_succinct.ml
│ ├── basic_md5_with_custom_arg.ml
│ ├── basic_md5_with_default_file.ml
│ ├── basic_md5_with_flags.ml
│ ├── basic_md5_with_opt_flags.ml
│ ├── basic_md5_with_optional_file.ml
│ ├── basic_md5_with_optional_file_broken.ml
│ ├── build_and_run_cal_add_interactive.rawsh
│ ├── build_basic_md5.sh
│ ├── build_basic_md5_as_filename.sh
│ ├── build_basic_md5_sequence.sh
│ ├── build_basic_md5_with_custom_arg.sh
│ ├── build_basic_md5_with_default_file.sh
│ ├── build_basic_md5_with_flags.sh
│ ├── build_basic_md5_with_opt_flags.sh
│ ├── build_basic_md5_with_optional_file.sh
│ ├── build_basic_md5_with_optional_file_broken.errsh
│ ├── build_cal_add_days.sh
│ ├── build_cal_add_sub_days.sh
│ ├── build_cal_append.sh
│ ├── build_cal_append_broken.errsh
│ ├── cal.cmd
│ ├── cal_add_days.ml
│ ├── cal_add_interactive.ml
│ ├── cal_add_labels.ml
│ ├── cal_add_sub_days.ml
│ ├── cal_append.ml
│ ├── cal_append_broken.ml
│ ├── cal_completion.rawsh
│ ├── command_types.topscript
│ ├── get_basic_md5_help.errsh
│ ├── get_basic_md5_version.sh
│ ├── group.topscript
│ ├── md5_completion.sh
│ ├── opam.rawsh
│ ├── run_basic_and_default_md5.sh
│ ├── run_basic_md5.sh
│ ├── run_basic_md5_as_filename.errsh
│ ├── run_basic_md5_flags_help.sh
│ ├── run_basic_md5_with_custom_arg.errsh
│ ├── run_cal_add_sub_days.sh
│ ├── single_anon_filename.topscript
│ └── step.topscript
├── corebuild
├── ctypes/
│ ├── ctypes.mli
│ └── ctypes_impl.ml
├── error-handling/
│ ├── blow_up.ml
│ ├── build_blow_up.errsh
│ ├── build_blow_up_notrace.errsh
│ ├── exn_cost.ml
│ ├── main.topscript
│ ├── result.ml
│ ├── result.mli
│ ├── run_exn_cost.sh
│ ├── run_exn_cost_notrace.sh
│ ├── sexpr.scm
│ └── try_with.syntax
├── exec_script.sh
├── exec_topscript.sh
├── fcm/
│ ├── build_query_handler.sh
│ ├── build_query_handler_loader.sh
│ ├── fcm.syntax
│ ├── loader_cli1.rawsh
│ ├── loader_cli2.rawsh
│ ├── loader_cli3.rawsh
│ ├── loader_cli4.rawsh
│ ├── main.topscript
│ ├── pack.syntax
│ ├── query-syntax.scm
│ ├── query_example.rawscript
│ ├── query_handler.ml
│ ├── query_handler.topscript
│ ├── query_handler_core.ml
│ ├── query_handler_loader.ml
│ └── unpack.syntax
├── ffi/
│ ├── build_datetime.sh
│ ├── build_hello.sh
│ ├── build_qsort.sh
│ ├── datetime.ml
│ ├── hello.ml
│ ├── infer_ncurses.sh
│ ├── input.txt
│ ├── install.rawsh
│ ├── ncurses.h
│ ├── ncurses.inferred.mli
│ ├── ncurses.ml
│ ├── ncurses.mli
│ ├── posix.topscript
│ ├── posix_headers.h
│ ├── qsort.h
│ ├── qsort.ml
│ ├── qsort.mli
│ ├── qsort.topscript
│ ├── qsort_typedef.h
│ ├── return_c_frag.c
│ ├── return_c_frag.h
│ ├── return_c_uncurried.c
│ ├── return_frag.ml
│ └── timeval_headers.h
├── files-modules-and-programs/
│ ├── abstract_username.ml
│ ├── build_session_info.errsh
│ ├── common.ml
│ ├── confusing_username_and_host.ml
│ ├── ext_list.ml
│ ├── ext_list.mli
│ ├── freq.ml
│ ├── intro.topscript
│ ├── main.topscript
│ ├── module.syntax
│ ├── session_info.ml
│ └── val.syntax
├── files-modules-and-programs-freq/
│ ├── freq.ml
│ ├── simple_build.sh
│ └── simple_build_fail.errsh
├── files-modules-and-programs-freq-cyclic1/
│ ├── build.errsh
│ ├── counter.ml
│ ├── counter.mli
│ └── freq.ml
├── files-modules-and-programs-freq-cyclic2/
│ ├── build.errsh
│ ├── counter.ml
│ ├── counter.mli
│ └── freq.ml
├── files-modules-and-programs-freq-fast/
│ ├── build.sh
│ ├── counter.ml
│ ├── counter.mli
│ └── freq.ml
├── files-modules-and-programs-freq-median/
│ ├── build.sh
│ ├── build_use_median.sh
│ ├── counter.ml
│ ├── counter.mli
│ ├── freq.ml
│ ├── use_median_1.ml
│ └── use_median_2.ml
├── files-modules-and-programs-freq-obuild/
│ ├── build.sh
│ └── test.sh
├── files-modules-and-programs-freq-with-counter/
│ ├── build.sh
│ ├── counter.ml
│ ├── freq.ml
│ └── infer_mli.sh
├── files-modules-and-programs-freq-with-missing-def/
│ ├── build.errsh
│ ├── counter.ml
│ ├── counter.mli
│ └── freq.ml
├── files-modules-and-programs-freq-with-sig/
│ ├── build.sh
│ ├── counter.ml
│ ├── counter.mli
│ └── freq.ml
├── files-modules-and-programs-freq-with-sig-abstract/
│ ├── build.errsh
│ ├── counter.ml
│ ├── counter.mli
│ └── freq.ml
├── files-modules-and-programs-freq-with-sig-abstract-fixed/
│ ├── build.sh
│ ├── counter.ml
│ ├── counter.mli
│ └── freq.ml
├── files-modules-and-programs-freq-with-sig-mismatch/
│ ├── build.errsh
│ ├── counter.ml
│ ├── counter.mli
│ └── freq.ml
├── files-modules-and-programs-freq-with-type-mismatch/
│ ├── build.errsh
│ ├── counter.ml
│ ├── counter.mli
│ └── freq.ml
├── front-end/
│ ├── alice.ml
│ ├── alice.mli
│ ├── alice_combined.ml
│ ├── broken_module.ml
│ ├── broken_poly.ml
│ ├── broken_poly_with_annot.ml
│ ├── build_broken_module.errsh
│ ├── build_broken_poly.errsh
│ ├── build_broken_poly_with_annot.errsh
│ ├── build_follow_on_function.errsh
│ ├── build_non_principal.sh
│ ├── build_ocamldoc.rawsh
│ ├── build_principal.sh
│ ├── build_type_conv_with_camlp4.rawsh
│ ├── build_type_conv_without_camlp4.errsh
│ ├── camlp4_dump.cmd
│ ├── camlp4_toplevel.topscript
│ ├── comparelib_test.ml
│ ├── comparelib_test.mli
│ ├── conflicting_interfaces.errsh
│ ├── doc.ml
│ ├── fixed_module.ml
│ ├── follow_on_function.ml
│ ├── follow_on_function_fixed.ml
│ ├── html/
│ │ ├── Doc.html
│ │ ├── index.html
│ │ ├── index_attributes.html
│ │ ├── index_class_types.html
│ │ ├── index_classes.html
│ │ ├── index_exceptions.html
│ │ ├── index_methods.html
│ │ ├── index_module_types.html
│ │ ├── index_modules.html
│ │ ├── index_types.html
│ │ ├── index_values.html
│ │ ├── style.css
│ │ └── type_Doc.html
│ ├── inconsistent_compilation_units.rawsh
│ ├── indent_follow_on_function.sh
│ ├── indent_follow_on_function_fixed.sh
│ ├── infer_typedef.sh
│ ├── install_ocp_index.rawsh
│ ├── let_notunit.ml
│ ├── let_unit.syntax
│ ├── man/
│ │ └── man3/
│ │ ├── Doc.3o
│ │ ├── My_exception.3o
│ │ ├── Rain.3o
│ │ ├── Sun.3o
│ │ ├── weather.3o
│ │ └── what_is_the_weather_in.3o
│ ├── non_principal.ml
│ ├── parsetree_typedef.sh
│ ├── pipeline.ascii
│ ├── principal.ml
│ ├── process_comparelib_interface.sh
│ ├── process_comparelib_test.sh
│ ├── short_paths_1.rawsh
│ ├── short_paths_2.rawsh
│ ├── short_paths_3.rawsh
│ ├── test.ml
│ ├── test.mli
│ ├── type_conv_example.ml
│ ├── typedef.ml
│ ├── typedef_objinfo.sh
│ ├── typedtree_typedef.sh
│ ├── unused_var.ml
│ └── xbuild_type_conv_with_camlp4.sh
├── functors/
│ ├── build_extended_fqueue.sh
│ ├── build_fqueue.sh
│ ├── compare_example.ml
│ ├── destructive_sub.syntax
│ ├── extended_fqueue.ml
│ ├── extended_fqueue.mli
│ ├── foldable.ml
│ ├── fqueue.ml
│ ├── fqueue.mli
│ ├── main-15.rawscript
│ ├── main-18.rawscript
│ ├── main-21.rawscript
│ ├── main-25.rawscript
│ ├── main.topscript
│ ├── multi_sharing_constraint.syntax
│ ├── sexpable.ml
│ └── sharing_constraint.syntax
├── gc/
│ ├── barrier_bench.ml
│ ├── finalizer.ml
│ ├── minor_heap.ascii
│ ├── run_barrier_bench.sh
│ ├── run_finalizer.sh
│ ├── show_barrier_bench_help.sh
│ └── tune.topscript
├── guided-tour/
│ ├── build_sum.sh
│ ├── local_let.topscript
│ ├── main.topscript
│ ├── recursion.ml
│ ├── run_sum.sh
│ ├── sum.ml
│ └── sum.rawsh
├── imperative-programming/
│ ├── .gitignore
│ ├── array-get.syntax
│ ├── array-set.syntax
│ ├── bigarray.syntax
│ ├── build_all.sh
│ ├── dictionary.ml
│ ├── dictionary.mli
│ ├── dictionary2.ml
│ ├── dlist.ml
│ ├── dlist.mli
│ ├── edit_distance.ascii
│ ├── edit_distance2.ascii
│ ├── examples.topscript
│ ├── fib.topscript
│ ├── file.topscript
│ ├── file2.topscript
│ ├── for.topscript
│ ├── lazy.topscript
│ ├── let-unit.syntax
│ ├── let_rec.ml
│ ├── letrec.topscript
│ ├── memo.topscript
│ ├── order.topscript
│ ├── printf.topscript
│ ├── ref.topscript
│ ├── remember_type.ml
│ ├── semicolon-syntax.syntax
│ ├── semicolon.syntax
│ ├── string.syntax
│ ├── time_converter.ml
│ ├── time_converter.rawsh
│ ├── time_converter2.ml
│ ├── time_converter2.rawsh
│ ├── value_restriction-13.rawscript
│ ├── value_restriction.topscript
│ └── weak.topscript
├── installation/
│ ├── arch_install.rawsh
│ ├── arch_opam.rawsh
│ ├── brew_install.rawsh
│ ├── brew_opam_install.rawsh
│ ├── debian_apt.rawsh
│ ├── debian_apt_opam.rawsh
│ ├── emacsrc.scm
│ ├── fedora_install.rawsh
│ ├── macports_install.rawsh
│ ├── macports_opam_install.rawsh
│ ├── ocaml_src_install.rawsh
│ ├── ocaml_user_conf.rawsh
│ ├── opam_eval.rawsh
│ ├── opam_init.rawsh
│ ├── opam_install.rawsh
│ ├── opam_install_utop.rawsh
│ ├── opam_list.rawsh
│ ├── opam_switch.rawsh
│ ├── open_core.ml
│ ├── show_ocamlinit.rawsh
│ └── ubuntu_opam_ppa.rawsh
├── json/
│ ├── _tags
│ ├── book.json
│ ├── build_github_atd.sh
│ ├── build_github_org.sh
│ ├── build_json.topscript
│ ├── generate_github_org_json.sh
│ ├── generate_github_org_types.sh
│ ├── github.atd
│ ├── github_j.ml
│ ├── github_j.mli
│ ├── github_j_excerpt.mli
│ ├── github_org.atd
│ ├── github_org_info.ml
│ ├── github_org_j.ml
│ ├── github_org_j.mli
│ ├── github_org_t.ml
│ ├── github_org_t.mli
│ ├── github_t.ml
│ ├── github_t.mli
│ ├── install.topscript
│ ├── install_atdgen.rawsh
│ ├── list_excerpt.mli
│ ├── parse_book.ml
│ ├── parse_book.topscript
│ ├── read_json.ml
│ ├── run_github_org.sh
│ ├── run_parse_book.sh
│ ├── run_read_json.sh
│ ├── yojson_basic.mli
│ ├── yojson_basic_simple.mli
│ └── yojson_safe.mli
├── lists-and-patterns/
│ ├── example.ml
│ ├── example.mli
│ ├── lists_layout.ascii
│ └── main.topscript
├── maps-and-hash-tables/
│ ├── comparable.ml
│ ├── core_phys_equal.topscript
│ ├── main-22.rawscript
│ ├── main-23.rawscript
│ ├── main-24.rawscript
│ ├── main-30.rawscript
│ ├── main.topscript
│ ├── map_vs_hash.ml
│ ├── map_vs_hash2.ml
│ ├── phys_equal.rawscript
│ ├── run_map_vs_hash.sh
│ └── run_map_vs_hash2.sh
├── memory-repr/
│ ├── block.ascii
│ ├── custom_ops.c
│ ├── float_array_layout.ascii
│ ├── reprs.topscript
│ ├── simple_record.topscript
│ ├── string_block.ascii
│ ├── string_size_calc.ascii
│ └── tuple_layout.ascii
├── objects/
│ ├── IsBarbell.java
│ ├── Shape.java
│ ├── immutable.topscript
│ ├── is_barbell.ml
│ ├── narrowing.ml
│ ├── polymorphism.topscript
│ ├── row_polymorphism.topscript
│ ├── stack.topscript
│ ├── subtyping.ml
│ └── subtyping.topscript
├── ocp-index/
│ └── index_ncurses.sh
├── packing/
│ ├── A.ml
│ ├── B.ml
│ ├── X.mlpack
│ ├── _tags
│ ├── build_test.sh
│ ├── show_files.sh
│ └── test.ml
├── parsing/
│ ├── basic_parser.mly
│ ├── build_short_parser.sh
│ ├── example.json
│ ├── json.ml
│ ├── lex.syntax
│ ├── lexer.mll
│ ├── lexer_int_fragment.mll
│ ├── manual_token_type.ml
│ ├── parsed_example.ml
│ ├── parser.mly
│ ├── production.syntax
│ ├── prog.mli
│ ├── quadratic_rule.mly
│ ├── right_rec_rule.mly
│ ├── short_parser.mly
│ ├── tokenized_example.ml
│ ├── tokens.ml
│ └── yacc.syntax
├── parsing-test/
│ ├── build_json_parser.sh
│ ├── build_test.sh
│ ├── run_broken_test.errsh
│ ├── test.ml
│ ├── test1.json
│ └── test2.json
├── principal/
│ └── build_principal.sh
├── records/
│ ├── functional_update.syntax
│ ├── main-29.rawscript
│ ├── main.topscript
│ ├── record.syntax
│ └── warn_help.sh
├── sexpr/
│ ├── auto_making_sexp.topscript
│ ├── basic.scm
│ ├── build_read_foo.errsh
│ ├── build_read_foo_better_errors.errsh
│ ├── build_test_interval.sh
│ ├── build_test_interval_manual_sexp.sh
│ ├── build_test_interval_nosexp.errsh
│ ├── comment_heavy.scm
│ ├── example.scm
│ ├── example_broken.scm
│ ├── example_load.topscript
│ ├── foo_broken_example.scm
│ ├── inline_sexp.topscript
│ ├── int_interval.ml
│ ├── int_interval.mli
│ ├── int_interval_manual_sexp.ml
│ ├── int_interval_manual_sexp.mli
│ ├── int_interval_nosexp.ml
│ ├── int_interval_nosexp.mli
│ ├── list_top_packages.sh
│ ├── manually_making_sexp.topscript
│ ├── print_sexp.topscript
│ ├── read_foo.ml
│ ├── read_foo_better_errors.ml
│ ├── sexp.mli
│ ├── sexp_default.topscript
│ ├── sexp_list.topscript
│ ├── sexp_opaque.topscript
│ ├── sexp_option.topscript
│ ├── sexp_override.ml
│ ├── sexp_printer.topscript
│ ├── test_interval.ml
│ ├── test_interval_manual_sexp.ml
│ ├── test_interval_nosexp.ml
│ └── to_from_sexp.topscript
├── variables-and-functions/
│ ├── abs_diff.mli
│ ├── htable_sig1.ml
│ ├── htable_sig2.ml
│ ├── let.syntax
│ ├── let_in.syntax
│ ├── main.topscript
│ ├── numerical_deriv_alt_sig.mli
│ ├── operators.syntax
│ ├── substring_sig1.ml
│ └── substring_sig2.ml
├── variants/
│ ├── blang.topscript
│ ├── catch_all.topscript
│ ├── logger.topscript
│ ├── main-2.rawscript
│ ├── main-5.rawscript
│ ├── main.topscript
│ └── variant.syntax
├── variants-termcol/
│ ├── build.sh
│ ├── terminal_color.ml
│ └── terminal_color.mli
├── variants-termcol-annotated/
│ ├── build.errsh
│ ├── terminal_color.ml
│ └── terminal_color.mli
└── variants-termcol-fixed/
├── build.sh
├── terminal_color.ml
└── terminal_color.mli
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
*.out
*.out.full
*.a
a.out
.*.swp
*.aux
*.aux
*.byte
*.cmo
*.cmi
*.cmx
*.cmxa
*.cma
*.idx
*.log
*.native
*.byte
*.o
*.omakedb.lock
*.omc
*.tmp
*.toc
*~
.*.swp
.DS_Store
.bzr
.bzrignore
.project
.pydevproject
.settings
/commenting-build
_build
================================================
FILE: INSTALL.sh
================================================
#!/bin/sh
opam install -j 4 --yes \
core \
core_extended \
cryptokit \
core_bench \
atdgen \
async \
yojson \
textwrap \
cohttp \
async_graphics \
menhir \
utop \
cmdliner \
cow \
ocp-indent \
ctypes \
ocp-index
echo You also need Pygments installed.
echo This is python-pygments in Debian
================================================
FILE: Makefile
================================================
.PHONY: all depend clean distclean
all:
cd code && $(MAKE) -j1
depend:
./INSTALL.sh
clean:
rm -rf scripts/_build
cd code && $(MAKE) clean
distclean: clean
cd code && $(MAKE) distclean
================================================
FILE: README.md
================================================
This repository contains all the code samples from Real World OCaml. The
repository tags represent a particular release of the book.
================================================
FILE: UNLICENSE
================================================
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
================================================
FILE: code/Makefile
================================================
#OCAMLPARAM=_,we=+A
#export OCAMLPARAM
dirs= json \
command-line-parsing guided-tour \
variables-and-functions \
lists-and-patterns \
sexpr \
parsing \
parsing-test \
maps-and-hash-tables \
files-modules-and-programs \
files-modules-and-programs-freq \
files-modules-and-programs-freq-obuild \
files-modules-and-programs-freq-with-counter \
files-modules-and-programs-freq-with-sig \
files-modules-and-programs-freq-with-sig-abstract \
files-modules-and-programs-freq-with-sig-abstract-fixed \
files-modules-and-programs-freq-fast \
files-modules-and-programs-freq-median \
files-modules-and-programs-freq-with-sig-mismatch \
files-modules-and-programs-freq-with-missing-def \
files-modules-and-programs-freq-with-type-mismatch \
files-modules-and-programs-freq-cyclic1 \
files-modules-and-programs-freq-cyclic2 \
records \
variants \
variants-termcol \
variants-termcol-annotated \
variants-termcol-fixed \
objects \
classes \
classes-async \
imperative-programming \
error-handling \
memory-repr \
gc \
front-end \
packing \
principal \
back-end \
back-end-bench \
back-end-embed \
functors \
fcm \
async \
ffi \
ctypes \
ocp-index \
installation
# html/xml files directory
OBJ= _build
# All the source files
ml_src= $(wildcard $(dirs:%=%/*.ml))
mli_src= $(wildcard $(dirs:%=%/*.mli))
mll_src= $(wildcard $(dirs:%=%/*.mll))
mly_src= $(wildcard $(dirs:%=%/*.mly))
json_src= $(wildcard $(dirs:%=%/*.json))
java_src= $(wildcard $(dirs:%=%/*.java))
c_src= $(wildcard $(dirs:%=%/*.c))
h_src= $(wildcard $(dirs:%=%/*.h))
asm_src= $(wildcard $(dirs:%=%/*.S))
cmd_src= $(wildcard $(dirs:%=%/*.cmd))
cpp_src= $(wildcard $(dirs:%=%/*.cpp))
atd_src= $(wildcard $(dirs:%=%/*.atd))
scm_src= $(wildcard $(dirs:%=%/*.scm))
syn_src= $(wildcard $(dirs:%=%/*.syntax))
ascii_src= $(wildcard $(dirs:%=%/*.ascii))
scripts= $(wildcard $(dirs:%=%/*.sh))
rawscripts= $(wildcard $(dirs:%=%/*.rawsh))
errscripts= $(wildcard $(dirs:%=%/*.errsh))
topscripts= $(wildcard $(dirs:%=%/*.topscript))
rawtscripts= $(wildcard $(dirs:%=%/*.rawscript))
all_src= $(ml_src) $(mli_src) $(json_src) $(java_src) $(c_src) \
$(cmd_src) $(cpp_src) $(atd_src) $(scm_src) $(syn_src) \
$(ascii_src) $(asm_src) $(mll_src) $(mly_src) $(h_src)
all_scripts= $(scripts:%.sh=%.out) $(errscripts:%.errsh=%.out) \
$(topscripts) $(rawtscripts) $(rawscripts:%.rawsh=%.out)
# The source files all map to %.<part>.html and %.<part>.xml
all_src_html= $(all_src:%=$(OBJ)/%.0.html) $(all_scripts:%=$(OBJ)/%.0.html)
all_src_md= $(all_src:%=$(OBJ)/%.0.xml) $(all_scripts:%=$(OBJ)/%.0.xml)
# Binaries we run
runtop= rwo-run-toplevel
highlight= rwo-syntax-highlight
.PHONY: all
all: $(all_src_html) $(all_src_md)
@ :
print-%:
@echo $($*)
json/run_github_org.out:: json/build_github_org.out
command-line-parsing/run_basic_md5.out:: command-line-parsing/build_basic_md5.out
command-line-parsing/get_basic_md5_version.out:: command-line-parsing/build_basic_md5.out
command-line-parsing/run_basic_and_default_md5.out:: command-line-parsing/build_basic_md5_with_optional_file.out command-line-parsing/build_basic_md5_with_default_file.out
command-line-parsing/run_cal_add_sub_days.out:: command-line-parsing/build_cal_add_sub_days.out
command-line-parsing/md5_completion.out:: command-line-parsing/build_basic_md5_with_flags.out
command-line-parsing/cal_completion.out:: command-line-parsing/build_cal_add_sub_days.out
parsing-test/run_broken_test.out:: parsing-test/build_test.out
$(OBJ)/%.mli.0.html $(OBJ)/%.mli.0.xml: %.mli
@mkdir -p $(@D)
$(highlight) -builddir $(OBJ) -cow $< || (cat $@ && rm -f $@)
$(OBJ)/%.ml.0.html $(OBJ)/%.ml.0.xml: %.ml
@mkdir -p $(@D)
$(highlight) -builddir $(OBJ) -cow $< || (cat $@ && rm -f $@)
$(OBJ)/%.mll.0.html $(OBJ)/%.mll.0.xml: %.mll
@mkdir -p $(@D)
$(highlight) -builddir $(OBJ) -cow $< || (cat $@ && rm -f $@)
$(OBJ)/%.mly.0.html $(OBJ)/%.mly.0.xml: %.mly
@mkdir -p $(@D)
$(highlight) -builddir $(OBJ) -cow $< || (cat $@ && rm -f $@)
$(OBJ)/%.json.0.html $(OBJ)/%.json.0.xml: %.json
@mkdir -p $(@D)
$(highlight) -builddir $(OBJ) -pygments json $< || (cat $@ && rm -f $@)
$(OBJ)/%.syntax.0.html $(OBJ)/%.syntax.0.xml: %.syntax
@mkdir -p $(@D)
$(highlight) -builddir $(OBJ) -raw ocamlsyntax $< || (cat $@ && rm -f $@)
$(OBJ)/%.cmd.0.html $(OBJ)/%.cmd.0.xml: %.cmd
@mkdir -p $(@D)
$(highlight) -builddir $(OBJ) -pygments bash $< || (cat $@ && rm -f $@)
$(OBJ)/%.atd.0.html $(OBJ)/%.atd.0.xml: %.atd
@mkdir -p $(@D)
$(highlight) -builddir $(OBJ) -cow $< || (cat $@ && rm -f $@)
$(OBJ)/%.ascii.0.html $(OBJ)/%.ascii.0.xml: %.ascii
@mkdir -p $(@D)
$(highlight) -builddir $(OBJ) -raw ascii $< || (cat $@ && rm -f $@)
$(OBJ)/%.java.0.html $(OBJ)/%.java.0.xml: %.java
@mkdir -p $(@D)
$(highlight) -builddir $(OBJ) -pygments java $< || (cat $@ && rm -f $@)
$(OBJ)/%.S.0.html $(OBJ)/%.S.0.xml: %.S
@mkdir -p $(@D)
$(highlight) -builddir $(OBJ) -pygments gas $< || (cat $@ && rm -f $@)
$(OBJ)/%.c.0.html $(OBJ)/%.c.0.xml: %.c
@mkdir -p $(@D)
$(highlight) -builddir $(OBJ) -pygments c $< || (cat $@ && rm -f $@)
$(OBJ)/%.h.0.html $(OBJ)/%.h.0.xml: %.h
@mkdir -p $(@D)
$(highlight) -builddir $(OBJ) -pygments c $< || (cat $@ && rm -f $@)
$(OBJ)/%.cpp.0.html $(OBJ)/%.cpp.0.xml: %.cpp
@mkdir -p $(@D)
$(highlight) -builddir $(OBJ) -pygments cpp $< || (cat $@ && rm -f $@)
$(OBJ)/%.scm.0.html $(OBJ)/%.scm.0.xml: %.scm
@mkdir -p $(@D)
$(highlight) -builddir $(OBJ) -pygments scheme $< || (cat $@ && rm -f $@)
$(OBJ)/%.topscript.0.xml $(OBJ)/%.topscript.0.html: %.topscript
@mkdir -p $(@D)
cd $(*D) && $(runtop) $(*F).topscript -fullfile "$<" -builddir "../$(@D)"
$(OBJ)/%.rawscript.0.xml $(OBJ)/%.rawscript.0.html: %.rawscript
@mkdir -p $(@D)
$(highlight) -builddir $(OBJ) -rawscript $<
$(OBJ)/%.out.0.html $(OBJ)/%.out.0.xml: %.out
@mkdir -p $(@D)
$(highlight) -builddir $(OBJ) -console $<
# The outputs of the shell scripts should be checked in.
%.out.full: %.sh
./exec_script.sh $< > $@ 2>&1 || (cat $@ && rm -f $@)
%.out: %.out.full
egrep -v '(^ocamlfind |^\+|^menhir --|added to search path$$)' < $< > $@
%.out.full: %.errsh
! ./exec_script.sh $< > $@ 2>&1 || (cat $@ && rm -f $@)
%.out: %.rawsh
cp $< $@
clean:
find . -name \*.out | xargs rm -f
rm -rf $(OBJ)
clean-%:
find $* -name \*.out | xargs rm -f
rm -rf $*/_build
rm -rf _build/$*
distclean:
for i in $(dirs); do $(MAKE) clean-$$i; done
.PRECIOUS: $(all_src) $(all_scripts)
================================================
FILE: code/async/#build_other_searches.sh#
================================================
corebuild -pkg cohttp.async,yojson,textwrap search_out_of_order.native
================================================
FILE: code/async/#main.topscript#
================================================
let x = 3;;
#part 1
In_channel.read_all;;
Out_channel.write_all "test.txt" ~data:"This is only a test.";;
In_channel.read_all "test.txt";;
#part 2
let x = 3;;
#part 3
#require "async";;
open Async.Std;;
Reader.file_contents;;
#part 4
let contents = Reader.file_contents "test.txt";;
Deferred.peek contents;;
#part 5
contents;;
#part 6
Deferred.peek contents;;
#part 7
Deferred.bind ;;
#part 8
let uppercase_file filename =
Deferred.bind (Reader.file_contents filename)
(fun text ->
Writer.save filename ~contents:(String.uppercase text))
;;
uppercase_file "test.txt";;
Reader.file_contents "test.txt";;
#part 9
let uppercase_file filename =
Reader.file_contents filename
>>= fun text ->
Writer.save filename ~contents:(String.uppercase text)
;;
#part 10
let count_lines filename =
Reader.file_contents filename
>>= fun text ->
List.length (String.split text ~on:'\n')
;;
#part 11
return;;
let three = return 3;;
three;;
#part 12
let count_lines filename =
Reader.file_contents filename
>>= fun text ->
return (List.length (String.split text ~on:'\n'))
;;
#part 13
Deferred.map;;
#part 14
let count_lines filename =
Reader.file_contents filename
>>| fun text ->
List.length (String.split text ~on:'\n')
;;
count_lines "/etc/hosts";;
#part 15
let ivar = Ivar.create ();;
let def = Ivar.read ivar;;
Deferred.peek def;;
Ivar.fill ivar "Hello";;
Deferred.peek def;;
#part 16
module type Delayer_intf = sig
type t
val create : Time.Span.t -> t
val schedule : t -> (unit -> 'a Deferred.t) -> 'a Deferred.t
end;;
#part 17
upon;;
#part 18
module Delayer : Delayer_intf = struct
type t = { delay: Time.Span.t;
jobs: (unit -> unit) Queue.t;
}
let create delay =
{ delay; jobs = Queue.create () }
let schedule t thunk =
let ivar = Ivar.create () in
Queue.enqueue t.jobs (fun () ->
upon (thunk ()) (fun x -> Ivar.fill ivar x));
upon (after t.delay) (fun () ->
let job = Queue.dequeue_exn t.jobs in
job ());
Ivar.read ivar
end;;
#part 19
let rec loop_forever () = loop_forever ();;
let always_fail () = assert false;;
#part 20
let do_stuff n =
let x = 3 in
if n > 0 then loop_forever ();
x + n
;;
#part 21
let rec loop_forever () : never_returns = loop_forever ();;
#part 22
let do_stuff n =
let x = 3 in
if n > 0 then loop_forever ();
x + n
;;
#part 23
never_returns;;
let do_stuff n =
let x = 3 in
if n > 0 then never_returns (loop_forever ());
x + n
;;
#part 24
let (r,w) = Pipe.create ();;
#part 25
let (r,w) = Pipe.create ();;
let write_complete = Pipe.write w "Hello World!";;
Pipe.read r;;
write_complete;;
#part 26
Pipe.transfer;;
#part 27
Command.async_basic;;
#part 28
#require "cohttp.async";;
Cohttp_async.Client.get;;
#part 29
Deferred.all;;
#part 30
Deferred.all_unit;;
#part 31
let maybe_raise =
let should_fail = ref false in
fun () ->
let will_fail = !should_fail in
should_fail := not will_fail;
after (Time.Span.of_sec 0.5)
>>= fun () ->
if will_fail then raise Exit else return ()
;;
maybe_raise ();;
maybe_raise ();;
#part 32
let handle_error () =
try
maybe_raise ()
>>| fun () -> "success"
with _ -> return "failure"
;;
handle_error ();;
handle_error ();;
#part 33
let handle_error () =
try_with (fun () -> maybe_raise ())
>>| function
| Ok () -> "success"
| Error _ -> "failure"
;;
handle_error ();;
handle_error ();;
#part 34
let blow_up () =
let monitor = Monitor.create ~name:"blow up monitor" () in
within' ~monitor maybe_raise
;;
blow_up ();;
blow_up ();;
#part 35
let swallow_error () =
let monitor = Monitor.create () in
Stream.iter (Monitor.errors monitor) ~f:(fun _exn ->
printf "an error happened\n");
within' ~monitor (fun () ->
after (Time.Span.of_sec 0.5) >>= fun () -> failwith "Kaboom!")
;;
(* swallow_error ();; *)
#part 36
exception Ignore_me;;
let swallow_some_errors exn_to_raise =
let child_monitor = Monitor.create () in
let parent_monitor = Monitor.current () in
Stream.iter (Monitor.errors child_monitor) ~f:(fun error ->
match Monitor.extract_exn error with
| Ignore_me -> printf "ignoring exn\n"
| _ -> Monitor.send_exn parent_monitor error);
within' ~monitor:child_monitor (fun () ->
after (Time.Span.of_sec 0.5)
>>= fun () -> raise exn_to_raise)
;;
#part 37
swallow_some_errors Not_found;;
#part 38
(* swallow_some_errors Ignore_me;; *)
#part 39
let string_and_float = Deferred.both
(after (sec 0.5) >>| fun () -> "A")
(after (sec 0.25) >>| fun () -> 32.33);;
string_and_float;;
#part 40
Deferred.any [ (after (sec 0.5) >>| fun () -> "half a second")
; (after (sec 10.) >>| fun () -> "ten seconds") ] ;;
#part 41
choice;;
choose;;
#part 42
let def = In_thread.run (fun () -> List.range 1 10);;
def;;
#part 43
let log_delays thunk =
let start = Time.now () in
let print_time () =
let diff = Time.diff (Time.now ()) start in
printf "%s, " (Time.Span.to_string diff)
in
let d = thunk () in
Clock.every (sec 0.1) ~stop:d print_time;
d >>| fun () -> print_time (); printf "\n"
;;
#part 44
log_delays (fun () -> after (sec 1.));;
#part 45
let busy_loop () =
let x = ref None in
for i = 1 to 100_000_000 do x := Some i done
;;
log_delays ( >>| fun () -> busy_loop 100);;
#part 46
log_delays (In_thread.run (fun () -> busy_loop 100));;
#part 47
let noalloc_busy_loop n =
let rec loop n =
if n <= 0 then ()
else loop (n-1)
in
loop (n * 100_000)
;;
log_delays (In_thread.run (fun () -> noalloc_busy_loop 500));;
================================================
FILE: code/async/better_echo.ml
================================================
open Core.Std
open Async.Std
let run ~uppercase ~port =
let host_and_port =
Tcp.Server.create
~on_handler_error:`Raise
(Tcp.on_port port)
(fun _addr r w ->
Pipe.transfer (Reader.pipe r) (Writer.pipe w)
~f:(if uppercase then String.uppercase else Fn.id))
in
ignore (host_and_port : (Socket.Address.Inet.t, int) Tcp.Server.t Deferred.t);
Deferred.never ()
let () =
Command.async_basic
~summary:"Start an echo server"
Command.Spec.(
empty
+> flag "-uppercase" no_arg
~doc:" Convert to uppercase before echoing back"
+> flag "-port" (optional_with_default 8765 int)
~doc:" Port to listen on (default 8765)"
)
(fun uppercase port () -> run ~uppercase ~port)
|> Command.run
================================================
FILE: code/async/build_echo.sh
================================================
corebuild -pkg async echo.native
corebuild -pkg async better_echo.native
================================================
FILE: code/async/build_other_searches.sh
================================================
corebuild -pkg cohttp.async,yojson,textwrap search_out_of_order.native
================================================
FILE: code/async/echo.ml
================================================
open Core.Std
open Async.Std
(* Copy data from the reader to the writer, using the provided buffer
as scratch space *)
let rec copy_blocks buffer r w =
Reader.read r buffer
>>= function
| `Eof -> return ()
| `Ok bytes_read ->
Writer.write w buffer ~len:bytes_read;
Writer.flushed w
>>= fun () ->
copy_blocks buffer r w
(* part 1 *)
(** Starts a TCP server, which listens on the specified port, invoking
copy_blocks every time a client connects. *)
let run () =
let host_and_port =
Tcp.Server.create
~on_handler_error:`Raise
(Tcp.on_port 8765)
(fun _addr r w ->
let buffer = String.create (16 * 1024) in
copy_blocks buffer r w)
in
ignore (host_and_port : (Socket.Address.Inet.t, int) Tcp.Server.t Deferred.t)
(* part 2 *)
(* Call [run], and then start the scheduler *)
let () =
run ();
never_returns (Scheduler.go ())
================================================
FILE: code/async/main-35.rawscript
================================================
# let swallow_error () =
let monitor = Monitor.create () in
Stream.iter (Monitor.errors monitor) ~f:(fun _exn ->
printf "an error happened\n");
within' ~monitor (fun () ->
after (Time.Span.of_sec 0.5) >>= fun () -> failwith "Kaboom!")
;;
val swallow_error : unit -> 'a Deferred.t = <fun>
# swallow_error ();;
an error happened
================================================
FILE: code/async/main-38.rawscript
================================================
# swallow_some_errors Ignore_me;;
ignoring exn
================================================
FILE: code/async/main-44.rawscript
================================================
# log_delays (fun () -> after (sec 0.5));;
0.154972ms, 102.126ms, 203.658ms, 305.73ms, 407.903ms, 501.563ms,
- : unit = ()
================================================
FILE: code/async/main-45.rawscript
================================================
# let busy_loop n =
let x = ref None in
for i = 1 to 100_000_000 do x := Some i done
;;
val busy_loop : 'a -> unit = <fun>
# log_delays (fun () -> return (busy_loop ()));;
19.2185s,
- : unit = ()
================================================
FILE: code/async/main-46.rawscript
================================================
# log_delays (fun () -> In_thread.run busy_loop);;
0.332117ms, 16.6319s, 18.8722s,
- : unit = ()
================================================
FILE: code/async/main-47.rawscript
================================================
# let noalloc_busy_loop () =
for i = 0 to 100_000_000 do () done
;;
val noalloc_busy_loop : unit -> unit = <fun>
# log_delays (fun () -> In_thread.run noalloc_busy_loop);;
0.169039ms, 4.58345s, 4.77866s, 4.87957s, 12.4723s, 15.0134s,
- : unit = ()
================================================
FILE: code/async/main.topscript
================================================
let x = 3;;
#part 1
In_channel.read_all;;
Out_channel.write_all "test.txt" ~data:"This is only a test.";;
In_channel.read_all "test.txt";;
#part 2
let x = 3;;
#part 3
#require "async";;
open Async.Std;;
Reader.file_contents;;
#part 4
let contents = Reader.file_contents "test.txt";;
Deferred.peek contents;;
#part 5
contents;;
#part 6
Deferred.peek contents;;
#part 7
Deferred.bind ;;
#part 8
let uppercase_file filename =
Deferred.bind (Reader.file_contents filename)
(fun text ->
Writer.save filename ~contents:(String.uppercase text))
;;
uppercase_file "test.txt";;
Reader.file_contents "test.txt";;
#part 9
let uppercase_file filename =
Reader.file_contents filename
>>= fun text ->
Writer.save filename ~contents:(String.uppercase text)
;;
#part 10
let count_lines filename =
Reader.file_contents filename
>>= fun text ->
List.length (String.split text ~on:'\n')
;;
#part 11
return;;
let three = return 3;;
three;;
#part 12
let count_lines filename =
Reader.file_contents filename
>>= fun text ->
return (List.length (String.split text ~on:'\n'))
;;
#part 13
Deferred.map;;
#part 14
let count_lines filename =
Reader.file_contents filename
>>| fun text ->
List.length (String.split text ~on:'\n')
;;
count_lines "/etc/hosts";;
#part 15
let ivar = Ivar.create ();;
let def = Ivar.read ivar;;
Deferred.peek def;;
Ivar.fill ivar "Hello";;
Deferred.peek def;;
#part 16
module type Delayer_intf = sig
type t
val create : Time.Span.t -> t
val schedule : t -> (unit -> 'a Deferred.t) -> 'a Deferred.t
end;;
#part 17
upon;;
#part 18
module Delayer : Delayer_intf = struct
type t = { delay: Time.Span.t;
jobs: (unit -> unit) Queue.t;
}
let create delay =
{ delay; jobs = Queue.create () }
let schedule t thunk =
let ivar = Ivar.create () in
Queue.enqueue t.jobs (fun () ->
upon (thunk ()) (fun x -> Ivar.fill ivar x));
upon (after t.delay) (fun () ->
let job = Queue.dequeue_exn t.jobs in
job ());
Ivar.read ivar
end;;
#part 19
let rec loop_forever () = loop_forever ();;
let always_fail () = assert false;;
#part 20
let do_stuff n =
let x = 3 in
if n > 0 then loop_forever ();
x + n
;;
#part 21
let rec loop_forever () : never_returns = loop_forever ();;
#part 22
let do_stuff n =
let x = 3 in
if n > 0 then loop_forever ();
x + n
;;
#part 23
never_returns;;
let do_stuff n =
let x = 3 in
if n > 0 then never_returns (loop_forever ());
x + n
;;
#part 24
let (r,w) = Pipe.create ();;
#part 25
let (r,w) = Pipe.create ();;
let write_complete = Pipe.write w "Hello World!";;
Pipe.read r;;
write_complete;;
#part 26
Pipe.transfer;;
#part 27
Command.async_basic;;
#part 28
#require "cohttp.async";;
Cohttp_async.Client.get;;
#part 29
Deferred.all;;
#part 30
Deferred.all_unit;;
#part 31
let maybe_raise =
let should_fail = ref false in
fun () ->
let will_fail = !should_fail in
should_fail := not will_fail;
after (Time.Span.of_sec 0.5)
>>= fun () ->
if will_fail then raise Exit else return ()
;;
maybe_raise ();;
maybe_raise ();;
#part 32
let handle_error () =
try
maybe_raise ()
>>| fun () -> "success"
with _ -> return "failure"
;;
handle_error ();;
handle_error ();;
#part 33
let handle_error () =
try_with (fun () -> maybe_raise ())
>>| function
| Ok () -> "success"
| Error _ -> "failure"
;;
handle_error ();;
handle_error ();;
#part 34
let blow_up () =
let monitor = Monitor.create ~name:"blow up monitor" () in
within' ~monitor maybe_raise
;;
blow_up ();;
blow_up ();;
#part 35
let swallow_error () =
let monitor = Monitor.create () in
Stream.iter (Monitor.errors monitor) ~f:(fun _exn ->
printf "an error happened\n");
within' ~monitor (fun () ->
after (Time.Span.of_sec 0.5) >>= fun () -> failwith "Kaboom!")
;;
(* swallow_error ();; *)
#part 36
exception Ignore_me;;
let swallow_some_errors exn_to_raise =
let child_monitor = Monitor.create () in
let parent_monitor = Monitor.current () in
Stream.iter (Monitor.errors child_monitor) ~f:(fun error ->
match Monitor.extract_exn error with
| Ignore_me -> printf "ignoring exn\n"
| _ -> Monitor.send_exn parent_monitor error);
within' ~monitor:child_monitor (fun () ->
after (Time.Span.of_sec 0.5)
>>= fun () -> raise exn_to_raise)
;;
#part 37
swallow_some_errors Not_found;;
#part 38
(* swallow_some_errors Ignore_me;; *)
#part 39
let string_and_float = Deferred.both
(after (sec 0.5) >>| fun () -> "A")
(after (sec 0.25) >>| fun () -> 32.33);;
string_and_float;;
#part 40
Deferred.any [ (after (sec 0.5) >>| fun () -> "half a second")
; (after (sec 10.) >>| fun () -> "ten seconds") ] ;;
#part 41
choice;;
choose;;
#part 42
let def = In_thread.run (fun () -> List.range 1 10);;
def;;
#part 43
let log_delays thunk =
let start = Time.now () in
let print_time () =
let diff = Time.diff (Time.now ()) start in
printf "%s, " (Time.Span.to_string diff)
in
let d = thunk () in
Clock.every (sec 0.1) ~stop:d print_time;
d >>| fun () -> print_time (); printf "\n"
;;
#part 44
log_delays (fun () -> after (sec 0.5));;
#part 45
let busy_loop n =
let x = ref None in
for i = 1 to 100_000_000 do x := Some i done
;;
log_delays (fun () -> return (busy_loop ()));;
#part 46
log_delays (fun () -> In_thread.run busy_loop);;
#part 47
let noalloc_busy_loop () =
for i = 0 to 100_000_000 do () done
;;
log_delays (fun () -> In_thread.run noalloc_busy_loop);;
================================================
FILE: code/async/native_code_log_delays.ml
================================================
open Core.Std
open Async.Std
let log_delays thunk =
let start = Time.now () in
let print_time () =
let diff = Time.diff (Time.now ()) start in
printf "%s, " (Time.Span.to_string diff)
in
let d = thunk () in
Clock.every (sec 0.1) ~stop:d print_time;
d >>| fun () -> print_time (); printf "\n"
let noalloc_busyloop () =
for _i = 1 to 25_000_000_000 do () done;
Deferred.unit
let () =
Command.async_basic
~summary:"run logger without busy loop"
Command.Spec.(empty)
(fun () -> log_delays noalloc_busyloop)
|> Command.run
================================================
FILE: code/async/pipe_write_break.rawscript
================================================
# Pipe.write w "Hello World!";;
Interrupted.
================================================
FILE: code/async/pipe_write_break.rawtopscript
================================================
# Pipe.write w "Hello World!";;
Interrupted.
================================================
FILE: code/async/run_echo.rawsh
================================================
$ ./echo.native &
$ nc 127.0.0.1 8765
This is an echo server
This is an echo server
It repeats whatever I write.
It repeats whatever I write.
================================================
FILE: code/async/run_native_code_log_delays.rawsh
================================================
$ corebuild -pkg async native_code_log_delays.native
$ ./native_code_log_delays.native
15.5686s,
$
================================================
FILE: code/async/run_native_code_log_delays_orig.sh
================================================
corebuild -pkg async native_code_log_delays.native
./native_code_log_delays.native
================================================
FILE: code/async/run_search.rawsh
================================================
$ corebuild -pkg cohttp.async,yojson,textwrap search.native
$ ./search.native "Concurrent Programming" "OCaml"
Concurrent Programming
----------------------
"Concurrent computing is a form of computing in which programs are
designed as collections of interacting computational processes that
may be executed in parallel."
OCaml
-----
"OCaml, originally known as Objective Caml, is the main implementation
of the Caml programming language, created by Xavier Leroy, Jérôme
Vouillon, Damien Doligez, Didier Rémy and others in 1996."
================================================
FILE: code/async/run_search_orig.sh
================================================
corebuild -pkg cohttp.async,yojson,textwrap search.native
./search.native "Concurrent Programming" "OCaml"
================================================
FILE: code/async/run_search_with_configurable_server.rawsh
================================================
$ corebuild -pkg cohttp.async,yojson,textwrap \
search_with_configurable_server.native
$ ./search_with_configurable_server.native \
-servers localhost,api.duckduckgo.com \
"Concurrent Programming" OCaml
("unhandled exception"
((lib/monitor.ml.Error_
((exn (Unix.Unix_error "Connection refused" connect 127.0.0.1:80))
(backtrace
("Raised by primitive operation at file \"lib/unix_syscalls.ml\", line 797, characters 12-69"
"Called from file \"lib/deferred.ml\", line 20, characters 62-65"
"Called from file \"lib/scheduler.ml\", line 125, characters 6-17"
"Called from file \"lib/jobs.ml\", line 65, characters 8-13" ""))
(monitor
(((name Tcp.close_sock_on_error) (here ()) (id 5) (has_seen_error true)
(someone_is_listening true) (kill_index 0))
((name main) (here ()) (id 1) (has_seen_error true)
(someone_is_listening false) (kill_index 0))))))
(Pid 15971)))
================================================
FILE: code/async/run_search_with_configurable_server_orig.errsh
================================================
corebuild -pkg cohttp.async,yojson,textwrap search_with_configurable_server.native
./search_with_configurable_server.native -servers localhost,api.duckduckgo.com "Concurrent Programming" OCaml
================================================
FILE: code/async/run_search_with_error_handling.rawsh
================================================
$ corebuild -pkg cohttp.async,yojson,textwrap \
search_with_error_handling.native
$ ./search_with_error_handling.native \
-servers localhost,api.duckduckgo.com \
"Concurrent Programming" OCaml
Concurrent Programming
----------------------
DuckDuckGo query failed: Unexpected failure
OCaml
-----
"OCaml, originally known as Objective Caml, is the main implementation
of the Caml programming language, created by Xavier Leroy, Jérôme
Vouillon, Damien Doligez, Didier Rémy and others in 1996."
================================================
FILE: code/async/run_search_with_error_handling_orig.sh
================================================
corebuild -pkg cohttp.async,yojson,textwrap search_with_error_handling.native
./search_with_error_handling.native -servers localhost,api.duckduckgo.com "Concurrent Programming" OCaml
================================================
FILE: code/async/run_search_with_timeout_no_leak.rawsh
================================================
$ corebuild -pkg cohttp.async,yojson,textwrap \
search_with_timeout_no_leak.native
$ ./search_with_timeout_no_leak.native \
"concurrent programming" ocaml -timeout 0.2s
concurrent programming
----------------------
DuckDuckGo query failed: Timed out
ocaml
-----
"OCaml or Objective Caml, is the main implementation of the Caml
programming language, created by Xavier Leroy, Jérôme Vouillon,
Damien Doligez, Didier Rémy and others in 1996."
================================================
FILE: code/async/run_search_with_timeout_no_leak_orig.sh
================================================
corebuild -pkg cohttp.async,yojson,textwrap search_with_timeout_no_leak.native
./search_with_timeout_no_leak.native "concurrent programming" ocaml -timeout 0.2s
================================================
FILE: code/async/run_thread.sh
================================================
corebuild -pkg async thread_exp_async_only.native
./thread_exp_async_only.native
================================================
FILE: code/async/search.ml
================================================
open Core.Std
open Async.Std
(* Generate a DuckDuckGo search URI from a query string *)
let query_uri query =
let base_uri = Uri.of_string "http://api.duckduckgo.com/?format=json" in
Uri.add_query_param base_uri ("q", [query])
(* part 1 *)
(* Extract the "Definition" or "Abstract" field from the DuckDuckGo results *)
let get_definition_from_json json =
match Yojson.Safe.from_string json with
| `Assoc kv_list ->
let find key =
begin match List.Assoc.find kv_list key with
| None | Some (`String "") -> None
| Some s -> Some (Yojson.Safe.to_string s)
end
in
begin match find "Abstract" with
| Some _ as x -> x
| None -> find "Definition"
end
| _ -> None
(* part 2 *)
(* Execute the DuckDuckGo search *)
let get_definition word =
Cohttp_async.Client.get (query_uri word)
>>= fun (_, body) ->
Pipe.to_list (Cohttp_async.Body.to_pipe body)
>>| fun strings ->
(word, get_definition_from_json (String.concat strings))
(* part 3 *)
(* Print out a word/definition pair *)
let print_result (word,definition) =
printf "%s\n%s\n\n%s\n\n"
word
(String.init (String.length word) ~f:(fun _ -> '-'))
(match definition with
| None -> "No definition found"
| Some def ->
String.concat ~sep:"\n"
(Wrapper.wrap (Wrapper.make 70) def))
(* part 4 *)
(* Run many searches in parallel, printing out the results after they're all
done. *)
let search_and_print words =
Deferred.all (List.map words ~f:get_definition)
>>| fun results ->
List.iter results ~f:print_result
(* part 5 *)
let () =
Command.async_basic
~summary:"Retrieve definitions from duckduckgo search engine"
Command.Spec.(
empty
+> anon (sequence ("word" %: string))
)
(fun words () -> search_and_print words)
|> Command.run
================================================
FILE: code/async/search_out_of_order.ml
================================================
open Core.Std
open Async.Std
(* Generate a DuckDuckGo search URI from a query string *)
let query_uri =
let base_uri = Uri.of_string "http://api.duckduckgo.com/?format=json" in
fun query -> Uri.add_query_param base_uri ("q", [query])
(* Extract the "Definition" or "Abstract" field from the DuckDuckGo results *)
let get_definition_from_json json =
match Yojson.Safe.from_string json with
| `Assoc kv_list ->
let find key =
begin match List.Assoc.find kv_list key with
| None | Some (`String "") -> None
| Some s -> Some (Yojson.Safe.to_string s)
end
in
begin match find "Abstract" with
| Some _ as x -> x
| None -> find "Definition"
end
| _ -> None
(* Execute the DuckDuckGo search *)
let get_definition word =
Cohttp_async.Client.get (query_uri word)
>>= fun (_,body) ->
Pipe.to_list body
>>| fun strings ->
(word, get_definition_from_json (String.concat strings))
(* Print out a word/definition pair *)
let print_result (word,definition) =
printf "%s\n%s\n\n%s\n\n"
word
(String.init (String.length word) ~f:(fun _ -> '-'))
(match definition with
| None -> "No definition found"
| Some def -> String.concat ~sep:"\n" (Wrapper.wrap (Wrapper.make 70) def))
(* part 1 *)
(* Run many searches in parallel, printing out the results as you go *)
let search_and_print words =
Deferred.all_unit (List.map words ~f:(fun word ->
get_definition word >>| print_result))
(* part 2 *)
let () =
Command.async_basic
~summary:"Retrieve definitions from duckduckgo search engine"
Command.Spec.(
empty
+> anon (sequence ("word" %: string))
)
(fun words () -> search_and_print words)
|> Command.run
================================================
FILE: code/async/search_with_configurable_server.ml
================================================
open Core.Std
open Async.Std
(* part 1 *)
(* Generate a DuckDuckGo search URI from a query string *)
let query_uri ~server query =
let base_uri =
Uri.of_string (String.concat ["http://";server;"/?format=json"])
in
Uri.add_query_param base_uri ("q", [query])
(* part 2 *)
(* Extract the "Definition" or "Abstract" field from the DuckDuckGo results *)
let get_definition_from_json json =
match Yojson.Safe.from_string json with
| `Assoc kv_list ->
let find key =
begin match List.Assoc.find kv_list key with
| None | Some (`String "") -> None
| Some s -> Some (Yojson.Safe.to_string s)
end
in
begin match find "Abstract" with
| Some _ as x -> x
| None -> find "Definition"
end
| _ -> None
(* Execute the DuckDuckGo search *)
let get_definition ~server word =
Cohttp_async.Client.get (query_uri ~server word)
>>= fun (_, body) ->
Pipe.to_list body
>>| fun strings ->
(word, get_definition_from_json (String.concat strings))
(* Print out a word/definition pair *)
let print_result (word,definition) =
printf "%s\n%s\n\n%s\n\n"
word
(String.init (String.length word) ~f:(fun _ -> '-'))
(match definition with
| None -> "No definition found"
| Some def ->
String.concat ~sep:"\n"
(Wrapper.wrap (Wrapper.make 70) def))
(* Run many searches in parallel, printing out the results after they're all
done. *)
let search_and_print ~servers words =
let servers = Array.of_list servers in
Deferred.all (List.mapi words ~f:(fun i word ->
let server = servers.(i mod Array.length servers) in
get_definition ~server word))
>>| fun results ->
List.iter results ~f:print_result
let () =
Command.async_basic
~summary:"Retrieve definitions from duckduckgo search engine"
Command.Spec.(
let string_list = Arg_type.create (String.split ~on:',') in
empty
+> anon (sequence ("word" %: string))
+> flag "-servers"
(optional_with_default ["api.duckduckgo.com"] string_list)
~doc:" Specify server to connect to"
)
(fun words servers () -> search_and_print ~servers words)
|> Command.run
================================================
FILE: code/async/search_with_error_handling.ml
================================================
open Core.Std
open Async.Std
(* Generate a DuckDuckGo search URI from a query string *)
let query_uri ~server query =
let base_uri =
Uri.of_string (String.concat ["http://";server;"/?format=json"])
in
Uri.add_query_param base_uri ("q", [query])
(* Extract the "Definition" or "Abstract" field from the DuckDuckGo results *)
let get_definition_from_json json =
match Yojson.Safe.from_string json with
| `Assoc kv_list ->
let find key =
begin match List.Assoc.find kv_list key with
| None | Some (`String "") -> None
| Some s -> Some (Yojson.Safe.to_string s)
end
in
begin match find "Abstract" with
| Some _ as x -> x
| None -> find "Definition"
end
| _ -> None
(* part 1 *)
(* Execute the DuckDuckGo search *)
let get_definition ~server word =
try_with (fun () ->
Cohttp_async.Client.get (query_uri ~server word)
>>= fun (_, body) ->
Pipe.to_list (Cohttp_async.Body.to_pipe body)
>>| fun strings ->
(word, get_definition_from_json (String.concat strings)))
>>| function
| Ok (word,result) -> (word, Ok result)
| Error _ -> (word, Error "Unexpected failure")
(* part 2 *)
(* Print out a word/definition pair *)
let print_result (word,definition) =
printf "%s\n%s\n\n%s\n\n"
word
(String.init (String.length word) ~f:(fun _ -> '-'))
(match definition with
| Error s -> "DuckDuckGo query failed: " ^ s
| Ok None -> "No definition found"
| Ok (Some def) ->
String.concat ~sep:"\n"
(Wrapper.wrap (Wrapper.make 70) def))
(* part 3 *)
(* Run many searches in parallel, printing out the results after they're all
done. *)
let search_and_print ~servers words =
let servers = Array.of_list servers in
Deferred.all (List.mapi words ~f:(fun i word ->
let server = servers.(i mod Array.length servers) in
get_definition ~server word))
>>| fun results ->
List.iter results ~f:print_result
let () =
Command.async_basic
~summary:"Retrieve definitions from duckduckgo search engine"
Command.Spec.(
let string_list = Arg_type.create (String.split ~on:',') in
empty
+> anon (sequence ("word" %: string))
+> flag "-servers"
(optional_with_default ["api.duckduckgo.com"] string_list)
~doc:" Specify server to connect to"
)
(fun words servers () -> search_and_print ~servers words)
|> Command.run
================================================
FILE: code/async/search_with_error_handling_deprecated.ml
================================================
open Core.Std
open Async.Std
(* Generate a DuckDuckGo search URI from a query string *)
let query_uri ~server query =
let base_uri =
Uri.of_string (String.concat ["http://";server;"/?format=json"])
in
Uri.add_query_param base_uri ("q", [query])
(* Extract the "Definition" or "Abstract" field from the DuckDuckGo results *)
let get_definition_from_json json =
match Yojson.Safe.from_string json with
| `Assoc kv_list ->
let find key =
begin match List.Assoc.find kv_list key with
| None | Some (`String "") -> None
| Some s -> Some (Yojson.Safe.to_string s)
end
in
begin match find "Abstract" with
| Some _ as x -> x
| None -> find "Definition"
end
| _ -> None
(* Execute the DuckDuckGo search *)
let get_definition ~server word =
try_with (fun () ->
Cohttp_async.Client.get (query_uri ~server word)
>>= fun (_, body) ->
Pipe.to_list body
>>| fun strings ->
(word, get_definition_from_json (String.concat strings)))
>>| function
| Ok (word,result) -> (word, Ok result)
| Error exn -> (word, Error exn)
(* Print out a word/definition pair *)
let print_result (word,definition) =
printf "%s\n%s\n\n%s\n\n"
word
(String.init (String.length word) ~f:(fun _ -> '-'))
(match definition with
| Error _ -> "DuckDuckGo query failed unexpectedly"
| Ok None -> "No definition found"
| Ok (Some def) ->
String.concat ~sep:"\n"
(Wrapper.wrap (Wrapper.make 70) def))
(* Run many searches in parallel, printing out the results after they're all
done. *)
let search_and_print ~server words =
Deferred.all (List.map ~f:(get_definition ~server) words)
>>| fun results ->
List.iter results ~f:print_result
let () =
Command.async_basic
~summary:"Retrieve definitions from duckduckgo search engine"
Command.Spec.(
empty
+> anon (sequence ("word" %: string))
+> flag "-server" (optional_with_default "api.duckduckgo.com" string)
~doc:" Specify server to connect to"
)
(fun words server () -> search_and_print ~server words)
|> Command.run
================================================
FILE: code/async/search_with_timeout.ml
================================================
open Core.Std
open Async.Std
(* Generate a DuckDuckGo search URI from a query string *)
let query_uri ~server query =
let base_uri =
Uri.of_string (String.concat ["http://";server;"/?format=json"])
in
Uri.add_query_param base_uri ("q", [query])
(* Extract the "Definition" or "Abstract" field from the DuckDuckGo results *)
let get_definition_from_json json =
match Yojson.Safe.from_string json with
| `Assoc kv_list ->
let find key =
begin match List.Assoc.find kv_list key with
| None | Some (`String "") -> None
| Some s -> Some (Yojson.Safe.to_string s)
end
in
begin match find "Abstract" with
| Some _ as x -> x
| None -> find "Definition"
end
| _ -> None
(* Execute the DuckDuckGo search *)
let get_definition ~server word =
try_with (fun () ->
Cohttp_async.Client.get (query_uri ~server word)
>>= fun (_, body) ->
Pipe.to_list body
>>| fun strings ->
(word, get_definition_from_json (String.concat strings)))
>>| function
| Ok (word,result) -> (word, Ok result)
| Error exn -> (word, Error exn)
(* part 1 *)
let get_definition_with_timeout ~server ~timeout word =
Deferred.any
[ (after timeout >>| fun () -> (word,Error "Timed out"))
; (get_definition ~server word
>>| fun (word,result) ->
let result' = match result with
| Ok _ as x -> x
| Error _ -> Error "Unexpected failure"
in
(word,result')
)
]
(* part 2 *)
(* Print out a word/definition pair *)
let print_result (word,definition) =
printf "%s\n%s\n\n%s\n\n"
word
(String.init (String.length word) ~f:(fun _ -> '-'))
(match definition with
| Error s -> "DuckDuckGo query failed: " ^ s
| Ok None -> "No definition found"
| Ok (Some def) ->
String.concat ~sep:"\n"
(Wrapper.wrap (Wrapper.make 70) def))
(* Run many searches in parallel, printing out the results after they're all
done. *)
let search_and_print ~servers ~timeout words =
let servers = Array.of_list servers in
Deferred.all (List.mapi words ~f:(fun i word ->
let server = servers.(i mod Array.length servers) in
get_definition_with_timeout ~server ~timeout word))
>>| fun results ->
List.iter results ~f:print_result
let () =
Command.async_basic
~summary:"Retrieve definitions from duckduckgo search engine"
Command.Spec.(
let string_list = Arg_type.create (String.split ~on:',') in
empty
+> anon (sequence ("word" %: string))
+> flag "-servers"
(optional_with_default ["api.duckduckgo.com"] string_list)
~doc:" Specify server to connect to"
+> flag "-timeout" (optional_with_default (sec 5.) time_span)
~doc:" Abandon queries that take longer than this time"
)
(fun words servers timeout () ->
search_and_print ~servers ~timeout words)
|> Command.run
================================================
FILE: code/async/search_with_timeout_choice.ml
================================================
open Core.Std
open Async.Std
(* Generate a DuckDuckGo search URI from a query string *)
let query_uri ~server query =
let base_uri =
Uri.of_string (String.concat ["http://";server;"/?format=json"])
in
Uri.add_query_param base_uri ("q", [query])
(* Extract the "Definition" or "Abstract" field from the DuckDuckGo results *)
let get_definition_from_json json =
match Yojson.Safe.from_string json with
| `Assoc kv_list ->
let find key =
begin match List.Assoc.find kv_list key with
| None | Some (`String "") -> None
| Some s -> Some (Yojson.Safe.to_string s)
end
in
begin match find "Abstract" with
| Some _ as x -> x
| None -> find "Definition"
end
| _ -> None
(* Execute the DuckDuckGo search *)
let get_definition ~server ~interrupt word =
try_with (fun () ->
Cohttp_async.Client.get ~interrupt (query_uri ~server word)
>>= fun (_, body) ->
Pipe.to_list body
>>| fun strings ->
(word, get_definition_from_json (String.concat strings)))
>>| function
| Ok (word,result) -> (word, Ok result)
| Error exn -> (word, Error exn)
let get_definition_with_timeout ~server ~timeout word =
let interrupt = Ivar.create () in
choose
[ choice (after timeout) (fun () ->
Ivar.fill interrupt ();
(word,Error "Timed out"))
; choice (get_definition ~server ~interrupt:(Ivar.read interrupt) word)
(fun (word,result) ->
let result' = match result with
| Ok _ as x -> x
| Error _ -> Error "Unexpected failure"
in
(word,result')
)
]
(* Print out a word/definition pair *)
let print_result (word,definition) =
printf "%s\n%s\n\n%s\n\n"
word
(String.init (String.length word) ~f:(fun _ -> '-'))
(match definition with
| Error _ -> "DuckDuckGo query failed unexpectedly"
| Ok None -> "No definition found"
| Ok (Some def) ->
String.concat ~sep:"\n"
(Wrapper.wrap (Wrapper.make 70) def))
(* Run many searches in parallel, printing out the results after they're all
done. *)
let search_and_print ~servers ~timeout words =
let servers = Array.of_list servers in
Deferred.all (List.mapi words ~f:(fun i word ->
let server = servers.(i mod Array.length servers) in
get_definition_with_timeout ~server ~timeout word))
>>| fun results ->
List.iter results ~f:print_result
let () =
Command.async_basic
~summary:"Retrieve definitions from duckduckgo search engine"
Command.Spec.(
let string_list = Arg_type.create (String.split ~on:',') in
empty
+> anon (sequence ("word" %: string))
+> flag "-servers"
(optional_with_default ["api.duckduckgo.com"] string_list)
~doc:" Specify server to connect to"
+> flag "-timeout" (optional_with_default (sec 5.) time_span)
~doc:" Abandon queries that take longer than this time"
)
(fun words servers timeout () ->
search_and_print ~servers ~timeout words)
|> Command.run
================================================
FILE: code/async/search_with_timeout_no_leak.ml
================================================
open Core.Std
open Async.Std
(* Generate a DuckDuckGo search URI from a query string *)
let query_uri ~server query =
let base_uri =
Uri.of_string (String.concat ["http://";server;"/?format=json"])
in
Uri.add_query_param base_uri ("q", [query])
(* Extract the "Definition" or "Abstract" field from the DuckDuckGo results *)
let get_definition_from_json json =
match Yojson.Safe.from_string json with
| `Assoc kv_list ->
let find key =
begin match List.Assoc.find kv_list key with
| None | Some (`String "") -> None
| Some s -> Some (Yojson.Safe.to_string s)
end
in
begin match find "Abstract" with
| Some _ as x -> x
| None -> find "Definition"
end
| _ -> None
(* part 1 *)
(* Execute the DuckDuckGo search *)
let get_definition ~server ~interrupt word =
try_with (fun () ->
Cohttp_async.Client.get ~interrupt (query_uri ~server word)
>>= fun (_, body) ->
Pipe.to_list (Cohttp_async.Body.to_pipe body)
>>| fun strings ->
(word, get_definition_from_json (String.concat strings)))
>>| function
| Ok (word,result) -> (word, Ok result)
| Error exn -> (word, Error exn)
(* part 2 *)
let get_definition_with_timeout ~server ~timeout word =
let interrupt = Ivar.create () in
choose
[ choice (after timeout) (fun () ->
Ivar.fill interrupt ();
(word,Error "Timed out"))
; choice (get_definition ~server ~interrupt:(Ivar.read interrupt) word)
(fun (word,result) ->
let result' = match result with
| Ok _ as x -> x
| Error _ -> Error "Unexpected failure"
in
(word,result')
)
]
(* part 3 *)
(* Print out a word/definition pair *)
let print_result (word,definition) =
printf "%s\n%s\n\n%s\n\n"
word
(String.init (String.length word) ~f:(fun _ -> '-'))
(match definition with
| Error s -> "DuckDuckGo query failed: " ^ s
| Ok None -> "No definition found"
| Ok (Some def) ->
String.concat ~sep:"\n"
(Wrapper.wrap (Wrapper.make 70) def))
(* Run many searches in parallel, printing out the results after they're all
done. *)
let search_and_print ~servers ~timeout words =
let servers = Array.of_list servers in
Deferred.all (List.mapi words ~f:(fun i word ->
let server = servers.(i mod Array.length servers) in
get_definition_with_timeout ~server ~timeout word))
>>| fun results ->
List.iter results ~f:print_result
let () =
Command.async_basic
~summary:"Retrieve definitions from duckduckgo search engine"
Command.Spec.(
let string_list = Arg_type.create (String.split ~on:',') in
empty
+> anon (sequence ("word" %: string))
+> flag "-servers"
(optional_with_default ["api.duckduckgo.com"] string_list)
~doc:" Specify server to connect to"
+> flag "-timeout" (optional_with_default (sec 5.) time_span)
~doc:" Abandon queries that take longer than this time"
)
(fun words servers timeout () ->
search_and_print ~servers ~timeout words)
|> Command.run
================================================
FILE: code/async/search_with_timeout_no_leak_simple.ml
================================================
open Core.Std
open Async.Std
(* Generate a DuckDuckGo search URI from a query string *)
let query_uri ~server query =
let base_uri =
Uri.of_string (String.concat ["http://";server;"/?format=json"])
in
Uri.add_query_param base_uri ("q", [query])
(* Extract the "Definition" or "Abstract" field from the DuckDuckGo results *)
let get_definition_from_json json =
match Yojson.Safe.from_string json with
| `Assoc kv_list ->
let find key =
begin match List.Assoc.find kv_list key with
| None | Some (`String "") -> None
| Some s -> Some (Yojson.Safe.to_string s)
end
in
begin match find "Abstract" with
| Some _ as x -> x
| None -> find "Definition"
end
| _ -> None
(* part 1 *)
(* Execute the DuckDuckGo search *)
let get_definition ~server ~interrupt word =
try_with (fun () ->
Cohttp_async.Client.get ~interrupt (query_uri ~server word)
>>= fun (_, body) ->
Pipe.to_list body
>>| fun strings ->
(word, get_definition_from_json (String.concat strings)))
>>| function
| Ok (word,result) -> (word, Ok result)
| Error exn -> (word, Error exn)
(* part 2 *)
let get_definition_with_timeout ~server ~timeout word =
get_definition ~server ~interrupt:(after timeout) word
>>| fun (word,result) ->
let result' = match result with
| Ok _ as x -> x
| Error _ -> Error "Unexpected failure"
in
(word,result')
(* part 3 *)
(* Print out a word/definition pair *)
let print_result (word,definition) =
printf "%s\n%s\n\n%s\n\n"
word
(String.init (String.length word) ~f:(fun _ -> '-'))
(match definition with
| Error _ -> "DuckDuckGo query failed unexpectedly"
| Ok None -> "No definition found"
| Ok (Some def) ->
String.concat ~sep:"\n"
(Wrapper.wrap (Wrapper.make 70) def))
(* Run many searches in parallel, printing out the results after they're all
done. *)
let search_and_print ~servers ~timeout words =
let servers = Array.of_list servers in
Deferred.all (List.mapi words ~f:(fun i word ->
let server = servers.(i mod Array.length servers) in
get_definition_with_timeout ~server ~timeout word))
>>| fun results ->
List.iter results ~f:print_result
let () =
Command.async_basic
~summary:"Retrieve definitions from duckduckgo search engine"
Command.Spec.(
let string_list = Arg_type.create (String.split ~on:',') in
empty
+> anon (sequence ("word" %: string))
+> flag "-servers"
(optional_with_default ["api.duckduckgo.com"] string_list)
~doc:" Specify server to connect to"
+> flag "-timeout" (optional_with_default (sec 5.) time_span)
~doc:" Abandon queries that take longer than this time"
)
(fun words servers timeout () ->
search_and_print ~servers ~timeout words)
|> Command.run
================================================
FILE: code/async/search_with_timeout_simple.ml
================================================
open Core.Std
open Async.Std
(* Generate a DuckDuckGo search URI from a query string *)
let query_uri ~server query =
let base_uri =
Uri.of_string (String.concat ["http://";server;"/?format=json"])
in
Uri.add_query_param base_uri ("q", [query])
(* Extract the "Definition" or "Abstract" field from the DuckDuckGo results *)
let get_definition_from_json json =
match Yojson.Safe.from_string json with
| `Assoc kv_list ->
let find key =
begin match List.Assoc.find kv_list key with
| None | Some (`String "") -> None
| Some s -> Some (Yojson.Safe.to_string s)
end
in
begin match find "Abstract" with
| Some _ as x -> x
| None -> find "Definition"
end
| _ -> None
(* Execute the DuckDuckGo search *)
let get_definition ~server word =
try_with (fun () ->
Cohttp_async.Client.get (query_uri ~server word)
>>= fun (_, body) ->
Pipe.to_list body
>>| fun strings ->
(word, get_definition_from_json (String.concat strings)))
>>| function
| Ok (word,result) -> (word, Ok result)
| Error exn -> (word, Error exn)
let get_definition_with_timeout ~server ~timeout word =
choose
[ choice (after timeout) (fun () -> (word,Error "Timed out"))
; choice (get_definition ~server word)
(fun (word,result) ->
let result' = match result with
| Ok x -> Ok x
| Error _ -> Error "Unexpected failure"
in
(word,result')
)
]
(* Print out a word/definition pair *)
let print_result (word,definition) =
printf "%s\n%s\n\n%s\n\n"
word
(String.init (String.length word) ~f:(fun _ -> '-'))
(match definition with
| Error msg -> "ERROR: " ^ msg
| Ok None -> "No definition found"
| Ok (Some def) ->
String.concat ~sep:"\n"
(Wrapper.wrap (Wrapper.make 70) def))
(* Run many searches in parallel, printing out the results after they're all
done. *)
let search_and_print ~server ~timeout words =
Deferred.all (List.map words
~f:(get_definition_with_timeout ~timeout ~server))
>>| fun results ->
List.iter results ~f:print_result
let () =
Command.async_basic
~summary:"Retrieve definitions from duckduckgo search engine"
Command.Spec.(
empty
+> anon (sequence ("word" %: string))
+> flag "-server" (optional_with_default "api.duckduckgo.com" string)
~doc:" Specify server to connect to"
+> flag "-timeout" (optional_with_default (sec 5.) time_span)
~doc:" Abandon queries that take longer than this time"
)
(fun words server timeout () ->
search_and_print ~server ~timeout words)
|> Command.run
================================================
FILE: code/async/test.txt
================================================
This is only a test.
================================================
FILE: code/async/thread_exp_async_busy_loop.ml
================================================
open Core.Std
open Async.Std
open Thread_exp_common
(* part 1 *)
let busy_loop n =
let x = ref None in
for i = 1 to 100_000_000 do x := Some i done
let () =
don't_wait_for
(log_delays (Deferred.unit >>= busy_loop))
(* part 2 *)
let () = finish ()
================================================
FILE: code/async/thread_exp_async_busy_loop_in_thread.ml
================================================
open Core.Std
open Async.Std
open Thread_exp_common
(* part 1 *)
let busy_loop n =
let x = ref None in
for i = 1 to 100_000_000 do x := Some i done
let () =
don't_wait_for
(log_delays (In_thread.run busy_loop))
(* part 2 *)
let () = finish ()
================================================
FILE: code/async/thread_exp_async_noalloc_busy_loop.ml
================================================
open Core.Std
open Async.Std
open Thread_exp_common
(* part 1 *)
let busy_loop () =
for i = 1 to 200_000_000 do () done
let () =
don't_wait_for
(log_delays (In_thread.run busy_loop))
(* part 2 *)
let () = finish ()
================================================
FILE: code/async/thread_exp_async_noalloc_busy_loop_in_thread.ml
================================================
open Core.Std
open Async.Std
open Thread_exp_common
(* part 1 *)
let busy_loop () =
for i = 1 to 200_000_000 do () done
let () =
don't_wait_for
(log_delays (In_thread.run busy_loop))
(* part 2 *)
let () = finish ()
================================================
FILE: code/async/thread_exp_async_only.ml
================================================
open Core.Std
open Async.Std
open Thread_exp_common
let () =
Command.async_basic
~summary:"run logger without busy loop"
Command.Spec.(empty)
(fun () ->
log_delays (after (sec 1.))
)
|> Command.run
================================================
FILE: code/async/thread_exp_common.ml
================================================
open Core.Std
open Async.Std
let log_delays d =
let start = Time.now () in
let rec loop stamps =
let delay = Time.diff (Time.now ()) start in
match Deferred.peek d with
| Some () -> return (delay :: stamps)
| None ->
after (sec 0.1)
>>= fun () ->
loop (delay :: stamps)
in
loop []
>>| fun delays ->
let sexp = <:sexp_of<Time.Span.t list>> (List.rev delays) in
printf "%s\n" (Sexp.to_string sexp)
let finish () =
shutdown 0;
never_returns (Scheduler.go ())
================================================
FILE: code/async/thread_experiments.ml
================================================
open Core.Std
open Async.Std
let log_delays thunk =
let start = Time.now () in
let print_time () =
let diff = Time.diff (Time.now ()) start in
Caml.Printf.printf ".%!";
printf "%s, " (Time.Span.to_string diff)
in
let d = thunk () in
Clock.every (sec 0.1) ~stop:d print_time;
d >>| fun () -> print_time (); printf "\n"
type how_to_wait =
| After
| Busyloop
| Busyloop_in_thread
| Noalloc_busyloop_in_thread
| Noalloc_busyloop_in_thread_2
with sexp
let busyloop () =
let x = ref None in
for i = 1 to 50_000_000 do x := Some i done
let noalloc_busyloop () =
for _i = 1 to 50_000_000 do () done
let noalloc_busyloop_2 () =
let rec loop i =
if i = 0 then () else loop (i-1)
in
loop 50_000_000
let wait_and_log how_to_wait =
let until = match how_to_wait with
| After -> (fun () -> after (sec 1.))
| Busyloop -> (fun () -> busyloop (); return ())
| Busyloop_in_thread -> (fun () -> In_thread.run busyloop)
| Noalloc_busyloop_in_thread -> (fun () -> In_thread.run noalloc_busyloop)
| Noalloc_busyloop_in_thread_2 -> (fun () -> In_thread.run noalloc_busyloop_2)
in
log_delays until
let how_to_wait =
Command.Spec.Arg_type.create
(fun s -> Sexp.of_string s |> how_to_wait_of_sexp)
let () =
Command.async_basic
~summary:"run logger without busy loop"
Command.Spec.(
empty
+> anon ("how-to-wait" %: how_to_wait)
)
(fun how () -> wait_and_log how)
|> Command.run
================================================
FILE: code/async/timeout_search.ml
================================================
open Core.Std
open Async.Std
module Cohttp = Cohttp_async
(* Generate a DuckDuckGo search URI from a query string *)
let query_uri =
let base_uri = Uri.of_string "http://api.duckduckgo.com/?format=json" in
fun query -> Uri.add_query_param base_uri ("q", [query])
(* Extract the "Definition" field from the DuckDuckGo results *)
let get_definition_from_json json =
match Yojson.Safe.from_string json with
| `Assoc kv_list ->
begin match List.Assoc.find kv_list "Definition" with
| None | Some (`String "") -> Or_error.error_string "No definition found"
| Some s -> Ok (Yojson.Safe.to_string s)
end
| _ -> Or_error.error_string "malformed reply"
(* Execute the DuckDuckGo search *)
let get_definition ~timeout word =
let get =
Cohttp.Client.call `GET (query_uri word)
>>= fun (_, body) ->
Pipe.to_list body
>>| fun strings ->
get_definition_from_json (String.concat strings)
in
match timeout with
| None -> get
| Some timeout ->
let timeout = Clock.after timeout in
choose [ choice get Fn.id
; choice timeout (fun () -> Or_error.error_string "timed out")
]
(* Run a single search and print out the results *)
let run_one_search ~timeout search_string =
get_definition ~timeout search_string >>| fun result ->
printf "%-10s : %s\n" search_string
(match result with
| Ok x -> x
| Error err -> "{" ^ Error.to_string_hum err ^ "}")
(* Run many searches in parallel, printing out the results as you go *)
let run_many_searches ~parallel ~timeout search_strings =
Deferred.List.iter search_strings ~f:(run_one_search ~timeout)
~how:(if parallel then `Parallel else `Sequential)
let () =
Command.async_basic
~summary:"Retrieve definitions from duckduckgo search engine"
Command.Spec.(
empty
+> flag "-timeout" (optional time_span) ~doc:" Whether to run queries in parallel"
+> flag "-parallel" no_arg ~doc:" Run queries in parallel"
+> anon (sequence ("search term" %: string))
)
(fun timeout parallel search_strings () ->
run_many_searches ~parallel ~timeout search_strings)
|> Command.run
================================================
FILE: code/back-end/alternate_list.ml
================================================
open Core.Std
let rec take =
function
|[] -> []
|hd::tl -> hd :: (skip tl)
and skip =
function
|[] -> []
|_::tl -> take tl
let () =
take [1;2;3;4;5;6;7;8;9]
|> List.map ~f:string_of_int
|> String.concat ~sep:","
|> print_endline
================================================
FILE: code/back-end/asm_from_compare_mono.sh
================================================
ocamlopt -inline 20 -nodynlink -S compare_mono.ml
================================================
FILE: code/back-end/cmp.S
================================================
_camlCompare_mono__cmp_1008:
.cfi_startproc
.L101:
cmpq %rbx, %rax
jle .L100
ret
.align 2
.L100:
movq %rbx, %rax
ret
.cfi_endproc
================================================
FILE: code/back-end/compare_mono.ml
================================================
let cmp (a:int) (b:int) =
if a > b then a else b
================================================
FILE: code/back-end/compare_mono.s
================================================
.data
.globl _camlCompare_mono__data_begin
_camlCompare_mono__data_begin:
.text
.globl _camlCompare_mono__code_begin
_camlCompare_mono__code_begin:
nop
.data
.quad 1024
.globl _camlCompare_mono
_camlCompare_mono:
.space 8
.data
.quad 3319
_camlCompare_mono__1:
.quad _caml_curry2
.quad 5
.quad _camlCompare_mono__cmp_1008
.text
.align 4
.globl _camlCompare_mono__cmp_1008
_camlCompare_mono__cmp_1008:
.cfi_startproc
.L101:
cmpq %rbx, %rax
jle .L100
ret
.align 2
.L100:
movq %rbx, %rax
ret
.cfi_endproc
.text
.align 4
.globl _camlCompare_mono__entry
_camlCompare_mono__entry:
.cfi_startproc
.L102:
leaq _camlCompare_mono__1(%rip), %rax
movq %rax, _camlCompare_mono(%rip)
movq $1, %rax
ret
.cfi_endproc
.data
.text
nop
.globl _camlCompare_mono__code_end
_camlCompare_mono__code_end:
.data
.globl _camlCompare_mono__data_end
_camlCompare_mono__data_end:
.long 0
.globl _camlCompare_mono__frametable
_camlCompare_mono__frametable:
.quad 0
================================================
FILE: code/back-end/compare_poly.ml
================================================
let cmp a b =
if a > b then a else b
================================================
FILE: code/back-end/compare_poly_asm.S
================================================
_camlCompare_poly__cmp_1008:
.cfi_startproc
subq $24, %rsp
.cfi_adjust_cfa_offset 24
.L101:
movq %rax, 8(%rsp)
movq %rbx, 0(%rsp)
movq %rax, %rdi
movq %rbx, %rsi
leaq _caml_greaterthan(%rip), %rax
call _caml_c_call
.L102:
leaq _caml_young_ptr(%rip), %r11
movq (%r11), %r15
cmpq $1, %rax
je .L100
movq 8(%rsp), %rax
addq $24, %rsp
.cfi_adjust_cfa_offset -24
ret
.cfi_adjust_cfa_offset 24
.align 2
.L100:
movq 0(%rsp), %rax
addq $24, %rsp
.cfi_adjust_cfa_offset -24
ret
.cfi_adjust_cfa_offset 24
.cfi_endproc
================================================
FILE: code/back-end/gdb_alternate0.rawsh
================================================
$ gdb ./alternate_list.native
GNU gdb (GDB) 7.4.1-debian
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/avsm/alternate_list.native...done.
(gdb)
================================================
FILE: code/back-end/gdb_alternate1.rawsh
================================================
(gdb) break camlAlternate_list__take_69242
Breakpoint 1 at 0x5658d0: file alternate_list.ml, line 5.
================================================
FILE: code/back-end/gdb_alternate2.rawsh
================================================
(gdb) run
Starting program: /home/avsm/alternate_list.native
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Breakpoint 1, camlAlternate_list__take_69242 () at alternate_list.ml:5
4 function
================================================
FILE: code/back-end/gdb_alternate3.rawsh
================================================
(gdb) cont
Continuing.
Breakpoint 1, camlAlternate_list__take_69242 () at alternate_list.ml:5
4 function
(gdb) cont
Continuing.
Breakpoint 1, camlAlternate_list__take_69242 () at alternate_list.ml:5
4 function
(gdb) bt
#0 camlAlternate_list__take_69242 () at alternate_list.ml:4
#1 0x00000000005658e7 in camlAlternate_list__take_69242 () at alternate_list.ml:6
#2 0x00000000005658e7 in camlAlternate_list__take_69242 () at alternate_list.ml:6
#3 0x00000000005659f7 in camlAlternate_list__entry () at alternate_list.ml:14
#4 0x0000000000560029 in caml_program ()
#5 0x000000000080984a in caml_start_program ()
#6 0x00000000008099a0 in ?? ()
#7 0x0000000000000000 in ?? ()
(gdb) clear camlAlternate_list__take_69242
Deleted breakpoint 1
(gdb) cont
Continuing.
1,3,5,7,9
[Inferior 1 (process 3546) exited normally]
================================================
FILE: code/back-end/instr_for_pattern_monomorphic_small.sh
================================================
ocamlc -dinstr pattern_monomorphic_small.ml 2>&1
================================================
FILE: code/back-end/lambda_for_pattern_monomorphic_large.sh
================================================
ocamlc -dlambda -c pattern_monomorphic_large.ml 2>&1
================================================
FILE: code/back-end/lambda_for_pattern_monomorphic_small.sh
================================================
ocamlc -dlambda -c pattern_monomorphic_small.ml 2>&1
================================================
FILE: code/back-end/lambda_for_pattern_polymorphic.sh
================================================
ocamlc -dlambda -c pattern_polymorphic.ml 2>&1
================================================
FILE: code/back-end/opam_switch.rawsh
================================================
$ opam switch 4.01.0dev+fp
================================================
FILE: code/back-end/pattern_monomorphic_large.ml
================================================
type t = | Alice | Bob | Charlie | David
let test v =
match v with
| Alice -> 100
| Bob -> 101
| Charlie -> 102
| David -> 103
================================================
FILE: code/back-end/pattern_monomorphic_small.ml
================================================
type t = | Alice | Bob
let test v =
match v with
| Alice -> 100
| Bob -> 101
================================================
FILE: code/back-end/pattern_polymorphic.ml
================================================
let test v =
match v with
| `Alice -> 100
| `Bob -> 101
| `Charlie -> 102
| `David -> 103
| `Eve -> 104
================================================
FILE: code/back-end/perf_record.rawsh
================================================
$ perf record -g ./barrier_bench.native
Estimated testing time 20s (change using -quota SECS).
Name Time (ns) Time 95ci Percentage
---- --------- --------- ----------
mutable 7_306_219 7_250_234-7_372_469 96.83
immutable 7_545_126 7_537_837-7_551_193 100.00
[ perf record: Woken up 11 times to write data ]
[ perf record: Captured and wrote 2.722 MB perf.data (~118926 samples) ]
perf record -g ./barrier.native
Estimated testing time 20s (change using -quota SECS).
Name Time (ns) Time 95ci Percentage
---- --------- --------- ----------
mutable 7_306_219 7_250_234-7_372_469 96.83
immutable 7_545_126 7_537_837-7_551_193 100.00
[ perf record: Woken up 11 times to write data ]
[ perf record: Captured and wrote 2.722 MB perf.data (~118926 samples) ]
================================================
FILE: code/back-end/perf_report.rawsh
================================================
$ perf report -g
+ 48.86% barrier.native barrier.native [.] camlBarrier__test_immutable_69282
+ 30.22% barrier.native barrier.native [.] camlBarrier__test_mutable_69279
+ 20.22% barrier.native barrier.native [.] caml_modify
================================================
FILE: code/back-end-bench/bench_patterns.ml
================================================
open Core.Std
open Core_bench.Std
type t = | Alice | Bob
type s = | A | B | C | D | E
let polymorphic_pattern () =
let test v =
match v with
| `Alice -> 100
| `Bob -> 101
| `Charlie -> 102
| `David -> 103
| `Eve -> 104
in
List.iter ~f:(fun v -> ignore(test v))
[`Alice; `Bob; `Charlie; `David]
let monomorphic_pattern_small () =
let test v =
match v with
| Alice -> 100
| Bob -> 101 in
List.iter ~f:(fun v -> ignore(test v))
[ Alice; Bob ]
let monomorphic_pattern_large () =
let test v =
match v with
| A -> 100
| B -> 101
| C -> 102
| D -> 103
| E -> 104
in
List.iter ~f:(fun v -> ignore(test v))
[ A; B; C; D ]
let tests = [
"Polymorphic pattern", polymorphic_pattern;
"Monomorphic larger pattern", monomorphic_pattern_large;
"Monomorphic small pattern", monomorphic_pattern_small;
]
let () =
List.map tests ~f:(fun (name,test) -> Bench.Test.create ~name test)
|> Bench.make_command
|> Command.run
================================================
FILE: code/back-end-bench/bench_poly_and_mono.ml
================================================
open Core.Std
open Core_bench.Std
let polymorphic_compare () =
let cmp a b = if a > b then a else b in
for i = 0 to 1000 do
ignore(cmp 0 i)
done
let monomorphic_compare () =
let cmp (a:int) (b:int) =
if a > b then a else b in
for i = 0 to 1000 do
ignore(cmp 0 i)
done
let tests =
[ "Polymorphic comparison", polymorphic_compare;
"Monomorphic comparison", monomorphic_compare ]
let () =
List.map tests ~f:(fun (name,test) -> Bench.Test.create ~name test)
|> Bench.make_command
|> Command.run
================================================
FILE: code/back-end-bench/run_alternate_list.sh
================================================
corebuild -tag debug alternate_list.native
./alternate_list.native -ascii
================================================
FILE: code/back-end-bench/run_bench_patterns.sh
================================================
corebuild -pkg core_bench bench_patterns.native
./bench_patterns.native -ascii
================================================
FILE: code/back-end-bench/run_bench_poly_and_mono.sh
================================================
corebuild -pkg core_bench bench_poly_and_mono.native
./bench_poly_and_mono.native -ascii
================================================
FILE: code/back-end-embed/build_embed.sh
================================================
rm -f embed_out.c
ocamlc -output-obj -o embed_out.o embed_me1.ml embed_me2.ml
================================================
FILE: code/back-end-embed/build_embed_binary.rawsh
================================================
$ gcc -fPIC -Wall -I`ocamlc -where` -L`ocamlc -where` -ltermcap -lm -ldl \
-o finalbc.native main.c embed_out.o -lcamlrun
$ ./finalbc.native
Before calling OCaml
hello embedded world 1
hello embedded world 2
After calling OCaml
================================================
FILE: code/back-end-embed/build_embed_c.sh
================================================
ocamlc -output-obj -o embed_out.c embed_me1.ml embed_me2.ml
================================================
FILE: code/back-end-embed/build_embed_native.rawsh
================================================
$ ocamlopt -output-obj -o embed_native.o embed_me1.ml embed_me2.ml
$ gcc -Wall -I `ocamlc -where` -o final.native embed_native.o main.c \
-L `ocamlc -where` -lasmrun -ltermcap -lm -ldl
$ ./final.native
Before calling OCaml
hello embedded world 1
hello embedded world 2
After calling OCaml
================================================
FILE: code/back-end-embed/embed_me1.ml
================================================
let () = print_endline "hello embedded world 1"
================================================
FILE: code/back-end-embed/embed_me2.ml
================================================
let () = print_endline "hello embedded world 2"
================================================
FILE: code/back-end-embed/embed_out.c
================================================
#ifdef __cplusplus
extern "C" {
#endif
#include <caml/mlvalues.h>
CAMLextern void caml_startup_code(
code_t code, asize_t code_size,
char *data, asize_t data_size,
char *section_table, asize_t section_table_size,
char **argv);
static int caml_code[] = {
0x00000054, 0x000003e3, 0x00000029, 0x0000002a, 0x00000001, 0x00000000,
0x00000056, 0x0000000e, 0x00000000, 0x00000044, 0x0000000b, 0x00000043,
0x0000000d, 0x0000000c, 0x00000032, 0x00000022, 0x0000000b, 0x00000040,
0x00000000, 0x00000028, 0x00000004, 0x00000001, 0x00000028, 0x00000002,
0x00000029, 0x0000002a, 0x00000003, 0x00000003, 0x00000085, 0x00000000,
0x00000004, 0x00000063, 0x00000028, 0x00000004, 0x00000003, 0x0000000d,
0x0000000d, 0x0000000d, 0x00000060, 0x0000009f, 0x0000000a, 0x00000084,
0x00000000, 0x00000006, 0x00000035, 0x00000004, 0x0000003f, 0x00000000,
0x0000005b, 0x00000000, 0x0000000f, 0x0000006f, 0x0000000b, 0x0000000f,
0x0000006e, 0x0000000e, 0x0000000e, 0x00000032, 0x00000024, 0x00000004,
0x00000009, 0x00000000, 0x0000005d, 0x0000009d, 0x00000028, 0x00000001,
0x00000029, 0x0000002a, 0x00000001, 0x00000001, 0x0000000b, 0x0000005e,
0x000000a7, 0x00000028, 0x00000002, 0x00000029, 0x0000002a, 0x00000001,
0x00000001, 0x0000000b, 0x0000005e, 0x000000a7, 0x00000028, 0x00000002,
0x00000029, 0x0000002a, 0x00000001, 0x00000001, 0x0000000b, 0x0000005e,
0x000000a8, 0x00000028, 0x00000002, 0x00000029, 0x0000002a, 0x00000001,
0x00000001, 0x0000000b, 0x0000005e, 0x000000b0, 0x00000028, 0x00000002,
0x00000000, 0x0000005d, 0x000000ac, 0x00000028, 0x00000001, 0x00000000,
0x0000005d, 0x0000009a, 0x00000028, 0x00000001, 0x00000029, 0x0000002a,
0x00000001, 0x00000001, 0x0000000b, 0x0000005e, 0x000000b2, 0x00000028,
0x00000002, 0x00000000, 0x0000005d, 0x000000a0, 0x00000028, 0x00000001,
0x00000000, 0x0000005d, 0x000000a0, 0x00000028, 0x00000001, 0x00000000,
0x0000005d, 0x000000a1, 0x00000028, 0x00000001, 0x00000000, 0x0000005d,
0x00000052, 0x00000028, 0x00000001, 0x00000029, 0x0000002a, 0x00000001,
0x00000001, 0x0000000b, 0x0000005e, 0x000000ae, 0x00000028, 0x00000002,
0x00000000, 0x0000005d, 0x000000aa, 0x00000028, 0x00000001, 0x00000000,
0x0000005d, 0x0000009a, 0x00000028, 0x00000001, 0x00000000, 0x0000005d,
0x0000009c, 0x00000028, 0x00000001, 0x00000029, 0x0000002a, 0x00000001,
0x00000001, 0x0000000b, 0x0000005e, 0x000000b2, 0x00000028, 0x00000002,
0x00000029, 0x0000002a, 0x00000001, 0x00000001, 0x0000000b, 0x0000005e,
0x000000b1, 0x00000028, 0x00000002, 0x00000000, 0x0000005d, 0x000000ad,
0x00000028, 0x00000001, 0x00000000, 0x0000005d, 0x0000009b, 0x00000028,
0x00000001, 0x00000029, 0x0000002a, 0x00000001, 0x00000001, 0x0000000b,
0x0000005e, 0x000000af, 0x00000028, 0x00000002, 0x00000000, 0x0000005d,
0x000000ab, 0x00000028, 0x00000001, 0x00000000, 0x0000005d, 0x0000009b,
0x00000028, 0x00000001, 0x00000063, 0x0000001a, 0x00000021, 0x00000000,
0x0000005d, 0x00000100, 0x00000028, 0x00000001, 0x00000063, 0x0000001a,
0x00000043, 0x00000025, 0x00000002, 0x00000063, 0x0000001a, 0x00000021,
0x00000063, 0x0000001b, 0x00000025, 0x00000002, 0x00000015, 0x00000043,
0x0000000a, 0x0000000c, 0x0000002b, 0x00000002, 0xfffffff3, 0x0000001a,
0x00000049, 0x00000028, 0x00000002, 0x00000000, 0x0000000a, 0x0000005d,
0x000000b3, 0x0000000a, 0x0000005d, 0x00000023, 0x0000000b, 0x00000068,
0x0000000c, 0x00000068, 0x00000010, 0x00000061, 0x00000019, 0x00000000,
0x00000028, 0x00000004, 0x00000029, 0x0000002a, 0x00000001, 0x00000001,
0x00000036, 0x0000000c, 0x0000001a, 0x00000022, 0x0000000b, 0x0000001a,
0x00000026, 0x00000004, 0x00000063, 0x0000001a, 0x00000021, 0x0000005d,
0x00000034, 0x00000028, 0x00000001, 0x00000063, 0x0000001a, 0x00000021,
0x0000005d, 0x00000087, 0x00000028, 0x00000001, 0x00000016, 0x0000005d,
0x0000009d, 0x00000015, 0x0000001c, 0x00000025, 0x00000002, 0x00000067,
0x0000000a, 0x0000001a, 0x0000005e, 0x000000a7, 0x00000015, 0x0000005d,
0x0000009d, 0x00000028, 0x00000001, 0x00000000, 0x0000001a, 0x0000001b,
0x00000022, 0x00000067, 0x0000000a, 0x0000001a, 0x0000005e, 0x000000a7,
0x00000015, 0x0000005d, 0x0000009d, 0x00000028, 0x00000001, 0x00000000,
0x0000001a, 0x00000021, 0x0000001b, 0x0000001c, 0x00000026, 0x00000003,
0x00000000, 0x0000001a, 0x00000021, 0x0000001b, 0x0000001c, 0x00000026,
0x00000003, 0x00000000, 0x0000001a, 0x0000001b, 0x00000026, 0x00000003,
0x00000000, 0x0000001a, 0x0000005e, 0x000000a7, 0x00000028, 0x00000001,
0x00000067, 0x0000000a, 0x0000001a, 0x0000005e, 0x000000a7, 0x00000015,
0x0000005d, 0x0000009d, 0x00000028, 0x00000001, 0x00000000, 0x0000001a,
0x0000001b, 0x00000022, 0x00000067, 0x0000000a, 0x0000001a, 0x0000005e,
0x000000a7, 0x00000015, 0x0000005d, 0x0000009d, 0x00000028, 0x00000001,
0x00000000, 0x0000001a, 0x00000021, 0x0000001b, 0x0000001c, 0x00000026,
0x00000003, 0x00000000, 0x0000001a, 0x00000021, 0x0000001b, 0x0000001c,
0x00000026, 0x00000003, 0x00000000, 0x0000001a, 0x0000001b, 0x00000026,
0x00000003, 0x00000000, 0x0000001a, 0x0000005e, 0x000000a7, 0x00000028,
0x00000001, 0x00000059, 0x00000007, 0x00000004, 0x0000005d, 0x0000009c,
0x0000005a, 0x00000028, 0x00000001, 0x00000068, 0x00000028, 0x00000002,
0x00000029, 0x0000002a, 0x00000002, 0x00000002, 0x00000056, 0x00000019,
0x00000002, 0x00000044, 0x0000000d, 0x00000043, 0x0000000a, 0x0000005d,
0x000000b3, 0x0000000a, 0x0000000b, 0x00000010, 0x0000006f, 0x0000000f,
0x00000068, 0x0000000f, 0x00000061, 0x00000019, 0x00000002, 0x0000000b,
0x00000010, 0x0000006f, 0x0000000f, 0x00000032, 0x00000027, 0x00000009,
0x00000000, 0x00000028, 0x00000003, 0x00000029, 0x0000002a, 0x00000001,
0x00000015, 0x0000005d, 0x000000a2, 0x0000000a, 0x00000084, 0x00000000,
0x00000011, 0x00000001, 0x00000056, 0x00000009, 0x00000001, 0x0000000d,
0x0000000e, 0x0000005d, 0x00000023, 0x0000001b, 0x00000027, 0x00000006,
0x00000035, 0x00000004, 0x0000003f, 0x00000000, 0x0000005b, 0x00000000,
0x00000088, 0x00000000, 0x00000029, 0x00000000, 0x0000007f, 0xffffffff,
0x0000005d, 0x00000023, 0x0000000b, 0x0000007f, 0xffffffff, 0x00000068,
0x0000000c, 0x0000001a, 0x00000060, 0x0000009f, 0x00000063, 0x00000015,
0x0000005d, 0x000000a0, 0x00000063, 0x00000002, 0x00000056, 0x00000011,
0x00000001, 0x0000000e, 0x0000006e, 0x0000007f, 0xffffffff, 0x0000000d,
0x0000000c, 0x00000040, 0x00000000, 0x0000000b, 0x0000000c, 0x0000005d,
0x00000023, 0x0000001b, 0x00000027, 0x00000008, 0x00000000, 0x00000028,
0x00000004, 0x00000000, 0x0000006d, 0x0000005d, 0x00000023, 0x0000000b,
0x0000006d, 0x00000068, 0x0000000c, 0x0000001a, 0x00000060, 0x0000009f,
0x00000063, 0x00000001, 0x0000000e, 0x0000006f, 0x0000000d, 0x0000000c,
0x00000040, 0x00000000, 0x00000032, 0x00000026, 0x00000006, 0x0000002c,
0x00000001, 0x00000000, 0xffffff81, 0x00000000, 0x0000000c, 0x0000002c,
0x00000001, 0x00000002, 0xffffff9c, 0x00000063, 0x00000068, 0x0000000c,
0x00000026, 0x00000005, 0x00000029, 0x0000002a, 0x00000003, 0x00000002,
0x00000087, 0x00000000, 0x0000000e, 0x00000003, 0x00000087, 0x00000000,
0x0000000a, 0x00000003, 0x0000000c, 0x0000005d, 0x000000b3, 0x0000006f,
0x0000000d, 0x0000007d, 0x00000056, 0x00000006, 0x00000035, 0x0000000d,
0x0000001a, 0x00000025, 0x00000005, 0x00000003, 0x0000000d, 0x0000000d,
0x0000000d, 0x0000001b, 0x00000024, 0x00000004, 0x00000008, 0x00000029,
0x0000002a, 0x00000003, 0x00000002, 0x00000087, 0x00000000, 0x0000000e,
0x00000003, 0x00000087, 0x00000000, 0x0000000a, 0x00000003, 0x0000000c,
0x0000005d, 0x000000b3, 0x0000006f, 0x0000000d, 0x0000007d, 0x00000056,
0x00000006, 0x00000035, 0x0000000e, 0x0000001a, 0x00000025, 0x00000005,
0x00000003, 0x0000000d, 0x0000000d, 0x0000000d, 0x00000060, 0x0000009f,
0x00000028, 0x00000004, 0x00000000, 0x00000068, 0x00000036, 0x0000000f,
0x0000001a, 0x00000027, 0x00000004, 0x00000000, 0x00000068, 0x00000036,
0x00000010, 0x0000001a, 0x00000027, 0x00000004, 0x00000029, 0x0000002a,
0x00000002, 0x00000001, 0x0000000b, 0x0000000e, 0x0000005f, 0x00000107,
0x0000005d, 0x000000a3, 0x00000028, 0x00000003, 0x00000059, 0x00000007,
0x00000004, 0x0000005d, 0x0000009d, 0x0000005a, 0x00000054, 0x00000004,
0x00000068, 0x00000013, 0x00000001, 0x00000059, 0x00000007, 0x00000004,
0x0000005d, 0x0000009c, 0x0000005a, 0x00000028, 0x00000001, 0x00000068,
0x00000028, 0x00000002, 0x00000000, 0x0000005d, 0x0000009d, 0x00000000,
0x0000005d, 0x0000009c, 0x00000028, 0x00000001, 0x00000029, 0x0000002a,
0x00000001, 0x00000063, 0x0000000c, 0x0000000c, 0x0000005f, 0x000000d7,
0x00000028, 0x00000002, 0x00000029, 0x0000002a, 0x00000003, 0x00000002,
0x00000087, 0x00000000, 0x0000000e, 0x00000003, 0x00000087, 0x00000000,
0x0000000a, 0x00000003, 0x0000000c, 0x0000005d, 0x000000b3, 0x0000006f,
0x0000000d, 0x0000007d, 0x00000056, 0x00000006, 0x00000035, 0x00000011,
0x0000001a, 0x00000025, 0x00000005, 0x00000003, 0x0000000d, 0x0000000d,
0x0000000d, 0x00000060, 0x000000a6, 0x00000028, 0x00000004, 0x00000029,
0x0000002a, 0x00000001, 0x00000001, 0x0000005d, 0x000000b3, 0x00000068,
0x0000000d, 0x0000000d, 0x00000060, 0x000000a6, 0x00000028, 0x00000002,
0x00000000, 0x00000056, 0x00000015, 0x00000000, 0x00000044, 0x0000000b,
0x00000043, 0x00000009, 0x00000059, 0x00000007, 0x00000004, 0x0000005d,
0x0000009d, 0x0000005a, 0x00000054, 0x00000004, 0x00000068, 0x00000013,
0x00000001, 0x00000001, 0x00000032, 0x00000025, 0x00000004, 0x00000063,
0x00000028, 0x00000001, 0x0000002c, 0x00000001, 0x00000000, 0xffffffe3,
0x00000063, 0x0000005d, 0x000000a5, 0x0000000b, 0x00000025, 0x00000003,
0x00000000, 0x0000006c, 0x000001b6, 0x00000036, 0x00000012, 0x0000001a,
0x00000027, 0x00000004, 0x00000000, 0x0000006c, 0x000001b6, 0x00000036,
0x00000013, 0x0000001a, 0x00000027, 0x00000004, 0x00000029, 0x0000002a,
0x00000002, 0x00000001, 0x0000000b, 0x0000000e, 0x0000005f, 0x00000107,
0x0000005d, 0x000000a4, 0x00000028, 0x00000003, 0x00000000, 0x00000036,
0x00000014, 0x0000005e, 0x00000037, 0x0000001a, 0x00000025, 0x00000002,
0x00000017, 0x0000000b, 0x0000007e, 0x00000056, 0x00000007, 0x00000035,
0x00000015, 0x0000001b, 0x0000001a, 0x00000026, 0x00000003, 0x00000000,
0x0000001b, 0x0000005e, 0x000000eb, 0x0000000a, 0x00000087, 0x00000030,
0x00000007, 0x00000000, 0x00000086, 0x0000003a, 0x00000009, 0x00000054,
0x0000000a, 0x00000000, 0x00000084, 0x0000002d, 0x00000003, 0x00000054,
0x00000004, 0x00000016, 0x00000028, 0x00000002, 0x00000001, 0x0000007f,
0x00000001, 0x00000032, 0x00000025, 0x00000003, 0x00000000, 0x0000005d,
0x000000b3, 0x0000000a, 0x0000000c, 0x0000001a, 0x0000002c, 0x00000001,
0x00000003, 0xffffffcf, 0x00000063, 0x0000000b, 0x00000025, 0x00000004,
0x00000000, 0x00000036, 0x00000016, 0x0000005e, 0x00000038, 0x00000028,
0x00000001, 0x00000035, 0x00000017, 0x0000000b, 0x0000005e, 0x000000f3,
0x00000056, 0x00000010, 0x00000035, 0x00000018, 0x0000000b, 0x0000005e,
0x000000f3, 0x00000056, 0x00000006, 0x00000035, 0x00000019, 0x0000001a,
0x00000025, 0x00000002, 0x00000064, 0x00000028, 0x00000001, 0x00000063,
0x00000028, 0x00000001, 0x00000000, 0x00000056, 0x00000005, 0x00000035,
0x0000001a, 0x00000028, 0x00000001, 0x00000035, 0x0000001b, 0x00000028,
0x00000001, 0x00000000, 0x00000087, 0x00000000, 0x00000005, 0x00000000,
0x00000088, 0x000000ff, 0x00000006, 0x00000035, 0x0000001c, 0x0000001a,
0x00000025, 0x00000002, 0x00000000, 0x00000028, 0x00000001, 0x00000029,
0x0000002a, 0x00000001, 0x00000000, 0x0000005d, 0x000000b3, 0x0000000c,
0x0000005d, 0x000000b3, 0x0000000a, 0x0000000c, 0x0000006e, 0x0000005d,
0x00000023, 0x0000000c, 0x00000068, 0x0000000c, 0x00000068, 0x00000011,
0x00000061, 0x00000019, 0x00000001, 0x0000000d, 0x0000000c, 0x00000068,
0x00000012, 0x00000008, 0x00000061, 0x00000019, 0x00000000, 0x00000028,
0x00000005, 0x00000067, 0xffffffff, 0x0000000b, 0x00000075, 0x00000028,
0x00000001, 0x00000000, 0x00000087, 0x00000000, 0x00000004, 0x00000000,
0x00000028, 0x00000001, 0x00000000, 0x0000006d, 0x00000028, 0x00000001,
0x00000029, 0x0000002a, 0x00000001, 0x00000001, 0x0000000b, 0x0000005e,
0x0000004c, 0x00000056, 0x00000004, 0x00000000, 0x00000028, 0x00000002,
0x00000001, 0x00000028, 0x00000002, 0x00000029, 0x0000002a, 0x00000001,
0x00000001, 0x0000000b, 0x0000005e, 0x0000008e, 0x00000056, 0x00000004,
0x00000000, 0x00000028, 0x00000002, 0x00000001, 0x00000028, 0x00000002,
0x00000000, 0x00000036, 0x00000003, 0x00000040, 0x00000000, 0x0000005b,
0x00000000, 0x00000036, 0x00000002, 0x00000040, 0x00000000, 0x0000005b,
0x0000002b, 0x00000000, 0xfffffff8, 0x00000009, 0x0000002b, 0x00000000,
0xffffffee, 0x00000036, 0x0000001d, 0x0000003f, 0x00000000, 0x00000009,
0x0000002b, 0x00000000, 0xffffffd8, 0x00000009, 0x0000002b, 0x00000000,
0xffffffc5, 0x00000009, 0x0000002b, 0x00000000, 0xffffffb5, 0x00000009,
0x0000002b, 0x00000000, 0xffffffab, 0x0000006c, 0x0000001f, 0x00000069,
0x00000076, 0x00000084, 0x00000000, 0x00000005, 0x00000067, 0x0000001e,
0x00000054, 0x00000003, 0x00000067, 0x0000003e, 0x00000069, 0x00000076,
0x0000000a, 0x0000007f, 0xffffffff, 0x00000036, 0x0000001e, 0x0000005d,
0x00000071, 0x00000036, 0x0000001f, 0x0000005d, 0x00000071, 0x00000036,
0x00000020, 0x0000005d, 0x00000071, 0x00000036, 0x00000021, 0x0000005d,
0x00000071, 0x00000036, 0x00000022, 0x0000005d, 0x00000071, 0x00000036,
0x00000023, 0x0000005d, 0x00000071, 0x00000009, 0x0000002b, 0x00000000,
0xffffff5e, 0x00000012, 0x0000000e, 0x0000002b, 0x00000001, 0xffffff48,
0x00000009, 0x0000002b, 0x00000000, 0xffffff39, 0x00000012, 0x00000010,
0x0000002b, 0x00000001, 0xffffff1b, 0x00000009, 0x0000002b, 0x00000000,
0xffffff10, 0x00000009, 0x0000003a, 0x0000000f, 0x0000002b, 0x00000001,
0xfffffefc, 0x0000000a, 0x0000002b, 0x00000001, 0xfffffec8, 0x00000009,
0x0000002c, 0x00000001, 0x00000000, 0xfffffbb6, 0x00000063, 0x0000005d,
0x000000a3, 0x00000069, 0x0000005d, 0x000000a4, 0x0000006a, 0x0000005d,
0x000000a4, 0x00000009, 0x0000002b, 0x00000000, 0xfffffeab, 0x0000000a,
0x0000002b, 0x00000001, 0xfffffe9e, 0x0000000b, 0x0000002b, 0x00000001,
0xfffffe92, 0x00000009, 0x0000002b, 0x00000000, 0xfffffe84, 0x00000009,
0x0000002b, 0x00000000, 0xfffffe5a, 0x00000012, 0x0000001e, 0x0000002b,
0x00000001, 0xfffffe34, 0x00000009, 0x0000002b, 0x00000000, 0xfffffe26,
0x00000009, 0x0000002b, 0x00000000, 0xfffffe19, 0x00000009, 0x0000002b,
0x00000000, 0xfffffdff, 0x00000009, 0x0000002b, 0x00000000, 0xfffffdf0,
0x0000000a, 0x0000002b, 0x00000001, 0xfffffde4, 0x0000000b, 0x0000002b,
0x00000001, 0xfffffdd9, 0x00000012, 0x00000025, 0x0000002b, 0x00000001,
0xfffffdb4, 0x00000009, 0x0000002c, 0x00000001, 0x00000000, 0xfffffb88,
0x00000000, 0x00000012, 0x00000028, 0x0000002b, 0x00000002, 0xfffffd88,
0x00000009, 0x0000002b, 0x00000000, 0xfffffd74, 0x00000009, 0x0000002b,
0x00000000, 0xfffffce8, 0x00000012, 0x00000012, 0x0000002b, 0x00000001,
0xfffffcdd, 0x00000012, 0x0000000d, 0x00000012, 0x00000014, 0x0000002b,
0x00000002, 0xfffffcd1, 0x00000012, 0x0000000e, 0x00000012, 0x00000015,
0x00000012, 0x0000001c, 0x0000002b, 0x00000003, 0xfffffcc1, 0x00000012,
0x0000000f, 0x00000012, 0x00000016, 0x00000012, 0x0000001a, 0x0000002b,
0x00000003, 0xfffffcb1, 0x00000012, 0x00000010, 0x00000012, 0x00000017,
0x0000002b, 0x00000002, 0xfffffc9c, 0x00000012, 0x00000017, 0x0000002b,
0x00000001, 0xfffffc8d, 0x00000012, 0x00000017, 0x0000002b, 0x00000001,
0xfffffc82, 0x00000012, 0x00000013, 0x00000012, 0x00000019, 0x0000002b,
0x00000002, 0xfffffc76, 0x00000012, 0x00000014, 0x00000012, 0x0000001a,
0x00000012, 0x00000022, 0x0000002b, 0x00000003, 0xfffffc66, 0x00000012,
0x00000015, 0x00000012, 0x0000001b, 0x00000012, 0x00000020, 0x0000002b,
0x00000003, 0xfffffc56, 0x00000012, 0x00000016, 0x00000012, 0x0000001c,
0x0000002b, 0x00000002, 0xfffffc41, 0x00000012, 0x0000001c, 0x0000002b,
0x00000001, 0xfffffc32, 0x00000012, 0x0000000d, 0x00000012, 0x0000001f,
0x00000012, 0x00000021, 0x0000002b, 0x00000003, 0xfffffc22, 0x0000000a,
0x0000002b, 0x00000001, 0xfffffc17, 0x0000000b, 0x0000002b, 0x00000001,
0xfffffc0c, 0x00000009, 0x0000003a, 0x00000012, 0x0000002c, 0x0000002b,
0x00000001, 0xfffffbfa, 0x00000009, 0x0000002b, 0x00000000, 0xfffffbe4,
0x00000012, 0x0000001f, 0x0000003f, 0x00000000, 0x0000000a, 0x0000002b,
0x00000001, 0xfffffbd1, 0x0000000b, 0x0000002b, 0x00000001, 0xfffffbc1,
0x0000000a, 0x0000002b, 0x00000001, 0xfffffbb5, 0x0000000b, 0x00000036,
0x00000024, 0x0000005e, 0x000000df, 0x00000001, 0x00000012, 0x0000001a,
0x00000012, 0x0000002e, 0x0000000f, 0x0000000e, 0x00000012, 0x0000000a,
0x00000012, 0x0000000a, 0x00000009, 0x0000002b, 0x00000000, 0xfffffb9c,
0x00000009, 0x0000002b, 0x00000000, 0xfffffb93, 0x00000009, 0x0000002b,
0x00000000, 0xfffffb87, 0x00000009, 0x0000002b, 0x00000000, 0xfffffb7d,
0x00000009, 0x0000002b, 0x00000000, 0xfffffb74, 0x00000009, 0x0000002b,
0x00000000, 0xfffffb68, 0x0000003e, 0x00000006, 0x00000000, 0x00000009,
0x0000002b, 0x00000000, 0xfffffb58, 0x00000012, 0x0000001f, 0x00000009,
0x0000002b, 0x00000000, 0xfffffb4c, 0x00000009, 0x0000002b, 0x00000000,
0xfffffb43, 0x00000009, 0x0000002b, 0x00000000, 0xfffffb3a, 0x00000009,
0x0000002b, 0x00000000, 0xfffffb2e, 0x00000009, 0x0000002b, 0x00000000,
0xfffffb24, 0x00000009, 0x0000002b, 0x00000000, 0xfffffb1b, 0x00000009,
0x0000002b, 0x00000000, 0xfffffb12, 0x00000012, 0x00000029, 0x00000012,
0x0000002c, 0x00000012, 0x0000002a, 0x00000009, 0x0000002b, 0x00000000,
0xfffffb03, 0x00000012, 0x00000032, 0x00000012, 0x00000031, 0x00000012,
0x00000033, 0x00000009, 0x0000002b, 0x00000000, 0xfffffaf1, 0x00000012,
0x00000037, 0x00000012, 0x00000039, 0x00000009, 0x0000002b, 0x00000000,
0xfffffae3, 0x00000009, 0x0000002b, 0x00000000, 0xfffffada, 0x00000009,
0x0000002b, 0x00000000, 0xffffface, 0x00000012, 0x0000003e, 0x00000009,
0x0000002b, 0x00000000, 0xfffffabf, 0x00000009, 0x0000002b, 0x00000000,
0xfffffab2, 0x00000012, 0x00000042, 0x00000012, 0x00000044, 0x00000009,
0x0000002b, 0x00000000, 0xfffffaa1, 0x00000012, 0x00000047, 0x00000009,
0x0000002b, 0x00000000, 0xfffffa95, 0x00000012, 0x0000004c, 0x00000012,
0x0000004b, 0x00000012, 0x0000004d, 0x00000012, 0x00000030, 0x00000012,
0x00000032, 0x00000012, 0x00000034, 0x00000012, 0x00000036, 0x00000012,
0x00000038, 0x00000012, 0x0000003a, 0x00000012, 0x0000003c, 0x00000012,
0x0000003e, 0x00000012, 0x00000040, 0x00000012, 0x00000042, 0x00000012,
0x00000044, 0x00000012, 0x00000046, 0x00000012, 0x00000048, 0x00000012,
0x0000004a, 0x00000012, 0x0000004c, 0x00000012, 0x0000005f, 0x00000012,
0x00000061, 0x00000012, 0x00000063, 0x00000012, 0x00000065, 0x00000012,
0x00000067, 0x00000012, 0x0000006b, 0x00000012, 0x0000006d, 0x00000012,
0x0000006f, 0x00000012, 0x00000071, 0x00000012, 0x00000073, 0x00000012,
0x00000075, 0x00000012, 0x00000077, 0x00000012, 0x00000079, 0x00000012,
0x0000007b, 0x00000012, 0x0000007d, 0x00000012, 0x0000007f, 0x00000012,
0x00000083, 0x00000012, 0x00000083, 0x00000012, 0x00000083, 0x00000012,
0x00000087, 0x00000012, 0x00000089, 0x00000012, 0x0000008b, 0x00000012,
0x0000008d, 0x00000012, 0x00000090, 0x00000012, 0x00000090, 0x0000003e,
0x00000051, 0x00000000, 0x00000013, 0x00000042, 0x00000039, 0x00000025,
0x00000035, 0x00000026, 0x00000038, 0x00000025, 0x0000001d, 0x00000021,
0x00000009, 0x0000003a, 0x00000013, 0x00000001, 0x00000039, 0x00000027,
0x00000035, 0x00000028, 0x00000038, 0x00000025, 0x0000001d, 0x00000021,
0x00000009, 0x0000003a, 0x00000013, 0x00000001, 0x00000039, 0x00000029,
0x8f};
static char caml_data[] = {
132, 149, 166, 190, 0, 0, 1, 211, 0, 0, 0, 60,
0, 0, 0, 254, 0, 0, 0, 204, 8, 0, 0, 168,
0, 144, 45, 79, 117, 116, 95, 111, 102, 95, 109, 101,
109, 111, 114, 121, 144, 41, 83, 121, 115, 95, 101, 114,
114, 111, 114, 144, 39, 70, 97, 105, 108, 117, 114, 101,
144, 48, 73, 110, 118, 97, 108, 105, 100, 95, 97, 114,
103, 117, 109, 101, 110, 116, 144, 43, 69, 110, 100, 95,
111, 102, 95, 102, 105, 108, 101, 144, 48, 68, 105, 118,
105, 115, 105, 111, 110, 95, 98, 121, 95, 122, 101, 114,
111, 144, 41, 78, 111, 116, 95, 102, 111, 117, 110, 100,
144, 45, 77, 97, 116, 99, 104, 95, 102, 97, 105, 108,
117, 114, 101, 144, 46, 83, 116, 97, 99, 107, 95, 111,
118, 101, 114, 102, 108, 111, 119, 144, 46, 83, 121, 115,
95, 98, 108, 111, 99, 107, 101, 100, 95, 105, 111, 144,
46, 65, 115, 115, 101, 114, 116, 95, 102, 97, 105, 108,
117, 114, 101, 144, 58, 85, 110, 100, 101, 102, 105, 110,
101, 100, 95, 114, 101, 99, 117, 114, 115, 105, 118, 101,
95, 109, 111, 100, 117, 108, 101, 34, 37, 44, 44, 114,
101, 97, 108, 108, 121, 95, 105, 110, 112, 117, 116, 37,
105, 110, 112, 117, 116, 160, 64, 160, 70, 64, 160, 64,
160, 71, 64, 38, 111, 117, 116, 112, 117, 116, 160, 65,
160, 67, 160, 68, 160, 70, 64, 160, 65, 160, 67, 160,
68, 160, 71, 64, 37, 37, 46, 49, 50, 103, 33, 46,
34, 37, 100, 37, 102, 97, 108, 115, 101, 36, 116, 114,
117, 101, 46, 98, 111, 111, 108, 95, 111, 102, 95, 115,
116, 114, 105, 110, 103, 36, 116, 114, 117, 101, 37, 102,
97, 108, 115, 101, 43, 99, 104, 97, 114, 95, 111, 102,
95, 105, 110, 116, 47, 80, 101, 114, 118, 97, 115, 105,
118, 101, 115, 46, 69, 120, 105, 116, 18, 95, 106, 0,
127, 240, 0, 0, 0, 0, 0, 0, 18, 95, 106, 0,
255, 240, 0, 0, 0, 0, 0, 0, 18, 95, 106, 0,
127, 240, 0, 0, 0, 0, 0, 1, 18, 95, 106, 0,
127, 239, 255, 255, 255, 255, 255, 255, 18, 95, 106, 0,
0, 16, 0, 0, 0, 0, 0, 0, 18, 95, 106, 0,
60, 176, 0, 0, 0, 0, 0, 0, 53, 80, 101, 114,
118, 97, 115, 105, 118, 101, 115, 46, 100, 111, 95, 97,
116, 95, 101, 120, 105, 116, 64, 54, 104, 101, 108, 108,
111, 32, 101, 109, 98, 101, 100, 100, 101, 100, 32, 119,
111, 114, 108, 100, 32, 49, 64, 54, 104, 101, 108, 108,
111, 32, 101, 109, 98, 101, 100, 100, 101, 100, 32, 119,
111, 114, 108, 100, 32, 50, 64,
};
static char caml_sections[] = {
132, 149, 166, 190, 0, 0, 22, 254, 0, 0, 0, 66,
0, 0, 6, 126, 0, 0, 3, 176, 160, 160, 36, 83,
89, 77, 66, 160, 106, 208, 208, 208, 208, 64, 176, 64,
41, 69, 109, 98, 101, 100, 95, 109, 101, 49, 65, 103,
208, 64, 176, 64, 41, 69, 109, 98, 101, 100, 95, 109,
101, 50, 65, 105, 64, 65, 66, 176, 64, 42, 80, 101,
114, 118, 97, 115, 105, 118, 101, 115, 65, 101, 208, 208,
64, 176, 80, 45, 77, 97, 116, 99, 104, 95, 102, 97,
105, 108, 117, 114, 101, 67, 71, 64, 65, 176, 81, 45,
79, 117, 116, 95, 111, 102, 95, 109, 101, 109, 111, 114,
121, 67, 64, 208, 64, 176, 82, 48, 73, 110, 118, 97,
108, 105, 100, 95, 97, 114, 103, 117, 109, 101, 110, 116,
67, 67, 64, 65, 66, 67, 176, 83, 39, 70, 97, 105,
108, 117, 114, 101, 67, 66, 208, 208, 64, 176, 84, 41,
78, 111, 116, 95, 102, 111, 117, 110, 100, 67, 70, 64,
65, 176, 85, 41, 83, 121, 115, 95, 101, 114, 114, 111,
114, 67, 65, 64, 66, 68, 176, 86, 43, 69, 110, 100,
95, 111, 102, 95, 102, 105, 108, 101, 67, 68, 208, 208,
64, 176, 87, 48, 68, 105, 118, 105, 115, 105, 111, 110,
95, 98, 121, 95, 122, 101, 114, 111, 67, 69, 64, 65,
176, 88, 46, 83, 116, 97, 99, 107, 95, 111, 118, 101,
114, 102, 108, 111, 119, 67, 72, 208, 208, 64, 176, 89,
46, 83, 121, 115, 95, 98, 108, 111, 99, 107, 101, 100,
95, 105, 111, 67, 73, 64, 65, 176, 90, 46, 65, 115,
115, 101, 114, 116, 95, 102, 97, 105, 108, 117, 114, 101,
67, 74, 208, 64, 176, 91, 58, 85, 110, 100, 101, 102,
105, 110, 101, 100, 95, 114, 101, 99, 117, 114, 115, 105,
118, 101, 95, 109, 111, 100, 117, 108, 101, 67, 75, 64,
65, 66, 67, 69, 160, 160, 36, 80, 82, 73, 77, 10,
0, 0, 21, 97, 99, 97, 109, 108, 95, 97, 98, 115,
95, 102, 108, 111, 97, 116, 0, 99, 97, 109, 108, 95,
97, 99, 111, 115, 95, 102, 108, 111, 97, 116, 0, 99,
97, 109, 108, 95, 97, 100, 100, 95, 102, 108, 111, 97,
116, 0, 99, 97, 109, 108, 95, 97, 108, 108, 111, 99,
95, 100, 117, 109, 109, 121, 0, 99, 97, 109, 108, 95,
97, 108, 108, 111, 99, 95, 100, 117, 109, 109, 121, 95,
102, 108, 111, 97, 116, 0, 99, 97, 109, 108, 95, 97,
114, 114, 97, 121, 95, 97, 112, 112, 101, 110, 100, 0,
99, 97, 109, 108, 95, 97, 114, 114, 97, 121, 95, 98,
108, 105, 116, 0, 99, 97, 109, 108, 95, 97, 114, 114,
97, 121, 95, 99, 111, 110, 99, 97, 116, 0, 99, 97,
109, 108, 95, 97, 114, 114, 97, 121, 95, 103, 101, 116,
0, 99, 97, 109, 108, 95, 97, 114, 114, 97, 121, 95,
103, 101, 116, 95, 97, 100, 100, 114, 0, 99, 97, 109,
108, 95, 97, 114, 114, 97, 121, 95, 103, 101, 116, 95,
102, 108, 111, 97, 116, 0, 99, 97, 109, 108, 95, 97,
114, 114, 97, 121, 95, 115, 101, 116, 0, 99, 97, 109,
108, 95, 97, 114, 114, 97, 121, 95, 115, 101, 116, 95,
97, 100, 100, 114, 0, 99, 97, 109, 108, 95, 97, 114,
114, 97, 121, 95, 115, 101, 116, 95, 102, 108, 111, 97,
116, 0, 99, 97, 109, 108, 95, 97, 114, 114, 97, 121,
95, 115, 117, 98, 0, 99, 97, 109, 108, 95, 97, 114,
114, 97, 121, 95, 117, 110, 115, 97, 102, 101, 95, 103,
101, 116, 0, 99, 97, 109, 108, 95, 97, 114, 114, 97,
121, 95, 117, 110, 115, 97, 102, 101, 95, 103, 101, 116,
95, 102, 108, 111, 97, 116, 0, 99, 97, 109, 108, 95,
97, 114, 114, 97, 121, 95, 117, 110, 115, 97, 102, 101,
95, 115, 101, 116, 0, 99, 97, 109, 108, 95, 97, 114,
114, 97, 121, 95, 117, 110, 115, 97, 102, 101, 95, 115,
101, 116, 95, 97, 100, 100, 114, 0, 99, 97, 109, 108,
95, 97, 114, 114, 97, 121, 95, 117, 110, 115, 97, 102,
101, 95, 115, 101, 116, 95, 102, 108, 111, 97, 116, 0,
99, 97, 109, 108, 95, 97, 115, 105, 110, 95, 102, 108,
111, 97, 116, 0, 99, 97, 109, 108, 95, 97, 116, 97,
110, 50, 95, 102, 108, 111, 97, 116, 0, 99, 97, 109,
108, 95, 97, 116, 97, 110, 95, 102, 108, 111, 97, 116,
0, 99, 97, 109, 108, 95, 98, 97, 99, 107, 116, 114,
97, 99, 101, 95, 115, 116, 97, 116, 117, 115, 0, 99,
97, 109, 108, 95, 98, 105, 116, 118, 101, 99, 116, 95,
116, 101, 115, 116, 0, 99, 97, 109, 108, 95, 98, 108,
105, 116, 95, 115, 116, 114, 105, 110, 103, 0, 99, 97,
109, 108, 95, 98, 115, 119, 97, 112, 49, 54, 0, 99,
97, 109, 108, 95, 99, 101, 105, 108, 95, 102, 108, 111,
97, 116, 0, 99, 97, 109, 108, 95, 99, 104, 97, 110,
110, 101, 108, 95, 100, 101, 115, 99, 114, 105, 112, 116,
111, 114, 0, 99, 97, 109, 108, 95, 99, 108, 97, 115,
115, 105, 102, 121, 95, 102, 108, 111, 97, 116, 0, 99,
97, 109, 108, 95, 99, 111, 109, 112, 97, 114, 101, 0,
99, 97, 109, 108, 95, 99, 111, 110, 118, 101, 114, 116,
95, 114, 97, 119, 95, 98, 97, 99, 107, 116, 114, 97,
99, 101, 0, 99, 97, 109, 108, 95, 99, 111, 112, 121,
115, 105, 103, 110, 95, 102, 108, 111, 97, 116, 0, 99,
97, 109, 108, 95, 99, 111, 115, 95, 102, 108, 111, 97,
116, 0, 99, 97, 109, 108, 95, 99, 111, 115, 104, 95,
102, 108, 111, 97, 116, 0, 99, 97, 109, 108, 95, 99,
114, 101, 97, 116, 101, 95, 115, 116, 114, 105, 110, 103,
0, 99, 97, 109, 108, 95, 100, 105, 118, 95, 102, 108,
111, 97, 116, 0, 99, 97, 109, 108, 95, 100, 121, 110,
108, 105, 110, 107, 95, 97, 100, 100, 95, 112, 114, 105,
109, 105, 116, 105, 118, 101, 0, 99, 97, 109, 108, 95,
100, 121, 110, 108, 105, 110, 107, 95, 99, 108, 111, 115,
101, 95, 108, 105, 98, 0, 99, 97, 109, 108, 95, 100,
121, 110, 108, 105, 110, 107, 95, 103, 101, 116, 95, 99,
117, 114, 114, 101, 110, 116, 95, 108, 105, 98, 115, 0,
99, 97, 109, 108, 95, 100, 121, 110, 108, 105, 110, 107,
95, 108, 111, 111, 107, 117, 112, 95, 115, 121, 109, 98,
111, 108, 0, 99, 97, 109, 108, 95, 100, 121, 110, 108,
105, 110, 107, 95, 111, 112, 101, 110, 95, 108, 105, 98,
0, 99, 97, 109, 108, 95, 101, 110, 115, 117, 114, 101,
95, 115, 116, 97, 99, 107, 95, 99, 97, 112, 97, 99,
105, 116, 121, 0, 99, 97, 109, 108, 95, 101, 113, 95,
102, 108, 111, 97, 116, 0, 99, 97, 109, 108, 95, 101,
113, 117, 97, 108, 0, 99, 97, 109, 108, 95, 101, 120,
112, 95, 102, 108, 111, 97, 116, 0, 99, 97, 109, 108,
95, 101, 120, 112, 109, 49, 95, 102, 108, 111, 97, 116,
0, 99, 97, 109, 108, 95, 102, 105, 108, 108, 95, 115,
116, 114, 105, 110, 103, 0, 99, 97, 109, 108, 95, 102,
105, 110, 97, 108, 95, 114, 101, 103, 105, 115, 116, 101,
114, 0, 99, 97, 109, 108, 95, 102, 105, 110, 97, 108,
95, 114, 101, 108, 101, 97, 115, 101, 0, 99, 97, 109,
108, 95, 102, 108, 111, 97, 116, 95, 99, 111, 109, 112,
97, 114, 101, 0, 99, 97, 109, 108, 95, 102, 108, 111,
97, 116, 95, 111, 102, 95, 105, 110, 116, 0, 99, 97,
109, 108, 95, 102, 108, 111, 97, 116, 95, 111, 102, 95,
115, 116, 114, 105, 110, 103, 0, 99, 97, 109, 108, 95,
102, 108, 111, 111, 114, 95, 102, 108, 111, 97, 116, 0,
99, 97, 109, 108, 95, 102, 109, 111, 100, 95, 102, 108,
111, 97, 116, 0, 99, 97, 109, 108, 95, 102, 111, 114,
109, 97, 116, 95, 102, 108, 111, 97, 116, 0, 99, 97,
109, 108, 95, 102, 111, 114, 109, 97, 116, 95, 105, 110,
116, 0, 99, 97, 109, 108, 95, 102, 114, 101, 120, 112,
95, 102, 108, 111, 97, 116, 0, 99, 97, 109, 108, 95,
103, 99, 95, 99, 111, 109, 112, 97, 99, 116, 105, 111,
110, 0, 99, 97, 109, 108, 95, 103, 99, 95, 99, 111,
117, 110, 116, 101, 114, 115, 0, 99, 97, 109, 108, 95,
103, 99, 95, 102, 117, 108, 108, 95, 109, 97, 106, 111,
114, 0, 99, 97, 109, 108, 95, 103, 99, 95, 103, 101,
116, 0, 99, 97, 109, 108, 95, 103, 99, 95, 109, 97,
106, 111, 114, 0, 99, 97, 109, 108, 95, 103, 99, 95,
109, 97, 106, 111, 114, 95, 115, 108, 105, 99, 101, 0,
99, 97, 109, 108, 95, 103, 99, 95, 109, 105, 110, 111,
114, 0, 99, 97, 109, 108, 95, 103, 99, 95, 113, 117,
105, 99, 107, 95, 115, 116, 97, 116, 0, 99, 97, 109,
108, 95, 103, 99, 95, 115, 101, 116, 0, 99, 97, 109,
108, 95, 103, 99, 95, 115, 116, 97, 116, 0, 99, 97,
109, 108, 95, 103, 101, 95, 102, 108, 111, 97, 116, 0,
99, 97, 109, 108, 95, 103, 101, 116, 95, 99, 117, 114,
114, 101, 110, 116, 95, 99, 97, 108, 108, 115, 116, 97,
99, 107, 0, 99, 97, 109, 108, 95, 103, 101, 116, 95,
99, 117, 114, 114, 101, 110, 116, 95, 101, 110, 118, 105,
114, 111, 110, 109, 101, 110, 116, 0, 99, 97, 109, 108,
95, 103, 101, 116, 95, 101, 120, 99, 101, 112, 116, 105,
111, 110, 95, 98, 97, 99, 107, 116, 114, 97, 99, 101,
0, 99, 97, 109, 108, 95, 103, 101, 116, 95, 101, 120,
99, 101, 112, 116, 105, 111, 110, 95, 114, 97, 119, 95,
98, 97, 99, 107, 116, 114, 97, 99, 101, 0, 99, 97,
109, 108, 95, 103, 101, 116, 95, 103, 108, 111, 98, 97,
108, 95, 100, 97, 116, 97, 0, 99, 97, 109, 108, 95,
103, 101, 116, 95, 112, 117, 98, 108, 105, 99, 95, 109,
101, 116, 104, 111, 100, 0, 99, 97, 109, 108, 95, 103,
101, 116, 95, 115, 101, 99, 116, 105, 111, 110, 95, 116,
97, 98, 108, 101, 0, 99, 97, 109, 108, 95, 103, 114,
101, 97, 116, 101, 114, 101, 113, 117, 97, 108, 0, 99,
97, 109, 108, 95, 103, 114, 101, 97, 116, 101, 114, 116,
104, 97, 110, 0, 99, 97, 109, 108, 95, 103, 116, 95,
102, 108, 111, 97, 116, 0, 99, 97, 109, 108, 95, 104,
97, 115, 104, 0, 99, 97, 109, 108, 95, 104, 97, 115,
104, 95, 117, 110, 105, 118, 95, 112, 97, 114, 97, 109,
0, 99, 97, 109, 108, 95, 104, 121, 112, 111, 116, 95,
102, 108, 111, 97, 116, 0, 99, 97, 109, 108, 95, 105,
110, 112, 117, 116, 95, 118, 97, 108, 117, 101, 0, 99,
97, 109, 108, 95, 105, 110, 112, 117, 116, 95, 118, 97,
108, 117, 101, 95, 102, 114, 111, 109, 95, 115, 116, 114,
105, 110, 103, 0, 99, 97, 109, 108, 95, 105, 110, 115,
116, 97, 108, 108, 95, 115, 105, 103, 110, 97, 108, 95,
104, 97, 110, 100, 108, 101, 114, 0, 99, 97, 109, 108,
95, 105, 110, 116, 51, 50, 95, 97, 100, 100, 0, 99,
97, 109, 108, 95, 105, 110, 116, 51, 50, 95, 97, 110,
100, 0, 99, 97, 109, 108, 95, 105, 110, 116, 51, 50,
95, 98, 105, 116, 115, 95, 111, 102, 95, 102, 108, 111,
97, 116, 0, 99, 97, 109, 108, 95, 105, 110, 116, 51,
50, 95, 98, 115, 119, 97, 112, 0, 99, 97, 109, 108,
95, 105, 110, 116, 51, 50, 95, 99, 111, 109, 112, 97,
114, 101, 0, 99, 97, 109, 108, 95, 105, 110, 116, 51,
50, 95, 100, 105, 118, 0, 99, 97, 109, 108, 95, 105,
110, 116, 51, 50, 95, 102, 108, 111, 97, 116, 95, 111,
102, 95, 98, 105, 116, 115, 0, 99, 97, 109, 108, 95,
105, 110, 116, 51, 50, 95, 102, 111, 114, 109, 97, 116,
0, 99, 97, 109, 108, 95, 105, 110, 116, 51, 50, 95,
109, 111, 100, 0, 99, 97, 109, 108, 95, 105, 110, 116,
51, 50, 95, 109, 117, 108, 0, 99, 97, 109, 108, 95,
105, 110, 116, 51, 50, 95, 110, 101, 103, 0, 99, 97,
109, 108, 95, 105, 110, 116, 51, 50, 95, 111, 102, 95,
102, 108, 111, 97, 116, 0, 99, 97, 109, 108, 95, 105,
110, 116, 51, 50, 95, 111, 102, 95, 105, 110, 116, 0,
99, 97, 109, 108, 95, 105, 110, 116, 51, 50, 95, 111,
102, 95, 115, 116, 114, 105, 110, 103, 0, 99, 97, 109,
108, 95, 105, 110, 116, 51, 50, 95, 111, 114, 0, 99,
97, 109, 108, 95, 105, 110, 116, 51, 50, 95, 115, 104,
105, 102, 116, 95, 108, 101, 102, 116, 0, 99, 97, 109,
108, 95, 105, 110, 116, 51, 50, 95, 115, 104, 105, 102,
116, 95, 114, 105, 103, 104, 116, 0, 99, 97, 109, 108,
95, 105, 110, 116, 51, 50, 95, 115, 104, 105, 102, 116,
95, 114, 105, 103, 104, 116, 95, 117, 110, 115, 105, 103,
110, 101, 100, 0, 99, 97, 109, 108, 95, 105, 110, 116,
51, 50, 95, 115, 117, 98, 0, 99, 97, 109, 108, 95,
105, 110, 116, 51, 50, 95, 116, 111, 95, 102, 108, 111,
97, 116, 0, 99, 97, 109, 108, 95, 105, 110, 116, 51,
50, 95, 116, 111, 95, 105, 110, 116, 0, 99, 97, 109,
108, 95, 105, 110, 116, 51, 50, 95, 120, 111, 114, 0,
99, 97, 109, 108, 95, 105, 110, 116, 54, 52, 95, 97,
100, 100, 0, 99, 97, 109, 108, 95, 105, 110, 116, 54,
52, 95, 97, 110, 100, 0, 99, 97, 109, 108, 95, 105,
110, 116, 54, 52, 95, 98, 105, 116, 115, 95, 111, 102,
95, 102, 108, 111, 97, 116, 0, 99, 97, 109, 108, 95,
105, 110, 116, 54, 52, 95, 98, 115, 119, 97, 112, 0,
99, 97, 109, 108, 95, 105, 110, 116, 54, 52, 95, 99,
111, 109, 112, 97, 114, 101, 0, 99, 97, 109, 108, 95,
105, 110, 116, 54, 52, 95, 100, 105, 118, 0, 99, 97,
109, 108, 95, 105, 110, 116, 54, 52, 95, 102, 108, 111,
97, 116, 95, 111, 102, 95, 98, 105, 116, 115, 0, 99,
97, 109, 108, 95, 105, 110, 116, 54, 52, 95, 102, 111,
114, 109, 97, 116, 0, 99, 97, 109, 108, 95, 105, 110,
116, 54, 52, 95, 109, 111, 100, 0, 99, 97, 109, 108,
95, 105, 110, 116, 54, 52, 95, 109, 117, 108, 0, 99,
97, 109, 108, 95, 105, 110, 116, 54, 52, 95, 110, 101,
103, 0, 99, 97, 109, 108, 95, 105, 110, 116, 54, 52,
95, 111, 102, 95, 102, 108, 111, 97, 116, 0, 99, 97,
109, 108, 95, 105, 110, 116, 54, 52, 95, 111, 102, 95,
105, 110, 116, 0, 99, 97, 109, 108, 95, 105, 110, 116,
54, 52, 95, 111, 102, 95, 105, 110, 116, 51, 50, 0,
99, 97, 109, 108, 95, 105, 110, 116, 54, 52, 95, 111,
102, 95, 110, 97, 116, 105, 118, 101, 105, 110, 116, 0,
99, 97, 109, 108, 95, 105, 110, 116, 54, 52, 95, 111,
102, 95, 115, 116, 114, 105, 110, 103, 0, 99, 97, 109,
108, 95, 105, 110, 116, 54, 52, 95, 111, 114, 0, 99,
97, 109, 108, 95, 105, 110, 116, 54, 52, 95, 115, 104,
105, 102, 116, 95, 108, 101, 102, 116, 0, 99, 97, 109,
108, 95, 105, 110, 116, 54, 52, 95, 115, 104, 105, 102,
116, 95, 114, 105, 103, 104, 116, 0, 99, 97, 109, 108,
95, 105, 110, 116, 54, 52, 95, 115, 104, 105, 102, 116,
95, 114, 105, 103, 104, 116, 95, 117, 110, 115, 105, 103,
110, 101, 100, 0, 99, 97, 109, 108, 95, 105, 110, 116,
54, 52, 95, 115, 117, 98, 0, 99, 97, 109, 108, 95,
105, 110, 116, 54, 52, 95, 116, 111, 95, 102, 108, 111,
97, 116, 0, 99, 97, 109, 108, 95, 105, 110, 116, 54,
52, 95, 116, 111, 95, 105, 110, 116, 0, 99, 97, 109,
108, 95, 105, 110, 116, 54, 52, 95, 116, 111, 95, 105,
110, 116, 51, 50, 0, 99, 97, 109, 108, 95, 105, 110,
116, 54, 52, 95, 116, 111, 95, 110, 97, 116, 105, 118,
101, 105, 110, 116, 0, 99, 97, 109, 108, 95, 105, 110,
116, 54, 52, 95, 120, 111, 114, 0, 99, 97, 109, 108,
95, 105, 110, 116, 95, 99, 111, 109, 112, 97, 114, 101,
0, 99, 97, 109, 108, 95, 105, 110, 116, 95, 111, 102,
95, 102, 108, 111, 97, 116, 0, 99, 97, 109, 108, 95,
105, 110, 116, 95, 111, 102, 95, 115, 116, 114, 105, 110,
103, 0, 99, 97, 109, 108, 95, 105, 110, 118, 111, 107,
101, 95, 116, 114, 97, 99, 101, 100, 95, 102, 117, 110,
99, 116, 105, 111, 110, 0, 99, 97, 109, 108, 95, 105,
115, 95, 112, 114, 105, 110, 116, 97, 98, 108, 101, 0,
99, 97, 109, 108, 95, 108, 97, 122, 121, 95, 102, 111,
108, 108, 111, 119, 95, 102, 111, 114, 119, 97, 114, 100,
0, 99, 97, 109, 108, 95, 108, 97, 122, 121, 95, 109,
97, 107, 101, 95, 102, 111, 114, 119, 97, 114, 100, 0,
99, 97, 109, 108, 95, 108, 100, 101, 120, 112, 95, 102,
108, 111, 97, 116, 0, 99, 97, 109, 108, 95, 108, 101,
95, 102, 108, 111, 97, 116, 0, 99, 97, 109, 108, 95,
108, 101, 115, 115, 101, 113, 117, 97, 108, 0, 99, 97,
109, 108, 95, 108, 101, 115, 115, 116, 104, 97, 110, 0,
99, 97, 109, 108, 95, 108, 101, 120, 95, 101, 110, 103,
105, 110, 101, 0, 99, 97, 109, 108, 95, 108, 111, 103,
49, 48, 95, 102, 108, 111, 97, 116, 0, 99, 97, 109,
108, 95, 108, 111, 103, 49, 112, 95, 102, 108, 111, 97,
116, 0, 99, 97, 109, 108, 95, 108, 111, 103, 95, 102,
108, 111, 97, 116, 0, 99, 97, 109, 108, 95, 108, 116,
95, 102, 108, 111, 97, 116, 0, 99, 97, 109, 108, 95,
109, 97, 107, 101, 95, 97, 114, 114, 97, 121, 0, 99,
97, 109, 108, 95, 109, 97, 107, 101, 95, 118, 101, 99,
116, 0, 99, 97, 109, 108, 95, 109, 97, 114, 115, 104,
97, 108, 95, 100, 97, 116, 97, 95, 115, 105, 122, 101,
0, 99, 97, 109, 108, 95, 109, 100, 53, 95, 99, 104,
97, 110, 0, 99, 97, 109, 108, 95, 109, 100, 53, 95,
115, 116, 114, 105, 110, 103, 0, 99, 97, 109, 108, 95,
109, 108, 95, 99, 104, 97, 110, 110, 101, 108, 95, 115,
105, 122, 101, 0, 99, 97, 109, 108, 95, 109, 108, 95,
99, 104, 97, 110, 110, 101, 108, 95, 115, 105, 122, 101,
95, 54, 52, 0, 99, 97, 109, 108, 95, 109, 108, 95,
99, 108, 111, 115, 101, 95, 99, 104, 97, 110, 110, 101,
108, 0, 99, 97, 109, 108, 95, 109, 108, 95, 102, 108,
117, 115, 104, 0, 99, 97, 109, 108, 95, 109, 108, 95,
102, 108, 117, 115, 104, 95, 112, 97, 114, 116, 105, 97,
108, 0, 99, 97, 109, 108, 95, 109, 108, 95, 105, 110,
112, 117, 116, 0, 99, 97, 109, 108, 95, 109, 108, 95,
105, 110, 112, 117, 116, 95, 99, 104, 97, 114, 0, 99,
97, 109, 108, 95, 109, 108, 95, 105, 110, 112, 117, 116,
95, 105, 110, 116, 0, 99, 97, 109, 108, 95, 109, 108,
95, 105, 110, 112, 117, 116, 95, 115, 99, 97, 110, 95,
108, 105, 110, 101, 0, 99, 97, 109, 108, 95, 109, 108,
95, 111, 112, 101, 110, 95, 100, 101, 115, 99, 114, 105,
112, 116, 111, 114, 95, 105, 110, 0, 99, 97, 109, 108,
95, 109, 108, 95, 111, 112, 101, 110, 95, 100, 101, 115,
99, 114, 105, 112, 116, 111, 114, 95, 111, 117, 116, 0,
99, 97, 109, 108, 95, 109, 108, 95, 111, 117, 116, 95,
99, 104, 97, 110, 110, 101, 108, 115, 95, 108, 105, 115,
116, 0, 99, 97, 109, 108, 95, 109, 108, 95, 111, 117,
116, 112, 117, 116, 0, 99, 97, 109, 108, 95, 109, 108,
95, 111, 117, 116, 112, 117, 116, 95, 99, 104, 97, 114,
0, 99, 97, 109, 108, 95, 109, 108, 95, 111, 117, 116,
112, 117, 116, 95, 105, 110, 116, 0, 99, 97, 109, 108,
95, 109, 108, 95, 111, 117, 116, 112, 117, 116, 95, 112,
97, 114, 116, 105, 97, 108, 0, 99, 97, 109, 108, 95,
109, 108, 95, 112, 111, 115, 95, 105, 110, 0, 99, 97,
109, 108, 95, 109, 108, 95, 112, 111, 115, 95, 105, 110,
95, 54, 52, 0, 99, 97, 109, 108, 95, 109, 108, 95,
112, 111, 115, 95, 111, 117, 116, 0, 99, 97, 109, 108,
95, 109, 108, 95, 112, 111, 115, 95, 111, 117, 116, 95,
54, 52, 0, 99, 97, 109, 108, 95, 109, 108, 95, 115,
101, 101, 107, 95, 105, 110, 0, 99, 97, 109, 108, 95,
109, 108, 95, 115, 101, 101, 107, 95, 105, 110, 95, 54,
52, 0, 99, 97, 109, 108, 95, 109, 108, 95, 115, 101,
101, 107, 95, 111, 117, 116, 0, 99, 97, 109, 108, 95,
109, 108, 95, 115, 101, 101, 107, 95, 111, 117, 116, 95,
54, 52, 0, 99, 97, 109, 108, 95, 109, 108, 95, 115,
101, 116, 95, 98, 105, 110, 97, 114, 121, 95, 109, 111,
100, 101, 0, 99, 97, 109, 108, 95, 109, 108, 95, 115,
116, 114, 105, 110, 103, 95, 108, 101, 110, 103, 116, 104,
0, 99, 97, 109, 108, 95, 109, 111, 100, 102, 95, 102,
108, 111, 97, 116, 0, 99, 97, 109, 108, 95, 109, 117,
108, 95, 102, 108, 111, 97, 116, 0, 99, 97, 109, 108,
95, 110, 97, 116, 105, 118, 101, 105, 110, 116, 95, 97,
100, 100, 0, 99, 97, 109, 108, 95, 110, 97, 116, 105,
118, 101, 105, 110, 116, 95, 97, 110, 100, 0, 99, 97,
109, 108, 95, 110, 97, 116, 105, 118, 101, 105, 110, 116,
95, 98, 115, 119, 97, 112, 0, 99, 97, 109, 108, 95,
110, 97, 116, 105, 118, 101, 105, 110, 116, 95, 99, 111,
109, 112, 97, 114, 101, 0, 99, 97, 109, 108, 95, 110,
97, 116, 105, 118, 101, 105, 110, 116, 95, 100, 105, 118,
0, 99, 97, 109, 108, 95, 110, 97, 116, 105, 118, 101,
105, 110, 116, 95, 102, 111, 114, 109, 97, 116, 0, 99,
97, 109, 108, 95, 110, 97, 116, 105, 118, 101, 105, 110,
116, 95, 109, 111, 100, 0, 99, 97, 109, 108, 95, 110,
97, 116, 105, 118, 101, 105, 110, 116, 95, 109, 117, 108,
0, 99, 97, 109, 108, 95, 110, 97, 116, 105, 118, 101,
105, 110, 116, 95, 110, 101, 103, 0, 99, 97, 109, 108,
95, 110, 97, 116, 105, 118, 101, 105, 110, 116, 95, 111,
102, 95, 102, 108, 111, 97, 116, 0, 99, 97, 109, 108,
95, 110, 97, 116, 105, 118, 101, 105, 110, 116, 95, 111,
102, 95, 105, 110, 116, 0, 99, 97, 109, 108, 95, 110,
97, 116, 105, 118, 101, 105, 110, 116, 95, 111, 102, 95,
105, 110, 116, 51, 50, 0, 99, 97, 109, 108, 95, 110,
97, 116, 105, 118, 101, 105, 110, 116, 95, 111, 102, 95,
115, 116, 114, 105, 110, 103, 0, 99, 97, 109, 108, 95,
110, 97, 116, 105, 118, 101, 105, 110, 116, 95, 111, 114,
0, 99, 97, 109, 108, 95, 110, 97, 116, 105, 118, 101,
105, 110, 116, 95, 115, 104, 105, 102, 116, 95, 108, 101,
102, 116, 0, 99, 97, 109, 108, 95, 110, 97, 116, 105,
118, 101, 105, 110, 116, 95, 115, 104, 105, 102, 116, 95,
114, 105, 103, 104, 116, 0, 99, 97, 109, 108, 95, 110,
97, 116, 105, 118, 101, 105, 110, 116, 95, 115, 104, 105,
102, 116, 95, 114, 105, 103, 104, 116, 95, 117, 110, 115,
105, 103, 110, 101, 100, 0, 99, 97, 109, 108, 95, 110,
97, 116, 105, 118, 101, 105, 110, 116, 95, 115, 117, 98,
0, 99, 97, 109, 108, 95, 110, 97, 116, 105, 118, 101,
105, 110, 116, 95, 116, 111, 95, 102, 108, 111, 97, 116,
0, 99, 97, 109, 108, 95, 110, 97, 116, 105, 118, 101,
105, 110, 116, 95, 116, 111, 95, 105, 110, 116, 0, 99,
97, 109, 108, 95, 110, 97, 116, 105, 118, 101, 105, 110,
116, 95, 116, 111, 95, 105, 110, 116, 51, 50, 0, 99,
97, 109, 108, 95, 110, 97, 116, 105, 118, 101, 105, 110,
116, 95, 120, 111, 114, 0, 99, 97, 109, 108, 95, 110,
101, 103, 95, 102, 108, 111, 97, 116, 0, 99, 97, 109,
108, 95, 110, 101, 113, 95, 102, 108, 111, 97, 116, 0,
99, 97, 109, 108, 95, 110, 101, 119, 95, 108, 101, 120,
95, 101, 110, 103, 105, 110, 101, 0, 99, 97, 109, 108,
95, 110, 111, 116, 101, 113, 117, 97, 108, 0, 99, 97,
109, 108, 95, 111, 98, 106, 95, 97, 100, 100, 95, 111,
102, 102, 115, 101, 116, 0, 99, 97, 109, 108, 95, 111,
98, 106, 95, 98, 108, 111, 99, 107, 0, 99, 97, 109,
108, 95, 111, 98, 106, 95, 100, 117, 112, 0, 99, 97,
109, 108, 95, 111, 98, 106, 95, 105, 115, 95, 98, 108,
111, 99, 107, 0, 99, 97, 109, 108, 95, 111, 98, 106,
95, 115, 101, 116, 95, 116, 97, 103, 0, 99, 97, 109,
108, 95, 111, 98, 106, 95, 116, 97, 103, 0, 99, 97,
109, 108, 95, 111, 98, 106, 95, 116, 114, 117, 110, 99,
97, 116, 101, 0, 99, 97, 109, 108, 95, 111, 117, 116,
112, 117, 116, 95, 118, 97, 108, 117, 101, 0, 99, 97,
109, 108, 95, 111, 117, 116, 112, 117, 116, 95, 118, 97,
108, 117, 101, 95, 116, 111, 95, 98, 117, 102, 102, 101,
114, 0, 99, 97, 109, 108, 95, 111, 117, 116, 112, 117,
116, 95, 118, 97, 108, 117, 101, 95, 116, 111, 95, 115,
116, 114, 105, 110, 103, 0, 99, 97, 109, 108, 95, 112,
97, 114, 115, 101, 95, 101, 110, 103, 105, 110, 101, 0,
99, 97, 109, 108, 95, 112, 111, 119, 101, 114, 95, 102,
108, 111, 97, 116, 0, 99, 97, 109, 108, 95, 114, 101,
97, 108, 108, 111, 99, 95, 103, 108, 111, 98, 97, 108,
0, 99, 97, 109, 108, 95, 114, 101, 99, 111, 114, 100,
95, 98, 97, 99, 107, 116, 114, 97, 99, 101, 0, 99,
97, 109, 108, 95, 114, 101, 103, 105, 115, 116, 101, 114,
95, 99, 111, 100, 101, 95, 102, 114, 97, 103, 109, 101,
110, 116, 0, 99, 97, 109, 108, 95, 114, 101, 103, 105,
115, 116, 101, 114, 95, 110, 97, 109, 101, 100, 95, 118,
97, 108, 117, 101, 0, 99, 97, 109, 108, 95, 114, 101,
105, 102, 121, 95, 98, 121, 116, 101, 99, 111, 100, 101,
0, 99, 97, 109, 108, 95, 115, 101, 116, 95, 112, 97,
114, 115, 101, 114, 95, 116, 114, 97, 99, 101, 0, 99,
97, 109, 108, 95, 115, 105, 110, 95, 102, 108, 111, 97,
116, 0, 99, 97, 109, 108, 95, 115, 105, 110, 104, 95,
102, 108, 111, 97, 116, 0, 99, 97, 109, 108, 95, 115,
113, 114, 116, 95, 102, 108, 111, 97, 116, 0, 99, 97,
109, 108, 95, 115, 116, 97, 116, 105, 99, 95, 97, 108,
108, 111, 99, 0, 99, 97, 109, 108, 95, 115, 116, 97,
116, 105, 99, 95, 102, 114, 101, 101, 0, 99, 97, 109,
108, 95, 115, 116, 97, 116, 105, 99, 95, 114, 101, 108,
101, 97, 115, 101, 95, 98, 121, 116, 101, 99, 111, 100,
101, 0, 99, 97, 109, 108, 95, 115, 116, 97, 116, 105,
99, 95, 114, 101, 115, 105, 122, 101, 0, 99, 97, 109,
108, 95, 115, 116, 114, 105, 110, 103, 95, 99, 111, 109,
112, 97, 114, 101, 0, 99, 97, 109, 108, 95, 115, 116,
114, 105, 110, 103, 95, 101, 113, 117, 97, 108, 0, 99,
97, 109, 108, 95, 115, 116, 114, 105, 110, 103, 95, 103,
101, 116, 0, 99, 97, 109, 108, 95, 115, 116, 114, 105,
110, 103, 95, 103, 101, 116, 49, 54, 0, 99, 97, 109,
108, 95, 115, 116, 114, 105, 110, 103, 95, 103, 101, 116,
51, 50, 0, 99, 97, 109, 108, 95, 115, 116, 114, 105,
110, 103, 95, 103, 101, 116, 54, 52, 0, 99, 97, 109,
108, 95, 115, 116, 114, 105, 110, 103, 95, 103, 114, 101,
97, 116, 101, 114, 101, 113, 117, 97, 108, 0, 99, 97,
109, 108, 95, 115, 116, 114, 105, 110, 103, 95, 103, 114,
101, 97, 116, 101, 114, 116, 104, 97, 110, 0, 99, 97,
109, 108, 95, 115, 116, 114, 105, 110, 103, 95, 108, 101,
115, 115, 101, 113, 117, 97, 108, 0, 99, 97, 109, 108,
95, 115, 116, 114, 105, 110, 103, 95, 108, 101, 115, 115,
116, 104, 97, 110, 0, 99, 97, 109, 108, 95, 115, 116,
114, 105, 110, 103, 95, 110, 111, 116, 101, 113, 117, 97,
108, 0, 99, 97, 109, 108, 95, 115, 116, 114, 105, 110,
103, 95, 115, 101, 116, 0, 99, 97, 109, 108, 95, 115,
116, 114, 105, 110, 103, 95, 115, 101, 116, 49, 54, 0,
99, 97, 109, 108, 95, 115, 116, 114, 105, 110, 103, 95,
115, 101, 116, 51, 50, 0, 99, 97, 109, 108, 95, 115,
116, 114, 105, 110, 103, 95, 115, 101, 116, 54, 52, 0,
99, 97, 109, 108, 95, 115, 117, 98, 95, 102, 108, 111,
97, 116, 0, 99, 97, 109, 108, 95, 115, 121, 115, 95,
99, 104, 100, 105, 114, 0, 99, 97, 109, 108, 95, 115,
121, 115, 95, 99, 108, 111, 115, 101, 0, 99, 97, 109,
108, 95, 115, 121, 115, 95, 99, 111, 110, 115, 116, 95,
98, 105, 103, 95, 101, 110, 100, 105, 97, 110, 0, 99,
97, 109, 108, 95, 115, 121, 115, 95, 99, 111, 110, 115,
116, 95, 111, 115, 116, 121, 112, 101, 95, 99, 121, 103,
119, 105, 110, 0, 99, 97, 109, 108, 95, 115, 121, 115,
95, 99, 111, 110, 115, 116, 95, 111, 115, 116, 121, 112,
101, 95, 117, 110, 105, 120, 0, 99, 97, 109, 108, 95,
115, 121, 115, 95, 99, 111, 110, 115, 116, 95, 111, 115,
116, 121, 112, 101, 95, 119, 105, 110, 51, 50, 0, 99,
97, 109, 108, 95, 115, 121, 115, 95, 99, 111, 110, 115,
116, 95, 119, 111, 114, 100, 95, 115, 105, 122, 101, 0,
99, 97, 109, 108, 95, 115, 121, 115, 95, 101, 120, 105,
116, 0, 99, 97, 109, 108, 95, 115, 121, 115, 95, 102,
105, 108, 101, 95, 101, 120, 105, 115, 116, 115, 0, 99,
97, 109, 108, 95, 115, 121, 115, 95, 103, 101, 116, 95,
97, 114, 103, 118, 0, 99, 97, 109, 108, 95, 115, 121,
115, 95, 103, 101, 116, 95, 99, 111, 110, 102, 105, 103,
0, 99, 97, 109, 108, 95, 115, 121, 115, 95, 103, 101,
116, 99, 119, 100, 0, 99, 97, 109, 108, 95, 115, 121,
115, 95, 103, 101, 116, 101, 110, 118, 0, 99, 97, 109,
108, 95, 115, 121, 115, 95, 105, 115, 95, 100, 105, 114,
101, 99, 116, 111, 114, 121, 0, 99, 97, 109, 108, 95,
115, 121, 115, 95, 111, 112, 101, 110, 0, 99, 97, 109,
108, 95, 115, 121, 115, 95, 114, 97, 110, 100, 111, 109,
95, 115, 101, 101, 100, 0, 99, 97, 109, 108, 95, 115,
121, 115, 95, 114, 101, 97, 100, 95, 100, 105, 114, 101,
99, 116, 111, 114, 121, 0, 99, 97, 109, 108, 95, 115,
121, 115, 95, 114, 101, 109, 111, 118, 101, 0, 99, 97,
109, 108, 95, 115, 121, 115, 95, 114, 101, 110, 97, 109,
101, 0, 99, 97, 109, 108, 95, 115, 121, 115, 95, 115,
121, 115, 116, 101, 109, 95, 99, 111, 109, 109, 97, 110,
100, 0, 99, 97, 109, 108, 95, 115, 121, 115, 95, 116,
105, 109, 101, 0, 99, 97, 109, 108, 95, 116, 97, 110,
95, 102, 108, 111, 97, 116, 0, 99, 97, 109, 108, 95,
116, 97, 110, 104, 95, 102, 108, 111, 97, 116, 0, 99,
97, 109, 108, 95, 116, 101, 114, 109, 105, 110, 102, 111,
95, 98, 97, 99, 107, 117, 112, 0, 99, 97, 109, 108,
95, 116, 101, 114, 109, 105, 110, 102, 111, 95, 114, 101,
115, 117, 109, 101, 0, 99, 97, 109, 108, 95, 116, 101,
114, 109, 105, 110, 102, 111, 95, 115, 101, 116, 117, 112,
0, 99, 97, 109, 108, 95, 116, 101, 114, 109, 105, 110,
102, 111, 95, 115, 116, 97, 110, 100, 111, 117, 116, 0,
99, 97, 109, 108, 95, 117, 112, 100, 97, 116, 101, 95,
100, 117, 109, 109, 121, 0, 99, 97, 109, 108, 95, 119,
101, 97, 107, 95, 98, 108, 105, 116, 0, 99, 97, 109,
108, 95, 119, 101, 97, 107, 95, 99, 104, 101, 99, 107,
0, 99, 97, 109, 108, 95, 119, 101, 97, 107, 95, 99,
114, 101, 97, 116, 101, 0, 99, 97, 109, 108, 95, 119,
101, 97, 107, 95, 103, 101, 116, 0, 99, 97, 109, 108,
95, 119, 101, 97, 107, 95, 103, 101, 116, 95, 99, 111,
112, 121, 0, 99, 97, 109, 108, 95, 119, 101, 97, 107,
95, 115, 101, 116, 0, 160, 160, 36, 67, 82, 67, 83,
160, 160, 4, 49, 48, 190, 163, 18, 101, 189, 28, 219,
213, 174, 68, 31, 211, 31, 177, 196, 145, 160, 160, 4,
49, 48, 18, 91, 100, 123, 73, 58, 159, 133, 115, 221,
105, 87, 212, 43, 208, 18, 160, 160, 42, 80, 101, 114,
118, 97, 115, 105, 118, 101, 115, 48, 54, 181, 188, 130,
39, 220, 153, 20, 198, 217, 253, 155, 220, 250, 219, 69,
64, 64,
};
extern value caml_abs_float();
extern value caml_acos_float();
extern value caml_add_float();
extern value caml_alloc_dummy();
extern value caml_alloc_dummy_float();
extern value caml_array_append();
extern value caml_array_blit();
extern value caml_array_concat();
extern value caml_array_get();
extern value caml_array_get_addr();
extern value caml_array_get_float();
extern value caml_array_set();
extern value caml_array_set_addr();
extern value caml_array_set_float();
extern value caml_array_sub();
extern value caml_array_unsafe_get();
extern value caml_array_unsafe_get_float();
extern value caml_array_unsafe_set();
extern value caml_array_unsafe_set_addr();
extern value caml_array_unsafe_set_float();
extern value caml_asin_float();
extern value caml_atan2_float();
extern value caml_atan_float();
extern value caml_backtrace_status();
extern value caml_bitvect_test();
extern value caml_blit_string();
extern value caml_bswap16();
extern value caml_ceil_float();
extern value caml_channel_descriptor();
extern value caml_classify_float();
extern value caml_compare();
extern value caml_convert_raw_backtrace();
extern value caml_copysign_float();
extern value caml_cos_float();
extern value caml_cosh_float();
extern value caml_create_string();
extern value caml_div_float();
extern value caml_dynlink_add_primitive();
extern value caml_dynlink_close_lib();
extern value caml_dynlink_get_current_libs();
extern value caml_dynlink_lookup_symbol();
extern value caml_dynlink_open_lib();
extern value caml_ensure_stack_capacity();
extern value caml_eq_float();
extern value caml_equal();
extern value caml_exp_float();
extern value caml_expm1_float();
extern value caml_fill_string();
extern value caml_final_register();
extern value caml_final_release();
extern value caml_float_compare();
extern value caml_float_of_int();
extern value caml_float_of_string();
extern value caml_floor_float();
extern value caml_fmod_float();
extern value caml_format_float();
extern value caml_format_int();
extern value caml_frexp_float();
extern value caml_gc_compaction();
extern value caml_gc_counters();
extern value caml_gc_full_major();
extern value caml_gc_get();
extern value caml_gc_major();
extern value caml_gc_major_slice();
extern value caml_gc_minor();
extern value caml_gc_quick_stat();
extern value caml_gc_set();
extern value caml_gc_stat();
extern value caml_ge_float();
extern value caml_get_current_callstack();
extern value caml_get_current_environment();
extern value caml_get_exception_backtrace();
extern value caml_get_exception_raw_backtrace();
extern value caml_get_global_data();
extern value caml_get_public_method();
extern value caml_get_section_table();
extern value caml_greaterequal();
extern value caml_greaterthan();
extern value caml_gt_float();
extern value caml_hash();
extern value caml_hash_univ_param();
extern value caml_hypot_float();
extern value caml_input_value();
extern value caml_input_value_from_string();
extern value caml_install_signal_handler();
extern value caml_int32_add();
extern value caml_int32_and();
extern value caml_int32_bits_of_float();
extern value caml_int32_bswap();
extern value caml_int32_compare();
extern value caml_int32_div();
extern value caml_int32_float_of_bits();
extern value caml_int32_format();
extern value caml_int32_mod();
extern value caml_int32_mul();
extern value caml_int32_neg();
extern value caml_int32_of_float();
extern value caml_int32_of_int();
extern value caml_int32_of_string();
extern value caml_int32_or();
extern value caml_int32_shift_left();
extern value caml_int32_shift_right();
extern value caml_int32_shift_right_unsigned();
extern value caml_int32_sub();
extern value caml_int32_to_float();
extern value caml_int32_to_int();
extern value caml_int32_xor();
extern value caml_int64_add();
extern value caml_int64_and();
extern value caml_int64_bits_of_float();
extern value caml_int64_bswap();
extern value caml_int64_compare();
extern value caml_int64_div();
extern value caml_int64_float_of_bits();
extern value caml_int64_format();
extern value caml_int64_mod();
extern value caml_int64_mul();
extern value caml_int64_neg();
extern value caml_int64_of_float();
extern value caml_int64_of_int();
extern value caml_int64_of_int32();
extern value caml_int64_of_nativeint();
extern value caml_int64_of_string();
extern value caml_int64_or();
extern value caml_int64_shift_left();
extern value caml_int64_shift_right();
extern value caml_int64_shift_right_unsigned();
extern value caml_int64_sub();
extern value caml_int64_to_float();
extern value caml_int64_to_int();
extern value caml_int64_to_int32();
extern value caml_int64_to_nativeint();
extern value caml_int64_xor();
extern value caml_int_compare();
extern value caml_int_of_float();
extern value caml_int_of_string();
extern value caml_invoke_traced_function();
extern value caml_is_printable();
extern value caml_lazy_follow_forward();
extern value caml_lazy_make_forward();
extern value caml_ldexp_float();
extern value caml_le_float();
extern value caml_lessequal();
extern value caml_lessthan();
extern value caml_lex_engine();
extern value caml_log10_float();
extern value caml_log1p_float();
extern value caml_log_float();
extern value caml_lt_float();
extern value caml_make_array();
extern value caml_make_vect();
extern value caml_marshal_data_size();
extern value caml_md5_chan();
extern value caml_md5_string();
extern value caml_ml_channel_size();
extern value caml_ml_channel_size_64();
extern value caml_ml_close_channel();
extern value caml_ml_flush();
extern value caml_ml_flush_partial();
extern value caml_ml_input();
extern value caml_ml_input_char();
extern value caml_ml_input_int();
extern value caml_ml_input_scan_line();
extern value caml_ml_open_descriptor_in();
extern value caml_ml_open_descriptor_out();
extern value caml_ml_out_channels_list();
extern value caml_ml_output();
extern value caml_ml_output_char();
extern value caml_ml_output_int();
extern value caml_ml_output_partial();
extern value caml_ml_pos_in();
extern value caml_ml_pos_in_64();
extern value caml_ml_pos_out();
extern value caml_ml_pos_out_64();
extern value caml_ml_seek_in();
extern value caml_ml_seek_in_64();
extern value caml_ml_seek_out();
extern value caml_ml_seek_out_64();
extern value caml_ml_set_binary_mode();
extern value caml_ml_string_length();
extern value caml_modf_float();
extern value caml_mul_float();
extern value caml_nativeint_add();
extern value caml_nativeint_and();
extern value caml_nativeint_bswap();
extern value caml_nativeint_compare();
extern value caml_nativeint_div();
extern value caml_nativeint_format();
extern value caml_nativeint_mod();
extern value caml_nativeint_mul();
extern value caml_nativeint_neg();
extern value caml_nativeint_of_float();
extern value caml_nativeint_of_int();
extern value caml_nativeint_of_int32();
extern value caml_nativeint_of_string();
extern value caml_nativeint_or();
extern value caml_nativeint_shift_left();
extern value caml_nativeint_shift_right();
extern value caml_nativeint_shift_right_unsigned();
extern value caml_nativeint_sub();
extern value caml_nativeint_to_float();
extern value caml_nativeint_to_int();
extern value caml_nativeint_to_int32();
extern value caml_nativeint_xor();
extern value caml_neg_float();
extern value caml_neq_float();
extern value caml_new_lex_engine();
extern value caml_notequal();
extern value caml_obj_add_offset();
extern value caml_obj_block();
extern value caml_obj_dup();
extern value caml_obj_is_block();
extern value caml_obj_set_tag();
extern value caml_obj_tag();
extern value caml_obj_truncate();
extern value caml_output_value();
extern value caml_output_value_to_buffer();
extern value caml_output_value_to_string();
extern value caml_parse_engine();
extern value caml_power_float();
extern value caml_realloc_global();
extern value caml_record_backtrace();
extern value caml_register_code_fragment();
extern value caml_register_named_value();
extern value caml_reify_bytecode();
extern value caml_set_parser_trace();
extern value caml_sin_float();
extern value caml_sinh_float();
extern value caml_sqrt_float();
extern value caml_static_alloc();
extern value caml_static_free();
extern value caml_static_release_bytecode();
extern value caml_static_resize();
extern value caml_string_compare();
extern value caml_string_equal();
extern value caml_string_get();
extern value caml_string_get16();
extern value caml_string_get32();
extern value caml_string_get64();
extern value caml_string_greaterequal();
extern value caml_string_greaterthan();
extern value caml_string_lessequal();
extern value caml_string_lessthan();
extern value caml_string_notequal();
extern value caml_string_set();
extern value caml_string_set16();
extern value caml_string_set32();
extern value caml_string_set64();
extern value caml_sub_float();
extern value caml_sys_chdir();
extern value caml_sys_close();
extern value caml_sys_const_big_endian();
extern value caml_sys_const_ostype_cygwin();
extern value caml_sys_const_ostype_unix();
extern value caml_sys_const_ostype_win32();
extern value caml_sys_const_word_size();
extern value caml_sys_exit();
extern value caml_sys_file_exists();
extern value caml_sys_get_argv();
extern value caml_sys_get_config();
extern value caml_sys_getcwd();
extern value caml_sys_getenv();
extern value caml_sys_is_directory();
extern value caml_sys_open();
extern value caml_sys_random_seed();
extern value caml_sys_read_directory();
extern value caml_sys_remove();
extern value caml_sys_rename();
extern value caml_sys_system_command();
extern value caml_sys_time();
extern value caml_tan_float();
extern value caml_tanh_float();
extern value caml_terminfo_backup();
extern value caml_terminfo_resume();
extern value caml_terminfo_setup();
extern value caml_terminfo_standout();
extern value caml_update_dummy();
extern value caml_weak_blit();
extern value caml_weak_check();
extern value caml_weak_create();
extern value caml_weak_get();
extern value caml_weak_get_copy();
extern value caml_weak_set();
typedef value (*primitive)();
primitive caml_builtin_cprim[] = {
caml_abs_float,
caml_acos_float,
caml_add_float,
caml_alloc_dummy,
caml_alloc_dummy_float,
caml_array_append,
caml_array_blit,
caml_array_concat,
caml_array_get,
caml_array_get_addr,
caml_array_get_float,
caml_array_set,
caml_array_set_addr,
caml_array_set_float,
caml_array_sub,
caml_array_unsafe_get,
caml_array_unsafe_get_float,
caml_array_unsafe_set,
caml_array_unsafe_set_addr,
caml_array_unsafe_set_float,
caml_asin_float,
caml_atan2_float,
caml_atan_float,
caml_backtrace_status,
caml_bitvect_test,
caml_blit_string,
caml_bswap16,
caml_ceil_float,
caml_channel_descriptor,
caml_classify_float,
caml_compare,
caml_convert_raw_backtrace,
caml_copysign_float,
caml_cos_float,
caml_cosh_float,
caml_create_string,
caml_div_float,
caml_dynlink_add_primitive,
caml_dynlink_close_lib,
caml_dynlink_get_current_libs,
caml_dynlink_lookup_symbol,
caml_dynlink_open_lib,
caml_ensure_stack_capacity,
caml_eq_float,
caml_equal,
caml_exp_float,
caml_expm1_float,
caml_fill_string,
caml_final_register,
caml_final_release,
caml_float_compare,
caml_float_of_int,
caml_float_of_string,
caml_floor_float,
caml_fmod_float,
caml_format_float,
caml_format_int,
caml_frexp_float,
caml_gc_compaction,
caml_gc_counters,
caml_gc_full_major,
caml_gc_get,
caml_gc_major,
caml_gc_major_slice,
caml_gc_minor,
caml_gc_quick_stat,
caml_gc_set,
caml_gc_stat,
caml_ge_float,
caml_get_current_callstack,
caml_get_current_environment,
caml_get_exception_backtrace,
caml_get_exception_raw_backtrace,
caml_get_global_data,
caml_get_public_method,
caml_get_section_table,
caml_greaterequal,
caml_greaterthan,
caml_gt_float,
caml_hash,
caml_hash_univ_param,
caml_hypot_float,
caml_input_value,
caml_input_value_from_string,
caml_install_signal_handler,
caml_int32_add,
caml_int32_and,
caml_int32_bits_of_float,
caml_int32_bswap,
caml_int32_compare,
caml_int32_div,
caml_int32_float_of_bits,
caml_int32_format,
caml_int32_mod,
caml_int32_mul,
caml_int32_neg,
caml_int32_of_float,
caml_int32_of_int,
caml_int32_of_string,
caml_int32_or,
caml_int32_shift_left,
caml_int32_shift_right,
caml_int32_shift_right_unsigned,
caml_int32_sub,
caml_int32_to_float,
caml_int32_to_int,
caml_int32_xor,
caml_int64_add,
caml_int64_and,
caml_int64_bits_of_float,
caml_int64_bswap,
caml_int64_compare,
caml_int64_div,
caml_int64_float_of_bits,
caml_int64_format,
caml_int64_mod,
caml_int64_mul,
caml_int64_neg,
caml_int64_of_float,
caml_int64_of_int,
caml_int64_of_int32,
caml_int64_of_nativeint,
caml_int64_of_string,
caml_int64_or,
caml_int64_shift_left,
caml_int64_shift_right,
caml_int64_shift_right_unsigned,
caml_int64_sub,
caml_int64_to_float,
caml_int64_to_int,
caml_int64_to_int32,
caml_int64_to_nativeint,
caml_int64_xor,
caml_int_compare,
caml_int_of_float,
caml_int_of_string,
caml_invoke_traced_function,
caml_is_printable,
caml_lazy_follow_forward,
caml_lazy_make_forward,
caml_ldexp_float,
caml_le_float,
caml_lessequal,
caml_lessthan,
caml_lex_engine,
caml_log10_float,
caml_log1p_float,
caml_log_float,
caml_lt_float,
caml_make_array,
caml_make_vect,
caml_marshal_data_size,
caml_md5_chan,
caml_md5_string,
caml_ml_channel_size,
caml_ml_channel_size_64,
caml_ml_close_channel,
caml_ml_flush,
caml_ml_flush_partial,
caml_ml_input,
caml_ml_input_char,
caml_ml_input_int,
caml_ml_input_scan_line,
caml_ml_open_descriptor_in,
caml_ml_open_descriptor_out,
caml_ml_out_channels_list,
caml_ml_output,
caml_ml_output_char,
caml_ml_output_int,
caml_ml_output_partial,
caml_ml_pos_in,
caml_ml_pos_in_64,
caml_ml_pos_out,
caml_ml_pos_out_64,
caml_ml_seek_in,
caml_ml_seek_in_64,
caml_ml_seek_out,
caml_ml_seek_out_64,
caml_ml_set_binary_mode,
caml_ml_string_length,
caml_modf_float,
caml_mul_float,
caml_nativeint_add,
caml_nativeint_and,
caml_nativeint_bswap,
caml_nativeint_compare,
caml_nativeint_div,
caml_nativeint_format,
caml_nativeint_mod,
caml_nativeint_mul,
caml_nativeint_neg,
caml_nativeint_of_float,
caml_nativeint_of_int,
caml_nativeint_of_int32,
caml_nativeint_of_string,
caml_nativeint_or,
caml_nativeint_shift_left,
caml_nativeint_shift_right,
caml_nativeint_shift_right_unsigned,
caml_nativeint_sub,
caml_nativeint_to_float,
caml_nativeint_to_int,
caml_nativeint_to_int32,
caml_nativeint_xor,
caml_neg_float,
caml_neq_float,
caml_new_lex_engine,
caml_notequal,
caml_obj_add_offset,
caml_obj_block,
caml_obj_dup,
caml_obj_is_block,
caml_obj_set_tag,
caml_obj_tag,
caml_obj_truncate,
caml_output_value,
caml_output_value_to_buffer,
caml_output_value_to_string,
caml_parse_engine,
caml_power_float,
caml_realloc_global,
caml_record_backtrace,
caml_register_code_fragment,
caml_register_named_value,
caml_reify_bytecode,
caml_set_parser_trace,
caml_sin_float,
caml_sinh_float,
caml_sqrt_float,
caml_static_alloc,
caml_static_free,
caml_static_release_bytecode,
caml_static_resize,
caml_string_compare,
caml_string_equal,
caml_string_get,
caml_string_get16,
caml_string_get32,
caml_string_get64,
caml_string_greaterequal,
caml_string_greaterthan,
caml_string_lessequal,
caml_string_lessthan,
caml_string_notequal,
caml_string_set,
caml_string_set16,
caml_string_set32,
caml_string_set64,
caml_sub_float,
caml_sys_chdir,
caml_sys_close,
caml_sys_const_big_endian,
caml_sys_const_ostype_cygwin,
caml_sys_const_ostype_unix,
caml_sys_const_ostype_win32,
caml_sys_const_word_size,
caml_sys_exit,
caml_sys_file_exists,
caml_sys_get_argv,
caml_sys_get_config,
caml_sys_getcwd,
caml_sys_getenv,
caml_sys_is_directory,
caml_sys_open,
caml_sys_random_seed,
caml_sys_read_directory,
caml_sys_remove,
caml_sys_rename,
caml_sys_system_command,
caml_sys_time,
caml_tan_float,
caml_tanh_float,
caml_terminfo_backup,
caml_terminfo_resume,
caml_terminfo_setup,
caml_terminfo_standout,
caml_update_dummy,
caml_weak_blit,
caml_weak_check,
caml_weak_create,
caml_weak_get,
caml_weak_get_copy,
caml_weak_set,
(primitive) 0 };
const char * caml_names_of_builtin_cprim[] = {
"caml_abs_float",
"caml_acos_float",
"caml_add_float",
"caml_alloc_dummy",
"caml_alloc_dummy_float",
"caml_array_append",
"caml_array_blit",
"caml_array_concat",
"caml_array_get",
"caml_array_get_addr",
"caml_array_get_float",
"caml_array_set",
"caml_array_set_addr",
"caml_array_set_float",
"caml_array_sub",
"caml_array_unsafe_get",
"caml_array_unsafe_get_float",
"caml_array_unsafe_set",
"caml_array_unsafe_set_addr",
"caml_array_unsafe_set_float",
"caml_asin_float",
"caml_atan2_float",
"caml_atan_float",
"caml_backtrace_status",
"caml_bitvect_test",
"caml_blit_string",
"caml_bswap16",
"caml_ceil_float",
"caml_channel_descriptor",
"caml_classify_float",
"caml_compare",
"caml_convert_raw_backtrace",
"caml_copysign_float",
"caml_cos_float",
"caml_cosh_float",
"caml_create_string",
"caml_div_float",
"caml_dynlink_add_primitive",
"caml_dynlink_close_lib",
"caml_dynlink_get_current_libs",
"caml_dynlink_lookup_symbol",
"caml_dynlink_open_lib",
"caml_ensure_stack_capacity",
"caml_eq_float",
"caml_equal",
"caml_exp_float",
"caml_expm1_float",
"caml_fill_string",
"caml_final_register",
"caml_final_release",
"caml_float_compare",
"caml_float_of_int",
"caml_float_of_string",
"caml_floor_float",
"caml_fmod_float",
"caml_format_float",
"caml_format_int",
"caml_frexp_float",
"caml_gc_compaction",
"caml_gc_counters",
"caml_gc_full_major",
"caml_gc_get",
"caml_gc_major",
"caml_gc_major_slice",
"caml_gc_minor",
"caml_gc_quick_stat",
"caml_gc_set",
"caml_gc_stat",
"caml_ge_float",
"caml_get_current_callstack",
"caml_get_current_environment",
"caml_get_exception_backtrace",
"caml_get_exception_raw_backtrace",
"caml_get_global_data",
"caml_get_public_method",
"caml_get_section_table",
"caml_greaterequal",
"caml_greaterthan",
"caml_gt_float",
"caml_hash",
"caml_hash_univ_param",
"caml_hypot_float",
"caml_input_value",
"caml_input_value_from_string",
"caml_install_signal_handler",
"caml_int32_add",
"caml_int32_and",
"caml_int32_bits_of_float",
"caml_int32_bswap",
"caml_int32_compare",
"caml_int32_div",
"caml_int32_float_of_bits",
"caml_int32_format",
"caml_int32_mod",
"caml_int32_mul",
"caml_int32_neg",
"caml_int32_of_float",
"caml_int32_of_int",
"caml_int32_of_string",
"caml_int32_or",
"caml_int32_shift_left",
"caml_int32_shift_right",
"caml_int32_shift_right_unsigned",
"caml_int32_sub",
"caml_int32_to_float",
"caml_int32_to_int",
"caml_int32_xor",
"caml_int64_add",
"caml_int64_and",
"caml_int64_bits_of_float",
"caml_int64_bswap",
"caml_int64_compare",
"caml_int64_div",
"caml_int64_float_of_bits",
"caml_int64_format",
"caml_int64_mod",
"caml_int64_mul",
"caml_int64_neg",
"caml_int64_of_float",
"caml_int64_of_int",
"caml_int64_of_int32",
"caml_int64_of_nativeint",
"caml_int64_of_string",
"caml_int64_or",
"caml_int64_shift_left",
"caml_int64_shift_right",
"caml_int64_shift_right_unsigned",
"caml_int64_sub",
"caml_int64_to_float",
"caml_int64_to_int",
"caml_int64_to_int32",
"caml_int64_to_nativeint",
"caml_int64_xor",
"caml_int_compare",
"caml_int_of_float",
"caml_int_of_string",
"caml_invoke_traced_function",
"caml_is_printable",
"caml_lazy_follow_forward",
"caml_lazy_make_forward",
"caml_ldexp_float",
"caml_le_float",
"caml_lessequal",
"caml_lessthan",
"caml_lex_engine",
"caml_log10_float",
"caml_log1p_float",
"caml_log_float",
"caml_lt_float",
"caml_make_array",
"caml_make_vect",
"caml_marshal_data_size",
"caml_md5_chan",
"caml_md5_string",
"caml_ml_channel_size",
"caml_ml_channel_size_64",
"caml_ml_close_channel",
"caml_ml_flush",
"caml_ml_flush_partial",
"caml_ml_input",
"caml_ml_input_char",
"caml_ml_input_int",
"caml_ml_input_scan_line",
"caml_ml_open_descriptor_in",
"caml_ml_open_descriptor_out",
"caml_ml_out_channels_list",
"caml_ml_output",
"caml_ml_output_char",
"caml_ml_output_int",
"caml_ml_output_partial",
"caml_ml_pos_in",
"caml_ml_pos_in_64",
"caml_ml_pos_out",
"caml_ml_pos_out_64",
"caml_ml_seek_in",
"caml_ml_seek_in_64",
"caml_ml_seek_out",
"caml_ml_seek_out_64",
"caml_ml_set_binary_mode",
"caml_ml_string_length",
"caml_modf_float",
"caml_mul_float",
"caml_nativeint_add",
"caml_nativeint_and",
"caml_nativeint_bswap",
"caml_nativeint_compare",
"caml_nativeint_div",
"caml_nativeint_format",
"caml_nativeint_mod",
"caml_nativeint_mul",
"caml_nativeint_neg",
"caml_nativeint_of_float",
"caml_nativeint_of_int",
"caml_nativeint_of_int32",
"caml_nativeint_of_string",
"caml_nativeint_or",
"caml_nativeint_shift_left",
"caml_nativeint_shift_right",
"caml_nativeint_shift_right_unsigned",
"caml_nativeint_sub",
"caml_nativeint_to_float",
"caml_nativeint_to_int",
"caml_nativeint_to_int32",
"caml_nativeint_xor",
"caml_neg_float",
"caml_neq_float",
"caml_new_lex_engine",
"caml_notequal",
"caml_obj_add_offset",
"caml_obj_block",
"caml_obj_dup",
"caml_obj_is_block",
"caml_obj_set_tag",
"caml_obj_tag",
"caml_obj_truncate",
"caml_output_value",
"caml_output_value_to_buffer",
"caml_output_value_to_string",
"caml_parse_engine",
"caml_power_float",
"caml_realloc_global",
"caml_record_backtrace",
"caml_register_code_fragment",
"caml_register_named_value",
"caml_reify_bytecode",
"caml_set_parser_trace",
"caml_sin_float",
"caml_sinh_float",
"caml_sqrt_float",
"caml_static_alloc",
"caml_static_free",
"caml_static_release_bytecode",
"caml_static_resize",
"caml_string_compare",
"caml_string_equal",
"caml_string_get",
"caml_string_get16",
"caml_string_get32",
"caml_string_get64",
"caml_string_greaterequal",
"caml_string_greaterthan",
"caml_string_lessequal",
"caml_string_lessthan",
"caml_string_notequal",
"caml_string_set",
"caml_string_set16",
"caml_string_set32",
"caml_string_set64",
"caml_sub_float",
"caml_sys_chdir",
"caml_sys_close",
"caml_sys_const_big_endian",
"caml_sys_const_ostype_cygwin",
"caml_sys_const_ostype_unix",
"caml_sys_const_ostype_win32",
"caml_sys_const_word_size",
"caml_sys_exit",
"caml_sys_file_exists",
"caml_sys_get_argv",
"caml_sys_get_config",
"caml_sys_getcwd",
"caml_sys_getenv",
"caml_sys_is_directory",
"caml_sys_open",
"caml_sys_random_seed",
"caml_sys_read_directory",
"caml_sys_remove",
"caml_sys_rename",
"caml_sys_system_command",
"caml_sys_time",
"caml_tan_float",
"caml_tanh_float",
"caml_terminfo_backup",
"caml_terminfo_resume",
"caml_terminfo_setup",
"caml_terminfo_standout",
"caml_update_dummy",
"caml_weak_blit",
"caml_weak_check",
"caml_weak_create",
"caml_weak_get",
"caml_weak_get_copy",
"caml_weak_set",
(char *) 0 };
void caml_startup(char ** argv)
{
caml_startup_code(caml_code, sizeof(caml_code),
caml_data, sizeof(caml_data),
caml_sections, sizeof(caml_sections),
argv);
}
#ifdef __cplusplus
}
#endif
================================================
FILE: code/back-end-embed/hello.ml
================================================
let () = print_endline "Hello OCaml World!"
================================================
FILE: code/back-end-embed/link_custom.rawsh
================================================
$ ocamlc -a -o mylib.cma -custom a.cmo b.cmo -cclib -lmylib
================================================
FILE: code/back-end-embed/link_dllib.rawsh
================================================
$ ocamlc -a -o mylib.cma a.cmo b.cmo -dllib -lmylib
================================================
FILE: code/back-end-embed/main.c
================================================
#include <stdio.h>
#include <caml/alloc.h>
#include <caml/mlvalues.h>
#include <caml/memory.h>
#include <caml/callback.h>
int
main (int argc, char **argv)
{
printf("Before calling OCaml\n");
fflush(stdout);
caml_startup (argv);
printf("After calling OCaml\n");
return 0;
}
================================================
FILE: code/back-end-embed/run_debug_hello.sh
================================================
ocamlopt -runtime-variant d -verbose -o hello.native hello.ml
./hello.native
================================================
FILE: code/back-end-embed/xbuild_embed_binary.sh
================================================
gcc -fPIC -Wall -I`ocamlc -where` -L`ocamlc -where` -ltermcap -lm -ldl -o finalbc.native main.c embed_out.o -lcamlrun
./finalbc.native
================================================
FILE: code/back-end-embed/xbuild_embed_native.sh
================================================
ocamlopt -output-obj -o embed_native.o embed_me1.ml embed_me2.ml
gcc -Wall -I `ocamlc -where` -o final.native embed_native.o main.c -L `ocamlc -where` -lasmrun -ltermcap -lm -ldl
./final.native
================================================
FILE: code/classes/Iterator.java
================================================
// Java-style iterator, specified as an interface.
interface <T> iterator {
T Get();
boolean HasValue();
void Next();
};
================================================
FILE: code/classes/binary.topscript
================================================
class square w = object(self : 'self)
method width = w
method area = Float.of_int (self#width * self#width)
method equals (other : 'self) = other#width = self#width
end ;;
class circle r = object(self : 'self)
method radius = r
method area = 3.14 *. (Float.of_int self#radius) ** 2.0
method equals (other : 'self) = other#radius = self#radius
end ;;
#part 1
(new square 5)#equals (new square 5) ;;
(new circle 10)#equals (new circle 7) ;;
#part 2
type shape = < equals : shape -> bool; area : float > ;;
(new square 5 :> shape) ;;
#part 3
(object method area = 5 end) = (object method area = 5 end) ;;
#part 4
type shape_repr =
| Square of int
| Circle of int ;;
type shape =
< repr : shape_repr; equals : shape -> bool; area : float > ;;
class square w = object(self)
method width = w
method area = Float.of_int (self#width * self#width)
method repr = Square self#width
method equals (other : shape) = other#repr = self#repr
end ;;
================================================
FILE: code/classes/binary_larger.ml
================================================
class square w = object(self)
method width = w
method area = Float.of_int (self#width * self#width)
method larger other = self#area > other#area
end
================================================
FILE: code/classes/binary_module.ml
================================================
module Shapes : sig
type shape_repr
type shape =
< repr : shape_repr; equals : shape -> bool; area: float >
class square : int ->
object
method width : int
method area : float
method repr : shape_repr
method equals : shape -> bool
end
end = struct
type shape_repr =
| Square of int
| Circle of int
...
end
================================================
FILE: code/classes/build_doc.sh
================================================
corebuild doc.native
================================================
FILE: code/classes/citerator.cpp
================================================
// Abstract class definition in C++.
template<typename T>
class Iterator {
public:
virtual ~Iterator() {}
virtual T get() const = 0;
virtual bool has_value() const = 0;
virtual void next() = 0;
};
================================================
FILE: code/classes/class_types_stack.ml
================================================
module Stack = struct
class ['a] stack init = object
...
end
type 'a t = 'a stack
let make init = new stack init
end
(* part 1 *)
module AbstractStack : sig
type 'a t = < pop: 'a option; push: 'a -> unit >
val make : unit -> 'a t
end = Stack
(* part 2 *)
module VisibleStack : sig
type 'a t = < pop: 'a option; push: 'a -> unit >
class ['a] stack : object
val mutable v : 'a list
method pop : 'a option
method push : 'a -> unit
end
val make : unit -> 'a t
end = Stack
================================================
FILE: code/classes/doc.ml
================================================
type doc =
| Heading of string
| Paragraph of text_item list
| Definition of string list_item list
and text_item =
| Raw of string
| Bold of text_item list
| Enumerate of int list_item list
| Quote of doc
and 'a list_item =
{ tag: 'a;
text: text_item list }
(* part 1 *)
open Core.Std
class ['a] folder = object(self)
method doc acc = function
| Heading _ -> acc
| Paragraph text -> List.fold ~f:self#text_item ~init:acc text
| Definition list -> List.fold ~f:self#list_item ~init:acc list
method list_item: 'b. 'a -> 'b list_item -> 'a =
fun acc {tag; text} ->
List.fold ~f:self#text_item ~init:acc text
method text_item acc = function
| Raw _ -> acc
| Bold text -> List.fold ~f:self#text_item ~init:acc text
| Enumerate list -> List.fold ~f:self#list_item ~init:acc list
| Quote doc -> self#doc acc doc
end
(* part 2 *)
class counter = object
inherit [int] folder as super
method list_item acc li = acc
method text_item acc ti =
let acc = super#text_item acc ti in
match ti with
| Bold _ -> acc + 1
| _ -> acc
end
let count_doc = (new counter)#doc
(* part 3 *)
class ['a] folder2 = object(self)
method doc acc = function
| Heading str -> self#heading acc str
| Paragraph text -> self#paragraph acc text
| Definition list -> self#definition acc list
method list_item: 'b. 'a -> 'b list_item -> 'a =
fun acc {tag; text} ->
List.fold ~f:self#text_item ~init:acc text
method text_item acc = function
| Raw str -> self#raw acc str
| Bold text -> self#bold acc text
| Enumerate list -> self#enumerate acc list
| Quote doc -> self#quote acc doc
method private heading acc str = acc
method private paragraph acc text =
List.fold ~f:self#text_item ~init:acc text
method private definition acc list =
List.fold ~f:self#list_item ~init:acc list
method private raw acc str = acc
method private bold acc text =
List.fold ~f:self#text_item ~init:acc text
method private enumerate acc list =
List.fold ~f:self#list_item ~init:acc list
method private quote acc doc = self#doc acc doc
end
let f :
< doc : int -> doc -> int;
list_item : 'a . int -> 'a list_item -> int;
text_item : int -> text_item -> int > = new folder2
(* part 4 *)
class counter_with_private_method = object
inherit [int] folder2 as super
method list_item acc li = acc
method private bold acc txt =
let acc = super#bold acc txt in
acc + 1
end
(* part 5 *)
class counter_with_sig : object
method doc : int -> doc -> int
method list_item : int -> 'b list_item -> int
method text_item : int -> text_item -> int
end = object
inherit [int] folder2 as super
method list_item acc li = acc
method private bold acc txt =
let acc = super#bold acc txt in
acc + 1
end
================================================
FILE: code/classes/initializer.topscript
================================================
class obj x =
let () = printf "Creating obj %d\n" x in
object
val field = printf "Initializing field\n"; x
end ;;
let o = new obj 3 ;;
================================================
FILE: code/classes/istack.topscript
================================================
class istack = object
val mutable v = [0; 2]
method pop =
match v with
| hd :: tl ->
v <- tl;
Some hd
| [] -> None
method push hd =
v <- hd :: v
end ;;
#part 1
let s = new istack ;;
s#pop ;;
s#push 5 ;;
s#pop ;;
- : int option = Some 5
#part 2
type istack = < pop: int option; push: int -> unit > ;;
================================================
FILE: code/classes/iter.topscript
================================================
type 'a iterator = < get : 'a; has_value : bool; next : unit > ;;
#part 1
class ['a] list_iterator init = object
val mutable current : 'a list = init
method has_value = current <> []
method get =
match current with
| hd :: tl -> hd
| [] -> raise (Invalid_argument "no value")
method next =
match current with
| hd :: tl -> current <- tl
| [] -> raise (Invalid_argument "no value")
end ;;
#part 2
class ['a] stack init = object
val mutable v : 'a list = init
method pop =
match v with
| hd :: tl ->
v <- tl;
Some hd
| [] -> None
method push hd =
v <- hd :: v
method iterator : 'a iterator =
new list_iterator v
end ;;
#part 3
let s = new stack [] ;;
s#push 5 ;;
s#push 4 ;;
let it = s#iterator ;;
it#get ;;
it#next ;;
it#get ;;
it#next ;;
it#has_value ;;
#part 4
class ['a] stack init = object
val mutable v : 'a list = init
method pop =
match v with
| hd :: tl ->
v <- tl;
Some hd
| [] -> None
method push hd =
v <- hd :: v
method iter f =
List.iter ~f v
end ;;
#part 5
class ['a] stack init = object
val mutable v : 'a list = init
method pop =
match v with
| hd :: tl ->
v <- tl;
Some hd
| [] -> None
method push hd =
v <- hd :: v
method fold : 'b. ('b -> 'a -> 'b) -> 'b -> 'b =
(fun f init -> List.fold ~f ~init v)
end ;;
================================================
FILE: code/classes/stack.topscript
================================================
class ['a] stack init = object
val mutable v : 'a list = init
method pop =
match v with
| hd :: tl ->
v <- tl;
Some hd
| [] -> None
method push hd =
v <- hd :: v
end ;;
#part 1
class ['a] stack init = object
val mutable v = init
method pop =
match v with
| hd :: tl ->
v <- tl;
Some hd
| [] -> None
method push hd =
v <- hd :: v
end ;;
#part 2
class sstack init = object
inherit [string] stack init
method print =
List.iter ~f:print_string v
end ;;
#part 3
class double_stack init = object
inherit [int] stack init as super
method push hd =
super#push (hd * 2)
end ;;
================================================
FILE: code/classes-async/build_shapes.sh
================================================
corebuild -pkg async_graphics shapes.native
================================================
FILE: code/classes-async/multiple_inheritance.ml
================================================
open Core.Std
open Async.Std
open Async_graphics
class virtual shape x y = object(self)
method virtual private contains: int -> int -> bool
val mutable x: int = x
method x = x
val mutable y: int = y
method y = y
method on_click ?start ?stop f =
on_click ?start ?stop
(fun {mouse_x;mouse_y} ->
if self#contains mouse_x mouse_y then
f mouse_x mouse_y)
method on_mousedown ?start ?stop f =
on_mousedown ?start ?stop
(fun {mouse_x;mouse_y} ->
if self#contains mouse_x mouse_y then
f mouse_x mouse_y)
end
class square w x y = object
inherit shape x y
val mutable width = w
method width = width
method draw = fill_rect x y width width
method private contains x' y' =
x <= x' && x' <= x + width &&
y <= y' && y' <= y + width
end
(* part 1 *)
class square_outline w x y = object
inherit square w x y
method draw = draw_rect x y width width
end
================================================
FILE: code/classes-async/multiple_inheritance_wrong.ml
================================================
open Core.Std
open Async.Std
open Async_graphics
class virtual shape x y = object(self)
method virtual private contains: int -> int -> bool
val mutable x: int = x
method x = x
val mutable y: int = y
method y = y
method on_click ?start ?stop f =
on_click ?start ?stop
(fun {mouse_x;mouse_y} ->
if self#contains mouse_x mouse_y then
f mouse_x mouse_y)
method on_mousedown ?start ?stop f =
on_mousedown ?start ?stop
(fun {mouse_x;mouse_y} ->
if self#contains mouse_x mouse_y then
f mouse_x mouse_y)
end
class square w x y = object
inherit shape x y
val mutable width = w
method width = width
method draw = fill_rect x y width width
method private contains x' y' =
x <= x' && x' <= x + width &&
y <= y' && y' <= y + width
end
(* part 1 *)
class square_outline w x y = object
method draw = draw_rect x y w w
inherit square w x y
end
================================================
FILE: code/classes-async/shapes.ml
================================================
open Core.Std
open Async.Std
open Async_graphics
type drawable = < draw: unit >
(* part 1 *)
class virtual shape x y = object(self)
method virtual private contains: int -> int -> bool
val mutable x: int = x
method x = x
val mutable y: int = y
method y = y
method on_click ?start ?stop f =
on_click ?start ?stop
(fun ev ->
if self#contains ev.mouse_x ev.mouse_y then
f ev.mouse_x ev.mouse_y)
method on_mousedown ?start ?stop f =
on_mousedown ?start ?stop
(fun ev ->
if self#contains ev.mouse_x ev.mouse_y then
f ev.mouse_x ev.mouse_y)
end
(* part 2 *)
class square w x y = object
inherit shape x y
val mutable width = w
method width = width
method draw = fill_rect x y width width
method private contains x' y' =
x <= x' && x' <= x + width &&
y <= y' && y' <= y + width
end
class circle r x y = object
inherit shape x y
val mutable radius = r
method radius = radius
method draw = fill_circle x y radius
method private contains x' y' =
let dx = abs (x' - x) in
let dy = abs (y' - y) in
let dist = sqrt (Float.of_int ((dx * dx) + (dy * dy))) in
dist <= (Float.of_int radius)
end
(* part 3 *)
class growing_circle r x y = object(self)
inherit circle r x y
initializer
self#on_click (fun _x _y -> radius <- radius * 2)
end
(* part 4 *)
class virtual draggable = object(self)
method virtual on_mousedown:
?start:unit Deferred.t ->
?stop:unit Deferred.t ->
(int -> int -> unit) -> unit
val virtual mutable x: int
val virtual mutable y: int
val mutable dragging = false
method dragging = dragging
initializer
self#on_mousedown
(fun mouse_x mouse_y ->
let offset_x = x - mouse_x in
let offset_y = y - mouse_y in
let mouse_up = Ivar.create () in
let stop = Ivar.read mouse_up in
dragging <- true;
on_mouseup ~stop
(fun _ ->
Ivar.fill mouse_up ();
dragging <- false);
on_mousemove ~stop
(fun ev ->
x <- ev.mouse_x + offset_x;
y <- ev.mouse_y + offset_y))
end
(* part 5 *)
class small_square = object
inherit square 20 40 40
inherit draggable
end
(* part 6 *)
class virtual animated span = object(self)
method virtual on_click:
?start:unit Deferred.t ->
?stop:unit Deferred.t ->
(int -> int -> unit) -> unit
val mutable updates: (int -> unit) list = []
val mutable step = 0
val mutable running = false
method running = running
method animate =
step <- 0;
running <- true;
let stop =
Clock.after span
>>| fun () -> running <- false
in
Clock.every ~stop (Time.Span.of_sec (1.0 /. 24.0))
(fun () ->
step <- step + 1;
List.iter ~f:(fun f -> f step) updates
)
initializer
self#on_click (fun _x _y -> if not self#running then self#animate)
end
(* part 7 *)
class my_circle = object
inherit circle 20 50 50
inherit animated Time.Span.second
initializer updates <- [fun _ -> x <- x + 5]
end
(* part 8 *)
class virtual linear x' y' = object
val virtual mutable updates: (int -> unit) list
val virtual mutable x: int
val virtual mutable y: int
initializer
let update _ =
x <- x + x';
y <- y + y'
in
updates <- update :: updates
end
let pi = (atan 1.0) *. 4.0
class virtual harmonic offset x' y' = object
val virtual mutable updates: (int -> unit) list
val virtual mutable x: int
val virtual mutable y: int
initializer
let update step =
let m = sin (offset +. ((Float.of_int step) *. (pi /. 64.))) in
let x' = Float.to_int (m *. Float.of_int x') in
let y' = Float.to_int (m *. Float.of_int y') in
x <- x + x';
y <- y + y'
in
updates <- update :: updates
end
(* part 9 *)
class my_square x y = object
inherit square 40 x y
inherit draggable
inherit animated (Time.Span.of_int_sec 5)
inherit linear 5 0
inherit harmonic 0.0 7 ~-10
end
let my_circle = object
inherit circle 30 250 250
inherit animated (Time.Span.minute)
inherit harmonic 0.0 10 0
inherit harmonic (pi /. 2.0) 0 10
end
(* part 10 *)
let main () =
let shapes = [
(my_circle :> drawable);
(new my_square 50 350 :> drawable);
(new my_square 50 200 :> drawable);
(new growing_circle 20 70 70 :> drawable);
] in
let repaint () =
clear_graph ();
List.iter ~f:(fun s -> s#draw) shapes;
synchronize ()
in
open_graph "";
auto_synchronize false;
Clock.every (Time.Span.of_sec (1.0 /. 24.0)) repaint
let () = never_returns (Scheduler.go_main ~main ())
================================================
FILE: code/classes-async/verbose_shapes.ml
================================================
open Core.Std
open Async.Std
open Async_graphics
(* part 1 *)
class square w x y = object(self)
val mutable x: int = x
method x = x
val mutable y: int = y
method y = y
val mutable width = w
method width = width
method draw = fill_rect x y width width
method private contains x' y' =
x <= x' && x' <= x + width &&
y <= y' && y' <= y + width
method on_click ?start ?stop f =
on_click ?start ?stop
(fun ev ->
if self#contains ev.mouse_x ev.mouse_y then
f ev.mouse_x ev.mouse_y)
end
(* part 2 *)
class circle r x y = object(self)
val mutable x: int = x
method x = x
val mutable y: int = y
method y = y
val mutable radius = r
method radius = radius
method draw = fill_circle x y radius
method private contains x' y' =
let dx = abs (x' - x) in
let dy = abs (y' - y) in
let dist = sqrt (Float.of_int ((dx * dx) + (dy * dy))) in
dist <= (Float.of_int radius)
method on_click ?start ?stop f =
on_click ?start ?stop
(fun ev ->
if self#contains ev.mouse_x ev.mouse_y then
f ev.mouse_x ev.mouse_y)
end
================================================
FILE: code/command-line-parsing/_tags
================================================
true: short_paths
================================================
FILE: code/command-line-parsing/basic.topscript
================================================
Command.basic ;;
================================================
FILE: code/command-line-parsing/basic_md5.ml
================================================
open Core.Std
let do_hash file =
In_channel.with_file file ~f:(fun ic ->
let open Cryptokit in
hash_channel (Hash.md5 ()) ic
|> transform_string (Hexa.encode ())
|> print_endline
)
(* part 1 *)
let spec =
let open Command.Spec in
empty
+> anon ("filename" %: string)
(* part 2 *)
let command =
Command.basic
~summary:"Generate an MD5 hash of the input data"
~readme:(fun () -> "More detailed information")
spec
(fun filename () -> do_hash filename)
(* part 3 *)
let () =
Command.run ~version:"1.0" ~build_info:"RWO" command
================================================
FILE: code/command-line-parsing/basic_md5_as_filename.ml
================================================
open Core.Std
let do_hash file () =
In_channel.with_file file ~f:(
fun ic ->
let open Cryptokit in
hash_channel (Hash.md5 ()) ic
|> transform_string (Hexa.encode ())
|> print_endline
)
(* part 1 *)
let command =
Command.basic
~summary:"Generate an MD5 hash of the input data"
~readme:(fun () -> "More detailed information")
Command.Spec.(empty +> anon ("filename" %: file))
do_hash
let () =
Command.run ~version:"1.0" ~build_info:"RWO" command
================================================
FILE: code/command-line-parsing/basic_md5_sequence.ml
================================================
open Core.Std
let do_hash filename ic =
let open Cryptokit in
hash_channel (Hash.md5 ()) ic
|> transform_string (Hexa.encode ())
|> fun md5 -> printf "MD5 (%s) = %s\n" filename md5
let command =
Command.basic
~summary:"Generate an MD5 hash of the input data"
~readme:(fun () -> "More detailed information")
Command.Spec.(empty +> anon (sequence ("filename" %: file)))
(fun files () ->
match files with
| [] -> do_hash "-" In_channel.stdin
| _ ->
List.iter files ~f:(fun file ->
In_channel.with_file ~f:(do_hash file) file
)
)
let () =
Command.run ~version:"1.0" ~build_info:"RWO" command
================================================
FILE: code/command-line-parsing/basic_md5_succinct.ml
================================================
open Core.Std
let do_hash file () =
In_channel.with_file file ~f:(fun ic ->
let open Cryptokit in
hash_channel (Hash.md5 ()) ic
|> transform_string (Hexa.encode ())
|> print_endline
)
let command =
Command.basic
~summary:"Generate an MD5 hash of the input data"
~readme:(fun () -> "More detailed information")
Command.Spec.(empty +> anon ("filename" %: string))
do_hash
let () =
Command.run ~version:"1.0" ~build_info:"RWO" command
================================================
FILE: code/command-line-parsing/basic_md5_with_custom_arg.ml
================================================
open Core.Std
let do_hash file () =
In_channel.with_file file ~f:(fun ic ->
let open Cryptokit in
hash_channel (Hash.md5 ()) ic
|> transform_string (Hexa.encode ())
|> print_endline
)
let regular_file =
Command.Spec.Arg_type.create
(fun filename ->
match Sys.is_file filename with
| `Yes -> filename
| `No | `Unknown ->
eprintf "'%s' is not a regular file.\n%!" filename;
exit 1
)
let command =
Command.basic
~summary:"Generate an MD5 hash of the input data"
~readme:(fun () -> "More detailed information")
Command.Spec.(empty +> anon ("filename" %: regular_file))
do_hash
let () =
Command.run ~version:"1.0" ~build_info:"RWO" command
================================================
FILE: code/command-line-parsing/basic_md5_with_default_file.ml
================================================
open Core.Std
let get_inchan = function
| "-" -> In_channel.stdin
| filename -> In_channel.create ~binary:true filename
let do_hash filename () =
let open Cryptokit in
get_inchan filename
|> hash_channel (Hash.md5 ())
|> transform_string (Hexa.encode ())
|> print_endline
let command =
Command.basic
~summary:"Generate an MD5 hash of the input data"
~readme:(fun () -> "More detailed information")
Command.Spec.(
empty
+> anon (maybe_with_default "-" ("filename" %: file))
)
do_hash
let () =
Command.run ~version:"1.0" ~build_info:"RWO" command
================================================
FILE: code/command-line-parsing/basic_md5_with_flags.ml
================================================
open Core.Std
open Cryptokit
let checksum_from_string buf =
hash_string (Hash.md5 ()) buf
|> transform_string (Hexa.encode ())
|> print_endline
let checksum_from_file filename =
let ic = match filename with
| "-" -> In_channel.stdin
| _ -> In_channel.create ~binary:true filename
in
hash_channel (Hash.md5 ()) ic
|> transform_string (Hexa.encode ())
|> print_endline
let command =
Command.basic
~summary:"Generate an MD5 hash of the input data"
Command.Spec.(
empty
+> flag "-s" (optional string) ~doc:"string Checksum the given string"
+> flag "-t" no_arg ~doc:" run a built-in time trial"
+> anon (maybe_with_default "-" ("filename" %: file))
)
(fun use_string trial filename () ->
match trial with
| true -> printf "Running time trial\n"
| false -> begin
match use_string with
| Some buf -> checksum_from_string buf
| None -> checksum_from_file filename
end
)
let () = Command.run command
================================================
FILE: code/command-line-parsing/basic_md5_with_opt_flags.ml
================================================
open Core.Std
open Cryptokit
let checksum_from_string buf =
hash_string (Hash.md5 ()) buf
|> transform_string (Hexa.encode ())
|> print_endline
let checksum_from_file filename =
let ic = match filename with
| "-" -> In_channel.stdin
| _ -> In_channel.create ~binary:true filename
in
hash_channel (Hash.md5 ()) ic
|> transform_string (Hexa.encode ())
|> print_endline
let command =
Command.basic
~summary:"Generate an MD5 hash of the input data"
Command.Spec.(
empty
+> flag "-s" (optional string)
~doc:"string Checksum the given string"
+> flag "-v" (listed bool)
~doc:" verbosity level. Repeat multiple times for more info."
+> flag "-t" no_arg
~doc:" run a built-in time trial"
+> flag "-tlen" (optional_with_default 5 int)
~doc:"seconds length of time trial"
+> anon (maybe_with_default "-" ("filename" %: file))
)
(fun use_string verbosity trial trial_secs filename () ->
eprintf "Verbosity level: %d\n" (List.length verbosity);
match trial with
| true -> printf "Running time trial for %d seconds\n" trial_secs
| false -> begin
match use_string with
| Some buf -> checksum_from_string buf
| None -> checksum_from_file filename
end
)
let () = Command.run command
================================================
FILE: code/command-line-parsing/basic_md5_with_optional_file.ml
================================================
open Core.Std
let get_inchan = function
| None | Some "-" ->
In_channel.stdin
| Some filename ->
In_channel.create ~binary:true filename
let do_hash filename () =
let open Cryptokit in
get_inchan filename
|> hash_channel (Hash.md5 ())
|> transform_string (Hexa.encode ())
|> print_endline
let command =
Command.basic
~summary:"Generate an MD5 hash of the input data"
~readme:(fun () -> "More detailed information")
Command.Spec.(empty +> anon (maybe ("filename" %: file)))
do_hash
let () =
Command.run ~version:"1.0" ~build_info:"RWO" command
================================================
FILE: code/command-line-parsing/basic_md5_with_optional_file_broken.ml
================================================
open Core.Std
let do_hash file () =
In_channel.with_file file ~f:(
fun ic ->
let open Cryptokit in
hash_channel (Hash.md5 ()) ic
|> transform_string (Hexa.encode ())
|> print_endline
)
(* part 1 *)
let command =
Command.basic
~summary:"Generate an MD5 hash of the input data"
~readme:(fun () -> "More detailed information")
Command.Spec.(empty +> anon (maybe ("filename" %: string)))
do_hash
let () =
Command.run ~version:"1.0" ~build_info:"RWO" command
================================================
FILE: code/command-line-parsing/build_and_run_cal_add_interactive.rawsh
================================================
$ ocamlbuild -use-ocamlfind -tag thread -pkg core cal_add_interactive.native
$ ./cal_add_interactive.native 2013-12-01
enter days:
35
2014-01-05
================================================
FILE: code/command-line-parsing/build_basic_md5.sh
================================================
corebuild -pkg cryptokit basic_md5.native
================================================
FILE: code/command-line-parsing/build_basic_md5_as_filename.sh
================================================
corebuild -pkg cryptokit basic_md5_as_filename.native
================================================
FILE: code/command-line-parsing/build_basic_md5_sequence.sh
================================================
corebuild -pkg cryptokit basic_md5_sequence.native
================================================
FILE: code/command-line-parsing/build_basic_md5_with_custom_arg.sh
================================================
corebuild -pkg cryptokit basic_md5_with_custom_arg.native
================================================
FILE: code/command-line-parsing/build_basic_md5_with_default_file.sh
================================================
corebuild -pkg cryptokit basic_md5_with_default_file.native
================================================
FILE: code/command-line-parsing/build_basic_md5_with_flags.sh
================================================
corebuild -pkg cryptokit basic_md5_with_flags.native
================================================
FILE: code/command-line-parsing/build_basic_md5_with_opt_flags.sh
================================================
corebuild -pkg cryptokit basic_md5_with_opt_flags.native
================================================
FILE: code/command-line-parsing/build_basic_md5_with_optional_file.sh
================================================
corebuild -pkg cryptokit basic_md5_with_optional_file.native
================================================
FILE: code/command-line-parsing/build_basic_md5_with_optional_file_broken.errsh
================================================
corebuild -pkg cryptokit basic_md5_with_optional_file_broken.native
================================================
FILE: code/command-line-parsing/build_cal_add_days.sh
================================================
corebuild cal_add_days.native
================================================
FILE: code/command-line-parsing/build_cal_add_sub_days.sh
================================================
corebuild cal_add_sub_days.native
./cal_add_sub_days.native -help
================================================
FILE: code/command-line-parsing/build_cal_append.sh
================================================
corebuild cal_append.native
================================================
FILE: code/command-line-parsing/build_cal_append_broken.errsh
================================================
corebuild cal_append_broken.native
================================================
FILE: code/command-line-parsing/cal.cmd
================================================
function _jsautocom_96173 {
export COMP_CWORD
COMP_WORDS[0]=./cal_add_sub_days.native
COMPREPLY=($("${COMP_WORDS[@]}"))
}
complete -F _jsautocom_96173 ./cal_add_sub_days.native
================================================
FILE: code/command-line-parsing/cal_add_days.ml
================================================
open Core.Std
let add =
Command.basic
~summary:"Add [days] to the [base] date and print day"
Command.Spec.(
empty
+> anon ("base" %: date)
+> anon ("days" %: int)
)
(fun base span () ->
Date.add_days base span
|> Date.to_string
|> print_endline
)
let () = Command.run add
================================================
FILE: code/command-line-parsing/cal_add_interactive.ml
================================================
open Core.Std
let add_days base span () =
Date.add_days base span
|> Date.to_string
|> print_endline
let add =
Command.basic
~summary:"Add [days] to the [base] date and print day"
Command.Spec.(
step
(fun m base days ->
match days with
| Some days ->
m base days
| None ->
print_endline "enter days: ";
read_int ()
|> m base
)
+> anon ("base" %: date)
+> anon (maybe ("days" %: int))
)
add_days
let () = Command.run add
================================================
FILE: code/command-line-parsing/cal_add_labels.ml
================================================
open Core.Std
let add_days ~base_date ~num_days () =
Date.add_days base_date num_days
|> Date.to_string
|> print_endline
let add =
Command.basic
~summary:"Add [days] to the [base] date and print day"
Command.Spec.(
step (fun m base days -> m ~base_date:base ~num_days:days)
+> anon ("base" %: date)
+> anon ("days" %: int)
)
add_days
let () = Command.run add
================================================
FILE: code/command-line-parsing/cal_add_sub_days.ml
================================================
open Core.Std
let add =
Command.basic ~summary:"Add [days] to the [base] date"
Command.Spec.(
empty
+> anon ("base" %: date)
+> anon ("days" %: int)
)
(fun base span () ->
Date.add_days base span
|> Date.to_string
|> print_endline
)
let diff =
Command.basic ~summary:"Show days between [date1] and [date2]"
Command.Spec.(
empty
+> anon ("date1" %: date)
+> anon ("date2" %: date)
)
(fun date1 date2 () ->
Date.diff date1 date2
|> printf "%d days\n"
)
let command =
Command.group ~summary:"Manipulate dates"
[ "add", add; "diff", diff ]
let () = Command.run command
================================================
FILE: code/command-line-parsing/cal_append.ml
================================================
open Core.Std
let add ~common =
Command.basic ~summary:"Add [days] to the [base] date"
Command.Spec.(
empty
+> anon ("base" %: date)
+> anon ("days" %: int)
++ common
)
(fun base span debug verbose () ->
Date.add_days base span
|> Date.to_string
|> print_endline
)
let diff ~common =
Command.basic ~summary:"Show days between [date2] and [date1]"
Command.Spec.(
empty
+> anon ("date1" %: date)
+> anon ("date2" %: date)
++ common
)
(fun date1 date2 debug verbose () ->
Date.diff date1 date2
|> printf "%d days\n"
)
(* part 1 *)
let () =
let common =
Command.Spec.(
empty
+> flag "-d" (optional_with_default false bool) ~doc:" Debug mode"
+> flag "-v" (optional_with_default false bool) ~doc:" Verbose output"
)
in
List.map ~f:(fun (name, cmd) -> (name, cmd ~common))
[ "add", add; "diff", diff ]
|> Command.group ~summary:"Manipulate dates"
|> Command.run
================================================
FILE: code/command-line-parsing/cal_append_broken.ml
================================================
open Core.Std
let add ~common =
Command.basic ~summary:"Add [days] to the [base] date"
Command.Spec.(
empty
+> anon ("base" %: date)
+> anon ("days" %: int)
++ common
)
(fun base span debug verbose () ->
Date.add_days base span
|> Date.to_string
|> print_endline
)
let diff ~common =
Command.basic ~summary:"Show days between [date2] and [date1]"
Command.Spec.(
empty
+> anon ("date1" %: date)
+> anon ("date2" %: date)
++ common
)
(fun date1 date2 debug verbose () ->
Date.diff date1 date2
|> printf "%d days\n"
)
(* part 1 *)
let () =
let common =
Command.Spec.(
empty
+> flag "-d" (optional_with_default false bool) ~doc:" Debug mode"
)
in
List.map ~f:(fun (name, cmd) -> (name, cmd ~common))
[ "add", add; "diff", diff ]
|> Command.group ~summary:"Manipulate dates"
|> Command.run
================================================
FILE: code/command-line-parsing/cal_completion.rawsh
================================================
$ env COMMAND_OUTPUT_INSTALLATION_BASH=1 ./cal_add_sub_days.native > cal.cmd
$ . cal.cmd
$ ./cal_add_sub_days.native <tab>
add diff help version
================================================
FILE: code/command-line-parsing/command_types.topscript
================================================
Command.Spec.empty ;;
Command.Spec.(empty +> anon ("foo" %: int)) ;;
================================================
FILE: code/command-line-parsing/get_basic_md5_help.errsh
================================================
./basic_md5.native
================================================
FILE: code/command-line-parsing/get_basic_md5_version.sh
================================================
./basic_md5.native -version
./basic_md5.native -build-info
================================================
FILE: code/command-line-parsing/group.topscript
================================================
Command.basic ;;
Command.group ;;
================================================
FILE: code/command-line-parsing/md5_completion.sh
================================================
env COMMAND_OUTPUT_INSTALLATION_BASH=1 ./basic_md5_with_flags.native
================================================
FILE: code/command-line-parsing/opam.rawsh
================================================
$ opam config env
$ opam remote list -k git
$ opam install --help
$ opam install cryptokit --verbose
================================================
FILE: code/command-line-parsing/run_basic_and_default_md5.sh
================================================
cat /etc/passwd | ./basic_md5_with_optional_file.native
cat /etc/passwd | ./basic_md5_with_default_file.native
================================================
FILE: code/command-line-parsing/run_basic_md5.sh
================================================
./basic_md5.native ./basic_md5.native
================================================
FILE: code/command-line-parsing/run_basic_md5_as_filename.errsh
================================================
./basic_md5_as_filename.native nonexistent
================================================
FILE: code/command-line-parsing/run_basic_md5_flags_help.sh
================================================
./basic_md5_with_flags.native -help
./basic_md5_with_flags.native -s "ocaml rocks"
================================================
FILE: code/command-line-parsing/run_basic_md5_with_custom_arg.errsh
================================================
./basic_md5_with_custom_arg.native /etc/passwd
./basic_md5_with_custom_arg.native /dev/null
================================================
FILE: code/command-line-parsing/run_cal_add_sub_days.sh
================================================
./cal_add_sub_days.native add 2012-12-25 40
./cal_add_sub_days.native diff 2012-12-25 2012-11-01
================================================
FILE: code/command-line-parsing/single_anon_filename.topscript
================================================
open Command.Spec ;;
empty +> anon ("filename" %: string) ;;
================================================
FILE: code/command-line-parsing/step.topscript
================================================
open Command.Spec ;;
step (fun m (base:Date.t) days ->
match days with
| Some days -> m base days
| None ->
print_endline "enter days: ";
m base (read_int ())) ;;
================================================
FILE: code/corebuild
================================================
#!/bin/sh
ocamlbuild \
-use-ocamlfind \
-classic-display \
-syntax camlp4o \
-pkg core,core_extended,async,textutils,core_bench \
-pkg sexplib.syntax,comparelib.syntax,fieldslib.syntax,variantslib.syntax \
-pkg bin_prot.syntax \
-tag thread \
-tag debug \
-cflags -short-paths \
-cflags "-w @A-4-33-41-42-43-34-44" \
-cflags -strict-sequence \
-cflags -principal \
$@
================================================
FILE: code/ctypes/ctypes.mli
================================================
type 'a typ
(* part 1 *)
val void : unit typ
val char : char typ
val schar : int typ
val short : int typ
val int : int typ
val long : long typ
val llong : llong typ
val nativeint : nativeint typ
val int8_t : int typ
val int16_t : int typ
val int32_t : int32 typ
val int64_t : int64 typ
val uchar : uchar typ
val uchar : uchar typ
val uint8_t : uint8 typ
val uint16_t : uint16 typ
val uint32_t : uint32 typ
val uint64_t : uint64 typ
val size_t : size_t typ
val ushort : ushort typ
val uint : uint typ
val ulong : ulong typ
val ullong : ullong typ
val float : float typ
val double : float typ
val complex32 : Complex.t typ
val complex64 : Complex.t typ
(* part 2 *)
val view :
read:('a -> 'b) ->
write:('b -> 'a) ->
'a typ -> 'b typ
(* part 3 *)
val string_of_char_ptr : char ptr -> string
val char_ptr_of_string : string -> char ptr
(* part 4 *)
val string : string.typ
(* part 5 *)
module Array : sig
type 'a t = 'a array
val get : 'a t -> int -> 'a
val set : 'a t -> int -> 'a -> unit
val of_list : 'a typ -> 'a list -> 'a t
val to_list : 'a t -> 'a list
val length : 'a t -> int
val start : 'a t -> 'a ptr
val from_ptr : 'a ptr -> int -> 'a t
val make : 'a typ -> ?initial:'a -> int -> 'a t
end
================================================
FILE: code/ctypes/ctypes_impl.ml
================================================
let string =
view (char ptr)
~read:string_of_char_ptr
~write:char_ptr_of_string
================================================
FILE: code/error-handling/blow_up.ml
================================================
open Core.Std
exception Empty_list
let list_max = function
| [] -> raise Empty_list
| hd :: tl -> List.fold tl ~init:hd ~f:(Int.max)
let () =
printf "%d\n" (list_max [1;2;3]);
printf "%d\n" (list_max [])
================================================
FILE: code/error-handling/build_blow_up.errsh
================================================
corebuild blow_up.byte
./blow_up.byte
================================================
FILE: code/error-handling/build_blow_up_notrace.errsh
================================================
corebuild blow_up.byte
OCAMLRUNPARAM= ./blow_up.byte
================================================
FILE: code/error-handling/exn_cost.ml
================================================
open Core.Std
open Core_bench.Std
let simple_computation () =
List.range 0 10
|> List.fold ~init:0 ~f:(fun sum x -> sum + x * x)
|> ignore
let simple_with_handler () =
try simple_computation () with Exit -> ()
let end_with_exn () =
try
simple_computation ();
raise Exit
with Exit -> ()
let () =
[ Bench.Test.create ~name:"simple computation"
(fun () -> simple_computation ());
Bench.Test.create ~name:"simple computation w/handler"
(fun () -> simple_with_handler ());
Bench.Test.create ~name:"end with exn"
(fun () -> end_with_exn ());
]
|> Bench.make_command
|> Command.run
================================================
FILE: code/error-handling/main.topscript
================================================
List.find;;
#part 1
List.find [1;2;3] ~f:(fun x -> x >= 2) ;;
List.find [1;2;3] ~f:(fun x -> x >= 10) ;;
#part 2
let compute_bounds ~cmp list =
let sorted = List.sort ~cmp list in
match List.hd sorted, List.last sorted with
| None,_ | _, None -> None
| Some x, Some y -> Some (x,y)
;;
#part 3
let find_mismatches table1 table2 =
Hashtbl.fold table1 ~init:[] ~f:(fun ~key ~data mismatches ->
match Hashtbl.find table2 key with
| Some data' when data' <> data -> key :: mismatches
| _ -> mismatches
)
;;
#part 4
[ Ok 3; Error "abject failure"; Ok 4 ];;
#part 5
Error.of_string "something went wrong";;
#part 6
Error.of_thunk (fun () ->
sprintf "something went wrong: %f" 32.3343);;
#part 7
Error.create "Something failed a long time ago" Time.epoch Time.sexp_of_t;;
#part 8
let custom_to_sexp = <:sexp_of<float * string list * int>>;;
custom_to_sexp (3.5, ["a";"b";"c"], 6034);;
#part 9
Error.create "Something went terribly wrong"
(3.5, ["a";"b";"c"], 6034)
<:sexp_of<float * string list * int>> ;;
#part 10
Error.tag
(Error.of_list [ Error.of_string "Your tires were slashed";
Error.of_string "Your windshield was smashed" ])
"over the weekend"
;;
#part 11
let bind option f =
match option with
| None -> None
| Some x -> f x
;;
#part 12
let compute_bounds ~cmp list =
let sorted = List.sort ~cmp list in
Option.bind (List.hd sorted) (fun first ->
Option.bind (List.last sorted) (fun last ->
Some (first,last)))
;;
#part 13
let compute_bounds ~cmp list =
let open Option.Monad_infix in
let sorted = List.sort ~cmp list in
List.hd sorted >>= fun first ->
List.last sorted >>= fun last ->
Some (first,last)
;;
#part 14
let compute_bounds ~cmp list =
let sorted = List.sort ~cmp list in
Option.both (List.hd sorted) (List.last sorted)
;;
#part 15
3 / 0;;
#part 16
List.map ~f:(fun x -> 100 / x) [1;3;0;4];;
#part 17
List.map ~f:(fun x -> printf "%d\n%!" x; 100 / x) [1;3;0;4];;
#part 18
exception Key_not_found of string;;
raise (Key_not_found "a");;
#part 19
let exceptions = [ Not_found; Division_by_zero; Key_not_found "b" ];;
List.filter exceptions ~f:(function
| Key_not_found _ | Not_found -> true
| _ -> false);;
#part 20
let rec find_exn alist key = match alist with
| [] -> raise (Key_not_found key)
| (key',data) :: tl -> if key = key' then data else find_exn tl key
;;
let alist = [("a",1); ("b",2)];;
find_exn alist "a";;
find_exn alist "c";;
#part 21
raise;;
#part 22
let rec forever () = forever ();;
#part 23
exception Wrong_date of Date.t;;
Wrong_date (Date.of_string "2011-02-23");;
#part 24
exception Wrong_date of Date.t with sexp;;
Wrong_date (Date.of_string "2011-02-23");;
#part 25
let failwith msg = raise (Failure msg);;
#part 26
let merge_lists xs ys ~f =
if List.length xs <> List.length ys then None
else
let rec loop xs ys =
match xs,ys with
| [],[] -> []
| x::xs, y::ys -> f x y :: loop xs ys
| _ -> assert false
in
Some (loop xs ys)
;;
merge_lists [1;2;3] [-1;1;2] ~f:(+);;
merge_lists [1;2;3] [-1;1] ~f:(+);;
#part 27
let merge_lists xs ys ~f =
let rec loop xs ys =
match xs,ys with
| [],[] -> []
| x::xs, y::ys -> f x y :: loop xs ys
| _ -> assert false
in
loop xs ys
;;
merge_lists [1;2;3] [-1] ~f:(+);;
#part 28
let reminders_of_sexp =
<:of_sexp<(Time.t * string) list>>
;;
let load_reminders filename =
let inc = In_channel.create filename in
let reminders = reminders_of_sexp (Sexp.input_sexp inc) in
In_channel.close inc;
reminders
;;
#part 29
let load_reminders filename =
let inc = In_channel.create filename in
protect ~f:(fun () -> reminders_of_sexp (Sexp.input_sexp inc))
~finally:(fun () -> In_channel.close inc)
;;
#part 30
let reminders_of_sexp filename =
In_channel.with_file filename ~f:(fun inc ->
reminders_of_sexp (Sexp.input_sexp inc))
;;
#part 31
let lookup_weight ~compute_weight alist key =
try
let data = List.Assoc.find_exn alist key in
compute_weight data
with
Not_found -> 0. ;;
#part 32
lookup_weight ~compute_weight:(fun _ -> raise Not_found)
["a",3; "b",4] "a" ;;
#part 33
let lookup_weight ~compute_weight alist key =
match
try Some (List.Assoc.find_exn alist key)
with _ -> None
with
| None -> 0.
| Some data -> compute_weight data ;;
#part 34
let lookup_weight ~compute_weight alist key =
match L
gitextract_jkpspzh6/
├── .gitignore
├── INSTALL.sh
├── Makefile
├── README.md
├── UNLICENSE
└── code/
├── Makefile
├── async/
│ ├── #build_other_searches.sh#
│ ├── #main.topscript#
│ ├── better_echo.ml
│ ├── build_echo.sh
│ ├── build_other_searches.sh
│ ├── echo.ml
│ ├── main-35.rawscript
│ ├── main-38.rawscript
│ ├── main-44.rawscript
│ ├── main-45.rawscript
│ ├── main-46.rawscript
│ ├── main-47.rawscript
│ ├── main.topscript
│ ├── native_code_log_delays.ml
│ ├── pipe_write_break.rawscript
│ ├── pipe_write_break.rawtopscript
│ ├── run_echo.rawsh
│ ├── run_native_code_log_delays.rawsh
│ ├── run_native_code_log_delays_orig.sh
│ ├── run_search.rawsh
│ ├── run_search_orig.sh
│ ├── run_search_with_configurable_server.rawsh
│ ├── run_search_with_configurable_server_orig.errsh
│ ├── run_search_with_error_handling.rawsh
│ ├── run_search_with_error_handling_orig.sh
│ ├── run_search_with_timeout_no_leak.rawsh
│ ├── run_search_with_timeout_no_leak_orig.sh
│ ├── run_thread.sh
│ ├── search.ml
│ ├── search_out_of_order.ml
│ ├── search_with_configurable_server.ml
│ ├── search_with_error_handling.ml
│ ├── search_with_error_handling_deprecated.ml
│ ├── search_with_timeout.ml
│ ├── search_with_timeout_choice.ml
│ ├── search_with_timeout_no_leak.ml
│ ├── search_with_timeout_no_leak_simple.ml
│ ├── search_with_timeout_simple.ml
│ ├── test.txt
│ ├── thread_exp_async_busy_loop.ml
│ ├── thread_exp_async_busy_loop_in_thread.ml
│ ├── thread_exp_async_noalloc_busy_loop.ml
│ ├── thread_exp_async_noalloc_busy_loop_in_thread.ml
│ ├── thread_exp_async_only.ml
│ ├── thread_exp_common.ml
│ ├── thread_experiments.ml
│ └── timeout_search.ml
├── back-end/
│ ├── alternate_list.ml
│ ├── asm_from_compare_mono.sh
│ ├── cmp.S
│ ├── compare_mono.ml
│ ├── compare_mono.s
│ ├── compare_poly.ml
│ ├── compare_poly_asm.S
│ ├── gdb_alternate0.rawsh
│ ├── gdb_alternate1.rawsh
│ ├── gdb_alternate2.rawsh
│ ├── gdb_alternate3.rawsh
│ ├── instr_for_pattern_monomorphic_small.sh
│ ├── lambda_for_pattern_monomorphic_large.sh
│ ├── lambda_for_pattern_monomorphic_small.sh
│ ├── lambda_for_pattern_polymorphic.sh
│ ├── opam_switch.rawsh
│ ├── pattern_monomorphic_large.ml
│ ├── pattern_monomorphic_small.ml
│ ├── pattern_polymorphic.ml
│ ├── perf_record.rawsh
│ └── perf_report.rawsh
├── back-end-bench/
│ ├── bench_patterns.ml
│ ├── bench_poly_and_mono.ml
│ ├── run_alternate_list.sh
│ ├── run_bench_patterns.sh
│ └── run_bench_poly_and_mono.sh
├── back-end-embed/
│ ├── build_embed.sh
│ ├── build_embed_binary.rawsh
│ ├── build_embed_c.sh
│ ├── build_embed_native.rawsh
│ ├── embed_me1.ml
│ ├── embed_me2.ml
│ ├── embed_out.c
│ ├── hello.ml
│ ├── link_custom.rawsh
│ ├── link_dllib.rawsh
│ ├── main.c
│ ├── run_debug_hello.sh
│ ├── xbuild_embed_binary.sh
│ └── xbuild_embed_native.sh
├── classes/
│ ├── Iterator.java
│ ├── binary.topscript
│ ├── binary_larger.ml
│ ├── binary_module.ml
│ ├── build_doc.sh
│ ├── citerator.cpp
│ ├── class_types_stack.ml
│ ├── doc.ml
│ ├── initializer.topscript
│ ├── istack.topscript
│ ├── iter.topscript
│ └── stack.topscript
├── classes-async/
│ ├── build_shapes.sh
│ ├── multiple_inheritance.ml
│ ├── multiple_inheritance_wrong.ml
│ ├── shapes.ml
│ └── verbose_shapes.ml
├── command-line-parsing/
│ ├── _tags
│ ├── basic.topscript
│ ├── basic_md5.ml
│ ├── basic_md5_as_filename.ml
│ ├── basic_md5_sequence.ml
│ ├── basic_md5_succinct.ml
│ ├── basic_md5_with_custom_arg.ml
│ ├── basic_md5_with_default_file.ml
│ ├── basic_md5_with_flags.ml
│ ├── basic_md5_with_opt_flags.ml
│ ├── basic_md5_with_optional_file.ml
│ ├── basic_md5_with_optional_file_broken.ml
│ ├── build_and_run_cal_add_interactive.rawsh
│ ├── build_basic_md5.sh
│ ├── build_basic_md5_as_filename.sh
│ ├── build_basic_md5_sequence.sh
│ ├── build_basic_md5_with_custom_arg.sh
│ ├── build_basic_md5_with_default_file.sh
│ ├── build_basic_md5_with_flags.sh
│ ├── build_basic_md5_with_opt_flags.sh
│ ├── build_basic_md5_with_optional_file.sh
│ ├── build_basic_md5_with_optional_file_broken.errsh
│ ├── build_cal_add_days.sh
│ ├── build_cal_add_sub_days.sh
│ ├── build_cal_append.sh
│ ├── build_cal_append_broken.errsh
│ ├── cal.cmd
│ ├── cal_add_days.ml
│ ├── cal_add_interactive.ml
│ ├── cal_add_labels.ml
│ ├── cal_add_sub_days.ml
│ ├── cal_append.ml
│ ├── cal_append_broken.ml
│ ├── cal_completion.rawsh
│ ├── command_types.topscript
│ ├── get_basic_md5_help.errsh
│ ├── get_basic_md5_version.sh
│ ├── group.topscript
│ ├── md5_completion.sh
│ ├── opam.rawsh
│ ├── run_basic_and_default_md5.sh
│ ├── run_basic_md5.sh
│ ├── run_basic_md5_as_filename.errsh
│ ├── run_basic_md5_flags_help.sh
│ ├── run_basic_md5_with_custom_arg.errsh
│ ├── run_cal_add_sub_days.sh
│ ├── single_anon_filename.topscript
│ └── step.topscript
├── corebuild
├── ctypes/
│ ├── ctypes.mli
│ └── ctypes_impl.ml
├── error-handling/
│ ├── blow_up.ml
│ ├── build_blow_up.errsh
│ ├── build_blow_up_notrace.errsh
│ ├── exn_cost.ml
│ ├── main.topscript
│ ├── result.ml
│ ├── result.mli
│ ├── run_exn_cost.sh
│ ├── run_exn_cost_notrace.sh
│ ├── sexpr.scm
│ └── try_with.syntax
├── exec_script.sh
├── exec_topscript.sh
├── fcm/
│ ├── build_query_handler.sh
│ ├── build_query_handler_loader.sh
│ ├── fcm.syntax
│ ├── loader_cli1.rawsh
│ ├── loader_cli2.rawsh
│ ├── loader_cli3.rawsh
│ ├── loader_cli4.rawsh
│ ├── main.topscript
│ ├── pack.syntax
│ ├── query-syntax.scm
│ ├── query_example.rawscript
│ ├── query_handler.ml
│ ├── query_handler.topscript
│ ├── query_handler_core.ml
│ ├── query_handler_loader.ml
│ └── unpack.syntax
├── ffi/
│ ├── build_datetime.sh
│ ├── build_hello.sh
│ ├── build_qsort.sh
│ ├── datetime.ml
│ ├── hello.ml
│ ├── infer_ncurses.sh
│ ├── input.txt
│ ├── install.rawsh
│ ├── ncurses.h
│ ├── ncurses.inferred.mli
│ ├── ncurses.ml
│ ├── ncurses.mli
│ ├── posix.topscript
│ ├── posix_headers.h
│ ├── qsort.h
│ ├── qsort.ml
│ ├── qsort.mli
│ ├── qsort.topscript
│ ├── qsort_typedef.h
│ ├── return_c_frag.c
│ ├── return_c_frag.h
│ ├── return_c_uncurried.c
│ ├── return_frag.ml
│ └── timeval_headers.h
├── files-modules-and-programs/
│ ├── abstract_username.ml
│ ├── build_session_info.errsh
│ ├── common.ml
│ ├── confusing_username_and_host.ml
│ ├── ext_list.ml
│ ├── ext_list.mli
│ ├── freq.ml
│ ├── intro.topscript
│ ├── main.topscript
│ ├── module.syntax
│ ├── session_info.ml
│ └── val.syntax
├── files-modules-and-programs-freq/
│ ├── freq.ml
│ ├── simple_build.sh
│ └── simple_build_fail.errsh
├── files-modules-and-programs-freq-cyclic1/
│ ├── build.errsh
│ ├── counter.ml
│ ├── counter.mli
│ └── freq.ml
├── files-modules-and-programs-freq-cyclic2/
│ ├── build.errsh
│ ├── counter.ml
│ ├── counter.mli
│ └── freq.ml
├── files-modules-and-programs-freq-fast/
│ ├── build.sh
│ ├── counter.ml
│ ├── counter.mli
│ └── freq.ml
├── files-modules-and-programs-freq-median/
│ ├── build.sh
│ ├── build_use_median.sh
│ ├── counter.ml
│ ├── counter.mli
│ ├── freq.ml
│ ├── use_median_1.ml
│ └── use_median_2.ml
├── files-modules-and-programs-freq-obuild/
│ ├── build.sh
│ └── test.sh
├── files-modules-and-programs-freq-with-counter/
│ ├── build.sh
│ ├── counter.ml
│ ├── freq.ml
│ └── infer_mli.sh
├── files-modules-and-programs-freq-with-missing-def/
│ ├── build.errsh
│ ├── counter.ml
│ ├── counter.mli
│ └── freq.ml
├── files-modules-and-programs-freq-with-sig/
│ ├── build.sh
│ ├── counter.ml
│ ├── counter.mli
│ └── freq.ml
├── files-modules-and-programs-freq-with-sig-abstract/
│ ├── build.errsh
│ ├── counter.ml
│ ├── counter.mli
│ └── freq.ml
├── files-modules-and-programs-freq-with-sig-abstract-fixed/
│ ├── build.sh
│ ├── counter.ml
│ ├── counter.mli
│ └── freq.ml
├── files-modules-and-programs-freq-with-sig-mismatch/
│ ├── build.errsh
│ ├── counter.ml
│ ├── counter.mli
│ └── freq.ml
├── files-modules-and-programs-freq-with-type-mismatch/
│ ├── build.errsh
│ ├── counter.ml
│ ├── counter.mli
│ └── freq.ml
├── front-end/
│ ├── alice.ml
│ ├── alice.mli
│ ├── alice_combined.ml
│ ├── broken_module.ml
│ ├── broken_poly.ml
│ ├── broken_poly_with_annot.ml
│ ├── build_broken_module.errsh
│ ├── build_broken_poly.errsh
│ ├── build_broken_poly_with_annot.errsh
│ ├── build_follow_on_function.errsh
│ ├── build_non_principal.sh
│ ├── build_ocamldoc.rawsh
│ ├── build_principal.sh
│ ├── build_type_conv_with_camlp4.rawsh
│ ├── build_type_conv_without_camlp4.errsh
│ ├── camlp4_dump.cmd
│ ├── camlp4_toplevel.topscript
│ ├── comparelib_test.ml
│ ├── comparelib_test.mli
│ ├── conflicting_interfaces.errsh
│ ├── doc.ml
│ ├── fixed_module.ml
│ ├── follow_on_function.ml
│ ├── follow_on_function_fixed.ml
│ ├── html/
│ │ ├── Doc.html
│ │ ├── index.html
│ │ ├── index_attributes.html
│ │ ├── index_class_types.html
│ │ ├── index_classes.html
│ │ ├── index_exceptions.html
│ │ ├── index_methods.html
│ │ ├── index_module_types.html
│ │ ├── index_modules.html
│ │ ├── index_types.html
│ │ ├── index_values.html
│ │ ├── style.css
│ │ └── type_Doc.html
│ ├── inconsistent_compilation_units.rawsh
│ ├── indent_follow_on_function.sh
│ ├── indent_follow_on_function_fixed.sh
│ ├── infer_typedef.sh
│ ├── install_ocp_index.rawsh
│ ├── let_notunit.ml
│ ├── let_unit.syntax
│ ├── man/
│ │ └── man3/
│ │ ├── Doc.3o
│ │ ├── My_exception.3o
│ │ ├── Rain.3o
│ │ ├── Sun.3o
│ │ ├── weather.3o
│ │ └── what_is_the_weather_in.3o
│ ├── non_principal.ml
│ ├── parsetree_typedef.sh
│ ├── pipeline.ascii
│ ├── principal.ml
│ ├── process_comparelib_interface.sh
│ ├── process_comparelib_test.sh
│ ├── short_paths_1.rawsh
│ ├── short_paths_2.rawsh
│ ├── short_paths_3.rawsh
│ ├── test.ml
│ ├── test.mli
│ ├── type_conv_example.ml
│ ├── typedef.ml
│ ├── typedef_objinfo.sh
│ ├── typedtree_typedef.sh
│ ├── unused_var.ml
│ └── xbuild_type_conv_with_camlp4.sh
├── functors/
│ ├── build_extended_fqueue.sh
│ ├── build_fqueue.sh
│ ├── compare_example.ml
│ ├── destructive_sub.syntax
│ ├── extended_fqueue.ml
│ ├── extended_fqueue.mli
│ ├── foldable.ml
│ ├── fqueue.ml
│ ├── fqueue.mli
│ ├── main-15.rawscript
│ ├── main-18.rawscript
│ ├── main-21.rawscript
│ ├── main-25.rawscript
│ ├── main.topscript
│ ├── multi_sharing_constraint.syntax
│ ├── sexpable.ml
│ └── sharing_constraint.syntax
├── gc/
│ ├── barrier_bench.ml
│ ├── finalizer.ml
│ ├── minor_heap.ascii
│ ├── run_barrier_bench.sh
│ ├── run_finalizer.sh
│ ├── show_barrier_bench_help.sh
│ └── tune.topscript
├── guided-tour/
│ ├── build_sum.sh
│ ├── local_let.topscript
│ ├── main.topscript
│ ├── recursion.ml
│ ├── run_sum.sh
│ ├── sum.ml
│ └── sum.rawsh
├── imperative-programming/
│ ├── .gitignore
│ ├── array-get.syntax
│ ├── array-set.syntax
│ ├── bigarray.syntax
│ ├── build_all.sh
│ ├── dictionary.ml
│ ├── dictionary.mli
│ ├── dictionary2.ml
│ ├── dlist.ml
│ ├── dlist.mli
│ ├── edit_distance.ascii
│ ├── edit_distance2.ascii
│ ├── examples.topscript
│ ├── fib.topscript
│ ├── file.topscript
│ ├── file2.topscript
│ ├── for.topscript
│ ├── lazy.topscript
│ ├── let-unit.syntax
│ ├── let_rec.ml
│ ├── letrec.topscript
│ ├── memo.topscript
│ ├── order.topscript
│ ├── printf.topscript
│ ├── ref.topscript
│ ├── remember_type.ml
│ ├── semicolon-syntax.syntax
│ ├── semicolon.syntax
│ ├── string.syntax
│ ├── time_converter.ml
│ ├── time_converter.rawsh
│ ├── time_converter2.ml
│ ├── time_converter2.rawsh
│ ├── value_restriction-13.rawscript
│ ├── value_restriction.topscript
│ └── weak.topscript
├── installation/
│ ├── arch_install.rawsh
│ ├── arch_opam.rawsh
│ ├── brew_install.rawsh
│ ├── brew_opam_install.rawsh
│ ├── debian_apt.rawsh
│ ├── debian_apt_opam.rawsh
│ ├── emacsrc.scm
│ ├── fedora_install.rawsh
│ ├── macports_install.rawsh
│ ├── macports_opam_install.rawsh
│ ├── ocaml_src_install.rawsh
│ ├── ocaml_user_conf.rawsh
│ ├── opam_eval.rawsh
│ ├── opam_init.rawsh
│ ├── opam_install.rawsh
│ ├── opam_install_utop.rawsh
│ ├── opam_list.rawsh
│ ├── opam_switch.rawsh
│ ├── open_core.ml
│ ├── show_ocamlinit.rawsh
│ └── ubuntu_opam_ppa.rawsh
├── json/
│ ├── _tags
│ ├── book.json
│ ├── build_github_atd.sh
│ ├── build_github_org.sh
│ ├── build_json.topscript
│ ├── generate_github_org_json.sh
│ ├── generate_github_org_types.sh
│ ├── github.atd
│ ├── github_j.ml
│ ├── github_j.mli
│ ├── github_j_excerpt.mli
│ ├── github_org.atd
│ ├── github_org_info.ml
│ ├── github_org_j.ml
│ ├── github_org_j.mli
│ ├── github_org_t.ml
│ ├── github_org_t.mli
│ ├── github_t.ml
│ ├── github_t.mli
│ ├── install.topscript
│ ├── install_atdgen.rawsh
│ ├── list_excerpt.mli
│ ├── parse_book.ml
│ ├── parse_book.topscript
│ ├── read_json.ml
│ ├── run_github_org.sh
│ ├── run_parse_book.sh
│ ├── run_read_json.sh
│ ├── yojson_basic.mli
│ ├── yojson_basic_simple.mli
│ └── yojson_safe.mli
├── lists-and-patterns/
│ ├── example.ml
│ ├── example.mli
│ ├── lists_layout.ascii
│ └── main.topscript
├── maps-and-hash-tables/
│ ├── comparable.ml
│ ├── core_phys_equal.topscript
│ ├── main-22.rawscript
│ ├── main-23.rawscript
│ ├── main-24.rawscript
│ ├── main-30.rawscript
│ ├── main.topscript
│ ├── map_vs_hash.ml
│ ├── map_vs_hash2.ml
│ ├── phys_equal.rawscript
│ ├── run_map_vs_hash.sh
│ └── run_map_vs_hash2.sh
├── memory-repr/
│ ├── block.ascii
│ ├── custom_ops.c
│ ├── float_array_layout.ascii
│ ├── reprs.topscript
│ ├── simple_record.topscript
│ ├── string_block.ascii
│ ├── string_size_calc.ascii
│ └── tuple_layout.ascii
├── objects/
│ ├── IsBarbell.java
│ ├── Shape.java
│ ├── immutable.topscript
│ ├── is_barbell.ml
│ ├── narrowing.ml
│ ├── polymorphism.topscript
│ ├── row_polymorphism.topscript
│ ├── stack.topscript
│ ├── subtyping.ml
│ └── subtyping.topscript
├── ocp-index/
│ └── index_ncurses.sh
├── packing/
│ ├── A.ml
│ ├── B.ml
│ ├── X.mlpack
│ ├── _tags
│ ├── build_test.sh
│ ├── show_files.sh
│ └── test.ml
├── parsing/
│ ├── basic_parser.mly
│ ├── build_short_parser.sh
│ ├── example.json
│ ├── json.ml
│ ├── lex.syntax
│ ├── lexer.mll
│ ├── lexer_int_fragment.mll
│ ├── manual_token_type.ml
│ ├── parsed_example.ml
│ ├── parser.mly
│ ├── production.syntax
│ ├── prog.mli
│ ├── quadratic_rule.mly
│ ├── right_rec_rule.mly
│ ├── short_parser.mly
│ ├── tokenized_example.ml
│ ├── tokens.ml
│ └── yacc.syntax
├── parsing-test/
│ ├── build_json_parser.sh
│ ├── build_test.sh
│ ├── run_broken_test.errsh
│ ├── test.ml
│ ├── test1.json
│ └── test2.json
├── principal/
│ └── build_principal.sh
├── records/
│ ├── functional_update.syntax
│ ├── main-29.rawscript
│ ├── main.topscript
│ ├── record.syntax
│ └── warn_help.sh
├── sexpr/
│ ├── auto_making_sexp.topscript
│ ├── basic.scm
│ ├── build_read_foo.errsh
│ ├── build_read_foo_better_errors.errsh
│ ├── build_test_interval.sh
│ ├── build_test_interval_manual_sexp.sh
│ ├── build_test_interval_nosexp.errsh
│ ├── comment_heavy.scm
│ ├── example.scm
│ ├── example_broken.scm
│ ├── example_load.topscript
│ ├── foo_broken_example.scm
│ ├── inline_sexp.topscript
│ ├── int_interval.ml
│ ├── int_interval.mli
│ ├── int_interval_manual_sexp.ml
│ ├── int_interval_manual_sexp.mli
│ ├── int_interval_nosexp.ml
│ ├── int_interval_nosexp.mli
│ ├── list_top_packages.sh
│ ├── manually_making_sexp.topscript
│ ├── print_sexp.topscript
│ ├── read_foo.ml
│ ├── read_foo_better_errors.ml
│ ├── sexp.mli
│ ├── sexp_default.topscript
│ ├── sexp_list.topscript
│ ├── sexp_opaque.topscript
│ ├── sexp_option.topscript
│ ├── sexp_override.ml
│ ├── sexp_printer.topscript
│ ├── test_interval.ml
│ ├── test_interval_manual_sexp.ml
│ ├── test_interval_nosexp.ml
│ └── to_from_sexp.topscript
├── variables-and-functions/
│ ├── abs_diff.mli
│ ├── htable_sig1.ml
│ ├── htable_sig2.ml
│ ├── let.syntax
│ ├── let_in.syntax
│ ├── main.topscript
│ ├── numerical_deriv_alt_sig.mli
│ ├── operators.syntax
│ ├── substring_sig1.ml
│ └── substring_sig2.ml
├── variants/
│ ├── blang.topscript
│ ├── catch_all.topscript
│ ├── logger.topscript
│ ├── main-2.rawscript
│ ├── main-5.rawscript
│ ├── main.topscript
│ └── variant.syntax
├── variants-termcol/
│ ├── build.sh
│ ├── terminal_color.ml
│ └── terminal_color.mli
├── variants-termcol-annotated/
│ ├── build.errsh
│ ├── terminal_color.ml
│ └── terminal_color.mli
└── variants-termcol-fixed/
├── build.sh
├── terminal_color.ml
└── terminal_color.mli
SYMBOL INDEX (12 symbols across 8 files)
FILE: code/back-end-embed/embed_out.c
type value (line 1098) | typedef value (*primitive)();
function caml_startup (line 1670) | void caml_startup(char ** argv)
FILE: code/back-end-embed/main.c
function main (line 7) | int
FILE: code/classes/citerator.cpp
class Iterator (line 3) | class Iterator {
FILE: code/ffi/ncurses.h
type WINDOW (line 1) | typedef struct _win_st WINDOW;
type chtype (line 2) | typedef unsigned int chtype;
FILE: code/ffi/timeval_headers.h
type timeval (line 1) | struct timeval {
type timeval (line 6) | struct timeval
type timezone (line 6) | struct timezone
FILE: code/memory-repr/custom_ops.c
type custom_operations (line 1) | struct custom_operations {
FILE: code/objects/IsBarbell.java
method IsBarbell (line 1) | boolean IsBarbell(Shape[] s) {
FILE: code/objects/Shape.java
method GetShapeName (line 1) | String GetShapeName(Shape s) {
Condensed preview — 597 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (480K chars).
[
{
"path": ".gitignore",
"chars": 243,
"preview": "*.out\n*.out.full\n*.a\na.out\n.*.swp\n*.aux\n*.aux\n*.byte\n*.cmo\n*.cmi\n*.cmx\n*.cmxa\n*.cma\n*.idx\n*.log\n*.native\n*.byte\n*.o\n*.om"
},
{
"path": "INSTALL.sh",
"chars": 326,
"preview": "#!/bin/sh\n\nopam install -j 4 --yes \\\n core \\\n core_extended \\\n cryptokit \\\n core_bench \\\n atdgen \\\n async \\\n yojs"
},
{
"path": "Makefile",
"chars": 193,
"preview": ".PHONY: all depend clean distclean\n\nall:\n\tcd code && $(MAKE) -j1\n\ndepend:\n\t./INSTALL.sh\n\nclean:\n\trm -rf scripts/_build\n\t"
},
{
"path": "README.md",
"chars": 134,
"preview": "This repository contains all the code samples from Real World OCaml. The\nrepository tags represent a particular release"
},
{
"path": "UNLICENSE",
"chars": 1211,
"preview": "This is free and unencumbered software released into the public domain.\n\nAnyone is free to copy, modify, publish, use, c"
},
{
"path": "code/Makefile",
"chars": 6786,
"preview": "#OCAMLPARAM=_,we=+A\n#export OCAMLPARAM\n\ndirs= json \\\n command-line-parsing guided-tour \\\n variables-and-functi"
},
{
"path": "code/async/#build_other_searches.sh#",
"chars": 72,
"preview": "corebuild -pkg cohttp.async,yojson,textwrap search_out_of_order.native\n\n"
},
{
"path": "code/async/#main.topscript#",
"chars": 5733,
"preview": "let x = 3;;\n#part 1\nIn_channel.read_all;;\nOut_channel.write_all \"test.txt\" ~data:\"This is only a test.\";;\nIn_channel.rea"
},
{
"path": "code/async/better_echo.ml",
"chars": 773,
"preview": "open Core.Std\nopen Async.Std\n\nlet run ~uppercase ~port =\n let host_and_port =\n Tcp.Server.create\n ~on_handler_e"
},
{
"path": "code/async/build_echo.sh",
"chars": 73,
"preview": "corebuild -pkg async echo.native\ncorebuild -pkg async better_echo.native\n"
},
{
"path": "code/async/build_other_searches.sh",
"chars": 72,
"preview": "corebuild -pkg cohttp.async,yojson,textwrap search_out_of_order.native\n\n"
},
{
"path": "code/async/echo.ml",
"chars": 901,
"preview": "open Core.Std\nopen Async.Std\n\n(* Copy data from the reader to the writer, using the provided buffer\n as scratch space "
},
{
"path": "code/async/main-35.rawscript",
"chars": 354,
"preview": "# let swallow_error () =\n let monitor = Monitor.create () in\n Stream.iter (Monitor.errors monitor) ~f:(fun _exn ->"
},
{
"path": "code/async/main-38.rawscript",
"chars": 47,
"preview": "# swallow_some_errors Ignore_me;;\nignoring exn\n"
},
{
"path": "code/async/main-44.rawscript",
"chars": 123,
"preview": "# log_delays (fun () -> after (sec 0.5));;\n0.154972ms, 102.126ms, 203.658ms, 305.73ms, 407.903ms, 501.563ms,\n- : unit = "
},
{
"path": "code/async/main-45.rawscript",
"chars": 206,
"preview": "# let busy_loop n =\n let x = ref None in\n for i = 1 to 100_000_000 do x := Some i done\n ;;\nval busy_loop : 'a -> "
},
{
"path": "code/async/main-46.rawscript",
"chars": 97,
"preview": "# log_delays (fun () -> In_thread.run busy_loop);;\n0.332117ms, 16.6319s, 18.8722s,\n- : unit = ()\n"
},
{
"path": "code/async/main-47.rawscript",
"chars": 252,
"preview": "# let noalloc_busy_loop () =\n for i = 0 to 100_000_000 do () done\n;;\nval noalloc_busy_loop : unit -> unit = <fun>\n# l"
},
{
"path": "code/async/main.topscript",
"chars": 5668,
"preview": "let x = 3;;\n#part 1\nIn_channel.read_all;;\nOut_channel.write_all \"test.txt\" ~data:\"This is only a test.\";;\nIn_channel.rea"
},
{
"path": "code/async/native_code_log_delays.ml",
"chars": 561,
"preview": "open Core.Std\nopen Async.Std\n\nlet log_delays thunk =\n let start = Time.now () in\n let print_time () =\n let diff = T"
},
{
"path": "code/async/pipe_write_break.rawscript",
"chars": 45,
"preview": "# Pipe.write w \"Hello World!\";;\nInterrupted.\n"
},
{
"path": "code/async/pipe_write_break.rawtopscript",
"chars": 45,
"preview": "# Pipe.write w \"Hello World!\";;\nInterrupted.\n"
},
{
"path": "code/async/run_echo.rawsh",
"chars": 142,
"preview": "$ ./echo.native &\n$ nc 127.0.0.1 8765\nThis is an echo server\nThis is an echo server\nIt repeats whatever I write.\nIt repe"
},
{
"path": "code/async/run_native_code_log_delays.rawsh",
"chars": 101,
"preview": "$ corebuild -pkg async native_code_log_delays.native\n$ ./native_code_log_delays.native\n15.5686s, \n$ \n"
},
{
"path": "code/async/run_native_code_log_delays_orig.sh",
"chars": 84,
"preview": "corebuild -pkg async native_code_log_delays.native\n./native_code_log_delays.native\n\n"
},
{
"path": "code/async/run_search.rawsh",
"chars": 534,
"preview": "$ corebuild -pkg cohttp.async,yojson,textwrap search.native\n$ ./search.native \"Concurrent Programming\" \"OCaml\"\nConcurren"
},
{
"path": "code/async/run_search_orig.sh",
"chars": 107,
"preview": "corebuild -pkg cohttp.async,yojson,textwrap search.native\n./search.native \"Concurrent Programming\" \"OCaml\"\n"
},
{
"path": "code/async/run_search_with_configurable_server.rawsh",
"chars": 935,
"preview": "$ corebuild -pkg cohttp.async,yojson,textwrap \\\n search_with_configurable_server.native\n$ ./search_with_configurable_"
},
{
"path": "code/async/run_search_with_configurable_server_orig.errsh",
"chars": 193,
"preview": "corebuild -pkg cohttp.async,yojson,textwrap search_with_configurable_server.native\n./search_with_configurable_server.nat"
},
{
"path": "code/async/run_search_with_error_handling.rawsh",
"chars": 507,
"preview": "$ corebuild -pkg cohttp.async,yojson,textwrap \\\n search_with_error_handling.native\n$ ./search_with_error_handling.nat"
},
{
"path": "code/async/run_search_with_error_handling_orig.sh",
"chars": 183,
"preview": "corebuild -pkg cohttp.async,yojson,textwrap search_with_error_handling.native\n./search_with_error_handling.native -serve"
},
{
"path": "code/async/run_search_with_timeout_no_leak.rawsh",
"chars": 453,
"preview": "$ corebuild -pkg cohttp.async,yojson,textwrap \\\n search_with_timeout_no_leak.native\n$ ./search_with_timeout_no_leak."
},
{
"path": "code/async/run_search_with_timeout_no_leak_orig.sh",
"chars": 161,
"preview": "corebuild -pkg cohttp.async,yojson,textwrap search_with_timeout_no_leak.native\n./search_with_timeout_no_leak.native \"con"
},
{
"path": "code/async/run_thread.sh",
"chars": 81,
"preview": "corebuild -pkg async thread_exp_async_only.native\n./thread_exp_async_only.native\n"
},
{
"path": "code/async/search.ml",
"chars": 1821,
"preview": "open Core.Std\nopen Async.Std\n\n(* Generate a DuckDuckGo search URI from a query string *)\nlet query_uri query =\n let bas"
},
{
"path": "code/async/search_out_of_order.ml",
"chars": 1717,
"preview": "open Core.Std\nopen Async.Std\n\n(* Generate a DuckDuckGo search URI from a query string *)\nlet query_uri =\n let base_uri "
},
{
"path": "code/async/search_with_configurable_server.ml",
"chars": 2160,
"preview": "open Core.Std\nopen Async.Std\n\n(* part 1 *)\n(* Generate a DuckDuckGo search URI from a query string *)\nlet query_uri ~ser"
},
{
"path": "code/async/search_with_error_handling.ml",
"chars": 2411,
"preview": "open Core.Std\nopen Async.Std\n\n(* Generate a DuckDuckGo search URI from a query string *)\nlet query_uri ~server query =\n "
},
{
"path": "code/async/search_with_error_handling_deprecated.ml",
"chars": 2126,
"preview": "open Core.Std\nopen Async.Std\n\n(* Generate a DuckDuckGo search URI from a query string *)\nlet query_uri ~server query =\n "
},
{
"path": "code/async/search_with_timeout.ml",
"chars": 2904,
"preview": "open Core.Std\nopen Async.Std\n\n(* Generate a DuckDuckGo search URI from a query string *)\nlet query_uri ~server query =\n "
},
{
"path": "code/async/search_with_timeout_choice.ml",
"chars": 3042,
"preview": "open Core.Std\nopen Async.Std\n\n(* Generate a DuckDuckGo search URI from a query string *)\nlet query_uri ~server query =\n "
},
{
"path": "code/async/search_with_timeout_no_leak.ml",
"chars": 3100,
"preview": "open Core.Std\nopen Async.Std\n\n(* Generate a DuckDuckGo search URI from a query string *)\nlet query_uri ~server query =\n "
},
{
"path": "code/async/search_with_timeout_no_leak_simple.ml",
"chars": 2846,
"preview": "open Core.Std\nopen Async.Std\n\n(* Generate a DuckDuckGo search URI from a query string *)\nlet query_uri ~server query =\n "
},
{
"path": "code/async/search_with_timeout_simple.ml",
"chars": 2700,
"preview": "open Core.Std\nopen Async.Std\n\n(* Generate a DuckDuckGo search URI from a query string *)\nlet query_uri ~server query =\n "
},
{
"path": "code/async/test.txt",
"chars": 20,
"preview": "This is only a test."
},
{
"path": "code/async/thread_exp_async_busy_loop.ml",
"chars": 264,
"preview": "open Core.Std\nopen Async.Std\nopen Thread_exp_common\n\n\n(* part 1 *)\nlet busy_loop n =\n let x = ref None in\n for i = 1 t"
},
{
"path": "code/async/thread_exp_async_busy_loop_in_thread.ml",
"chars": 260,
"preview": "open Core.Std\nopen Async.Std\nopen Thread_exp_common\n\n\n(* part 1 *)\nlet busy_loop n =\n let x = ref None in\n for i = 1 t"
},
{
"path": "code/async/thread_exp_async_noalloc_busy_loop.ml",
"chars": 230,
"preview": "open Core.Std\nopen Async.Std\nopen Thread_exp_common\n\n\n(* part 1 *)\nlet busy_loop () =\n for i = 1 to 200_000_000 do () d"
},
{
"path": "code/async/thread_exp_async_noalloc_busy_loop_in_thread.ml",
"chars": 230,
"preview": "open Core.Std\nopen Async.Std\nopen Thread_exp_common\n\n\n(* part 1 *)\nlet busy_loop () =\n for i = 1 to 200_000_000 do () d"
},
{
"path": "code/async/thread_exp_async_only.ml",
"chars": 226,
"preview": "open Core.Std\nopen Async.Std\nopen Thread_exp_common\n\nlet () =\n Command.async_basic\n ~summary:\"run logger without bus"
},
{
"path": "code/async/thread_exp_common.ml",
"chars": 538,
"preview": "open Core.Std\nopen Async.Std\n\nlet log_delays d =\n let start = Time.now () in\n let rec loop stamps =\n let dela"
},
{
"path": "code/async/thread_experiments.ml",
"chars": 1528,
"preview": "open Core.Std\nopen Async.Std\n\nlet log_delays thunk =\n let start = Time.now () in\n let print_time () =\n let diff = T"
},
{
"path": "code/async/timeout_search.ml",
"chars": 2150,
"preview": "open Core.Std\nopen Async.Std\nmodule Cohttp = Cohttp_async\n\n(* Generate a DuckDuckGo search URI from a query string *)\nle"
},
{
"path": "code/back-end/alternate_list.ml",
"chars": 251,
"preview": "open Core.Std\n\nlet rec take =\n function\n |[] -> []\n |hd::tl -> hd :: (skip tl)\nand skip =\n function\n |[] -> []\n |_"
},
{
"path": "code/back-end/asm_from_compare_mono.sh",
"chars": 50,
"preview": "ocamlopt -inline 20 -nodynlink -S compare_mono.ml\n"
},
{
"path": "code/back-end/cmp.S",
"chars": 205,
"preview": "_camlCompare_mono__cmp_1008:\n .cfi_startproc\n.L101:\n cmpq %rbx, %rax\n jle .L100\n ret\n"
},
{
"path": "code/back-end/compare_mono.ml",
"chars": 51,
"preview": "let cmp (a:int) (b:int) =\n if a > b then a else b\n"
},
{
"path": "code/back-end/compare_mono.s",
"chars": 978,
"preview": "\t.data\n\t.globl\t_camlCompare_mono__data_begin\n_camlCompare_mono__data_begin:\n\t.text\n\t.globl\t_camlCompare_mono__code_begin"
},
{
"path": "code/back-end/compare_poly.ml",
"chars": 39,
"preview": "let cmp a b =\n if a > b then a else b\n"
},
{
"path": "code/back-end/compare_poly_asm.S",
"chars": 760,
"preview": "_camlCompare_poly__cmp_1008:\n .cfi_startproc\n subq $24, %rsp\n .cfi_adjust_cfa_offset 24\n.L101:\n"
},
{
"path": "code/back-end/gdb_alternate0.rawsh",
"chars": 562,
"preview": "$ gdb ./alternate_list.native\nGNU gdb (GDB) 7.4.1-debian\nCopyright (C) 2012 Free Software Foundation, Inc.\nLicense GPLv3"
},
{
"path": "code/back-end/gdb_alternate1.rawsh",
"chars": 102,
"preview": "(gdb) break camlAlternate_list__take_69242 \nBreakpoint 1 at 0x5658d0: file alternate_list.ml, line 5.\n"
},
{
"path": "code/back-end/gdb_alternate2.rawsh",
"chars": 273,
"preview": "(gdb) run\nStarting program: /home/avsm/alternate_list.native\n[Thread debugging using libthread_db enabled]\nUsing host li"
},
{
"path": "code/back-end/gdb_alternate3.rawsh",
"chars": 839,
"preview": "(gdb) cont\nContinuing.\n\nBreakpoint 1, camlAlternate_list__take_69242 () at alternate_list.ml:5\n4 function\n(gdb) "
},
{
"path": "code/back-end/instr_for_pattern_monomorphic_small.sh",
"chars": 49,
"preview": "ocamlc -dinstr pattern_monomorphic_small.ml 2>&1\n"
},
{
"path": "code/back-end/lambda_for_pattern_monomorphic_large.sh",
"chars": 53,
"preview": "ocamlc -dlambda -c pattern_monomorphic_large.ml 2>&1\n"
},
{
"path": "code/back-end/lambda_for_pattern_monomorphic_small.sh",
"chars": 53,
"preview": "ocamlc -dlambda -c pattern_monomorphic_small.ml 2>&1\n"
},
{
"path": "code/back-end/lambda_for_pattern_polymorphic.sh",
"chars": 47,
"preview": "ocamlc -dlambda -c pattern_polymorphic.ml 2>&1\n"
},
{
"path": "code/back-end/opam_switch.rawsh",
"chars": 27,
"preview": "$ opam switch 4.01.0dev+fp\n"
},
{
"path": "code/back-end/pattern_monomorphic_large.ml",
"chars": 146,
"preview": "type t = | Alice | Bob | Charlie | David\n\nlet test v =\n match v with\n | Alice -> 100\n | Bob -> 101\n | Charlie "
},
{
"path": "code/back-end/pattern_monomorphic_small.ml",
"chars": 91,
"preview": "type t = | Alice | Bob \n\nlet test v =\n match v with\n | Alice -> 100\n | Bob -> 101\n"
},
{
"path": "code/back-end/pattern_polymorphic.ml",
"chars": 128,
"preview": "let test v =\n match v with\n | `Alice -> 100\n | `Bob -> 101\n | `Charlie -> 102\n | `David -> 103\n | `Eve "
},
{
"path": "code/back-end/perf_record.rawsh",
"chars": 902,
"preview": "$ perf record -g ./barrier_bench.native\nEstimated testing time 20s (change using -quota SECS).\n\n Name Time (ns) "
},
{
"path": "code/back-end/perf_report.rawsh",
"chars": 236,
"preview": "$ perf report -g\n+ 48.86% barrier.native barrier.native [.] camlBarrier__test_immutable_69282\n+ 30.22% barrier.nat"
},
{
"path": "code/back-end-bench/bench_patterns.ml",
"chars": 1055,
"preview": "open Core.Std\nopen Core_bench.Std\n\ntype t = | Alice | Bob \ntype s = | A | B | C | D | E\n\nlet polymorphic_pattern () =\n "
},
{
"path": "code/back-end-bench/bench_poly_and_mono.ml",
"chars": 531,
"preview": "open Core.Std\nopen Core_bench.Std\n\nlet polymorphic_compare () =\n let cmp a b = if a > b then a else b in\n for i = 0 to"
},
{
"path": "code/back-end-bench/run_alternate_list.sh",
"chars": 74,
"preview": "corebuild -tag debug alternate_list.native\n./alternate_list.native -ascii\n"
},
{
"path": "code/back-end-bench/run_bench_patterns.sh",
"chars": 79,
"preview": "corebuild -pkg core_bench bench_patterns.native\n./bench_patterns.native -ascii\n"
},
{
"path": "code/back-end-bench/run_bench_poly_and_mono.sh",
"chars": 89,
"preview": "corebuild -pkg core_bench bench_poly_and_mono.native\n./bench_poly_and_mono.native -ascii\n"
},
{
"path": "code/back-end-embed/build_embed.sh",
"chars": 78,
"preview": "rm -f embed_out.c\nocamlc -output-obj -o embed_out.o embed_me1.ml embed_me2.ml\n"
},
{
"path": "code/back-end-embed/build_embed_binary.rawsh",
"chars": 230,
"preview": "$ gcc -fPIC -Wall -I`ocamlc -where` -L`ocamlc -where` -ltermcap -lm -ldl \\\n -o finalbc.native main.c embed_out.o -lcaml"
},
{
"path": "code/back-end-embed/build_embed_c.sh",
"chars": 60,
"preview": "ocamlc -output-obj -o embed_out.c embed_me1.ml embed_me2.ml\n"
},
{
"path": "code/back-end-embed/build_embed_native.rawsh",
"chars": 292,
"preview": "$ ocamlopt -output-obj -o embed_native.o embed_me1.ml embed_me2.ml\n$ gcc -Wall -I `ocamlc -where` -o final.native embed_"
},
{
"path": "code/back-end-embed/embed_me1.ml",
"chars": 48,
"preview": "let () = print_endline \"hello embedded world 1\"\n"
},
{
"path": "code/back-end-embed/embed_me2.ml",
"chars": 48,
"preview": "let () = print_endline \"hello embedded world 2\"\n"
},
{
"path": "code/back-end-embed/embed_out.c",
"chars": 72663,
"preview": "#ifdef __cplusplus\nextern \"C\" {\n#endif\n#include <caml/mlvalues.h>\nCAMLextern void caml_startup_code(\n code_t c"
},
{
"path": "code/back-end-embed/hello.ml",
"chars": 44,
"preview": "let () = print_endline \"Hello OCaml World!\"\n"
},
{
"path": "code/back-end-embed/link_custom.rawsh",
"chars": 60,
"preview": "$ ocamlc -a -o mylib.cma -custom a.cmo b.cmo -cclib -lmylib\n"
},
{
"path": "code/back-end-embed/link_dllib.rawsh",
"chars": 52,
"preview": "$ ocamlc -a -o mylib.cma a.cmo b.cmo -dllib -lmylib\n"
},
{
"path": "code/back-end-embed/main.c",
"chars": 285,
"preview": "#include <stdio.h>\n#include <caml/alloc.h>\n#include <caml/mlvalues.h>\n#include <caml/memory.h>\n#include <caml/callback.h"
},
{
"path": "code/back-end-embed/run_debug_hello.sh",
"chars": 77,
"preview": "ocamlopt -runtime-variant d -verbose -o hello.native hello.ml\n./hello.native\n"
},
{
"path": "code/back-end-embed/xbuild_embed_binary.sh",
"chars": 135,
"preview": "gcc -fPIC -Wall -I`ocamlc -where` -L`ocamlc -where` -ltermcap -lm -ldl -o finalbc.native main.c embed_out.o -lcamlrun\n./"
},
{
"path": "code/back-end-embed/xbuild_embed_native.sh",
"chars": 194,
"preview": "ocamlopt -output-obj -o embed_native.o embed_me1.ml embed_me2.ml\ngcc -Wall -I `ocamlc -where` -o final.native embed_nati"
},
{
"path": "code/classes/Iterator.java",
"chars": 127,
"preview": "// Java-style iterator, specified as an interface.\ninterface <T> iterator {\n T Get();\n boolean HasValue();\n void Next"
},
{
"path": "code/classes/binary.topscript",
"chars": 988,
"preview": "class square w = object(self : 'self) \n method width = w\n method area = Float.of_int (self#width * self#width)\n "
},
{
"path": "code/classes/binary_larger.ml",
"chars": 156,
"preview": "class square w = object(self) \n method width = w\n method area = Float.of_int (self#width * self#width)\n method larger"
},
{
"path": "code/classes/binary_module.ml",
"chars": 360,
"preview": "module Shapes : sig\n type shape_repr\n type shape =\n < repr : shape_repr; equals : shape -> bool; area: float >\n\n c"
},
{
"path": "code/classes/build_doc.sh",
"chars": 21,
"preview": "corebuild doc.native\n"
},
{
"path": "code/classes/citerator.cpp",
"chars": 206,
"preview": "// Abstract class definition in C++.\ntemplate<typename T>\nclass Iterator {\n public:\n virtual ~Iterator() {}\n virtual T"
},
{
"path": "code/classes/class_types_stack.ml",
"chars": 520,
"preview": "module Stack = struct\n class ['a] stack init = object\n ... \n end\n\n type 'a t = 'a stack\n\n let make init = new "
},
{
"path": "code/classes/doc.ml",
"chars": 2815,
"preview": "type doc =\n | Heading of string\n | Paragraph of text_item list\n | Definition of string list_item list\n\nand text_item "
},
{
"path": "code/classes/initializer.topscript",
"chars": 155,
"preview": "class obj x = \n let () = printf \"Creating obj %d\\n\" x in\n object \n val field = printf \"Initializing field\\n\";"
},
{
"path": "code/classes/istack.topscript",
"chars": 360,
"preview": "class istack = object\n val mutable v = [0; 2]\n\n method pop =\n match v with\n | hd :: tl ->\n v <-"
},
{
"path": "code/classes/iter.topscript",
"chars": 1485,
"preview": "type 'a iterator = < get : 'a; has_value : bool; next : unit > ;;\n#part 1\nclass ['a] list_iterator init = object\n val"
},
{
"path": "code/classes/stack.topscript",
"chars": 739,
"preview": "class ['a] stack init = object\n val mutable v : 'a list = init\n\n method pop =\n match v with\n | hd :: tl "
},
{
"path": "code/classes-async/build_shapes.sh",
"chars": 44,
"preview": "corebuild -pkg async_graphics shapes.native\n"
},
{
"path": "code/classes-async/multiple_inheritance.ml",
"chars": 946,
"preview": "open Core.Std\nopen Async.Std\nopen Async_graphics\n\nclass virtual shape x y = object(self)\n method virtual private contai"
},
{
"path": "code/classes-async/multiple_inheritance_wrong.ml",
"chars": 938,
"preview": "open Core.Std\nopen Async.Std\nopen Async_graphics\n\nclass virtual shape x y = object(self)\n method virtual private contai"
},
{
"path": "code/classes-async/shapes.ml",
"chars": 4697,
"preview": "open Core.Std\nopen Async.Std\nopen Async_graphics\n\ntype drawable = < draw: unit >\n\n(* part 1 *)\nclass virtual shape x y ="
},
{
"path": "code/classes-async/verbose_shapes.ml",
"chars": 1126,
"preview": "open Core.Std\nopen Async.Std\nopen Async_graphics\n\n(* part 1 *)\nclass square w x y = object(self)\n val mutable x: int = "
},
{
"path": "code/command-line-parsing/_tags",
"chars": 18,
"preview": "true: short_paths\n"
},
{
"path": "code/command-line-parsing/basic.topscript",
"chars": 17,
"preview": "Command.basic ;;\n"
},
{
"path": "code/command-line-parsing/basic_md5.ml",
"chars": 574,
"preview": "open Core.Std\n\nlet do_hash file =\n In_channel.with_file file ~f:(fun ic ->\n let open Cryptokit in\n hash_channel ("
},
{
"path": "code/command-line-parsing/basic_md5_as_filename.ml",
"chars": 499,
"preview": "open Core.Std\n\nlet do_hash file () =\n In_channel.with_file file ~f:(\n fun ic ->\n let open Cryptokit in\n ha"
},
{
"path": "code/command-line-parsing/basic_md5_sequence.ml",
"chars": 674,
"preview": "open Core.Std\n\nlet do_hash filename ic =\n let open Cryptokit in\n hash_channel (Hash.md5 ()) ic\n |> transform_string ("
},
{
"path": "code/command-line-parsing/basic_md5_succinct.ml",
"chars": 475,
"preview": "open Core.Std\n\nlet do_hash file () =\n In_channel.with_file file ~f:(fun ic ->\n let open Cryptokit in\n hash_channe"
},
{
"path": "code/command-line-parsing/basic_md5_with_custom_arg.ml",
"chars": 728,
"preview": "open Core.Std\n\nlet do_hash file () =\n In_channel.with_file file ~f:(fun ic ->\n let open Cryptokit in\n hash_channe"
},
{
"path": "code/command-line-parsing/basic_md5_with_default_file.ml",
"chars": 604,
"preview": "open Core.Std\n\nlet get_inchan = function\n | \"-\" -> In_channel.stdin\n | filename -> In_channel.create ~binary:true"
},
{
"path": "code/command-line-parsing/basic_md5_with_flags.ml",
"chars": 1031,
"preview": "open Core.Std\nopen Cryptokit\n\nlet checksum_from_string buf =\n hash_string (Hash.md5 ()) buf\n |> transform_string (Hexa"
},
{
"path": "code/command-line-parsing/basic_md5_with_opt_flags.ml",
"chars": 1369,
"preview": "open Core.Std\nopen Cryptokit\n\nlet checksum_from_string buf =\n hash_string (Hash.md5 ()) buf\n |> transform_string (Hexa"
},
{
"path": "code/command-line-parsing/basic_md5_with_optional_file.ml",
"chars": 589,
"preview": "open Core.Std\n\nlet get_inchan = function\n | None | Some \"-\" ->\n In_channel.stdin\n | Some filename ->\n In_channel"
},
{
"path": "code/command-line-parsing/basic_md5_with_optional_file_broken.ml",
"chars": 509,
"preview": "open Core.Std\n\nlet do_hash file () =\n In_channel.with_file file ~f:(\n fun ic ->\n let open Cryptokit in\n ha"
},
{
"path": "code/command-line-parsing/build_and_run_cal_add_interactive.rawsh",
"chars": 145,
"preview": "$ ocamlbuild -use-ocamlfind -tag thread -pkg core cal_add_interactive.native\n$ ./cal_add_interactive.native 2013-12-01\ne"
},
{
"path": "code/command-line-parsing/build_basic_md5.sh",
"chars": 42,
"preview": "corebuild -pkg cryptokit basic_md5.native\n"
},
{
"path": "code/command-line-parsing/build_basic_md5_as_filename.sh",
"chars": 54,
"preview": "corebuild -pkg cryptokit basic_md5_as_filename.native\n"
},
{
"path": "code/command-line-parsing/build_basic_md5_sequence.sh",
"chars": 51,
"preview": "corebuild -pkg cryptokit basic_md5_sequence.native\n"
},
{
"path": "code/command-line-parsing/build_basic_md5_with_custom_arg.sh",
"chars": 58,
"preview": "corebuild -pkg cryptokit basic_md5_with_custom_arg.native\n"
},
{
"path": "code/command-line-parsing/build_basic_md5_with_default_file.sh",
"chars": 60,
"preview": "corebuild -pkg cryptokit basic_md5_with_default_file.native\n"
},
{
"path": "code/command-line-parsing/build_basic_md5_with_flags.sh",
"chars": 53,
"preview": "corebuild -pkg cryptokit basic_md5_with_flags.native\n"
},
{
"path": "code/command-line-parsing/build_basic_md5_with_opt_flags.sh",
"chars": 57,
"preview": "corebuild -pkg cryptokit basic_md5_with_opt_flags.native\n"
},
{
"path": "code/command-line-parsing/build_basic_md5_with_optional_file.sh",
"chars": 61,
"preview": "corebuild -pkg cryptokit basic_md5_with_optional_file.native\n"
},
{
"path": "code/command-line-parsing/build_basic_md5_with_optional_file_broken.errsh",
"chars": 68,
"preview": "corebuild -pkg cryptokit basic_md5_with_optional_file_broken.native\n"
},
{
"path": "code/command-line-parsing/build_cal_add_days.sh",
"chars": 30,
"preview": "corebuild cal_add_days.native\n"
},
{
"path": "code/command-line-parsing/build_cal_add_sub_days.sh",
"chars": 66,
"preview": "corebuild cal_add_sub_days.native\n./cal_add_sub_days.native -help\n"
},
{
"path": "code/command-line-parsing/build_cal_append.sh",
"chars": 28,
"preview": "corebuild cal_append.native\n"
},
{
"path": "code/command-line-parsing/build_cal_append_broken.errsh",
"chars": 35,
"preview": "corebuild cal_append_broken.native\n"
},
{
"path": "code/command-line-parsing/cal.cmd",
"chars": 183,
"preview": "function _jsautocom_96173 {\n export COMP_CWORD\n COMP_WORDS[0]=./cal_add_sub_days.native\n COMPREPLY=($(\"${COMP_WORDS[@"
},
{
"path": "code/command-line-parsing/cal_add_days.ml",
"chars": 335,
"preview": "open Core.Std\n\nlet add =\n Command.basic\n ~summary:\"Add [days] to the [base] date and print day\"\n Command.Spec.(\n "
},
{
"path": "code/command-line-parsing/cal_add_interactive.ml",
"chars": 568,
"preview": "open Core.Std\n\nlet add_days base span () =\n Date.add_days base span\n |> Date.to_string\n |> print_endline\n\nlet add =\n "
},
{
"path": "code/command-line-parsing/cal_add_labels.ml",
"chars": 405,
"preview": "open Core.Std\n\nlet add_days ~base_date ~num_days () =\n Date.add_days base_date num_days\n |> Date.to_string\n |> print_"
},
{
"path": "code/command-line-parsing/cal_add_sub_days.ml",
"chars": 682,
"preview": "open Core.Std\n\nlet add =\n Command.basic ~summary:\"Add [days] to the [base] date\"\n Command.Spec.(\n empty\n +"
},
{
"path": "code/command-line-parsing/cal_append.ml",
"chars": 1018,
"preview": "open Core.Std\n\nlet add ~common =\n Command.basic ~summary:\"Add [days] to the [base] date\"\n Command.Spec.(\n empty"
},
{
"path": "code/command-line-parsing/cal_append_broken.ml",
"chars": 941,
"preview": "open Core.Std\n\nlet add ~common =\n Command.basic ~summary:\"Add [days] to the [base] date\"\n Command.Spec.(\n empty"
},
{
"path": "code/command-line-parsing/cal_completion.rawsh",
"chars": 158,
"preview": "$ env COMMAND_OUTPUT_INSTALLATION_BASH=1 ./cal_add_sub_days.native > cal.cmd\n$ . cal.cmd\n$ ./cal_add_sub_days.native <ta"
},
{
"path": "code/command-line-parsing/command_types.topscript",
"chars": 69,
"preview": "Command.Spec.empty ;;\nCommand.Spec.(empty +> anon (\"foo\" %: int)) ;;\n"
},
{
"path": "code/command-line-parsing/get_basic_md5_help.errsh",
"chars": 19,
"preview": "./basic_md5.native\n"
},
{
"path": "code/command-line-parsing/get_basic_md5_version.sh",
"chars": 59,
"preview": "./basic_md5.native -version\n./basic_md5.native -build-info\n"
},
{
"path": "code/command-line-parsing/group.topscript",
"chars": 34,
"preview": "Command.basic ;;\nCommand.group ;;\n"
},
{
"path": "code/command-line-parsing/md5_completion.sh",
"chars": 69,
"preview": "env COMMAND_OUTPUT_INSTALLATION_BASH=1 ./basic_md5_with_flags.native\n"
},
{
"path": "code/command-line-parsing/opam.rawsh",
"chars": 101,
"preview": "$ opam config env\n$ opam remote list -k git\n$ opam install --help\n$ opam install cryptokit --verbose\n"
},
{
"path": "code/command-line-parsing/run_basic_and_default_md5.sh",
"chars": 111,
"preview": "cat /etc/passwd | ./basic_md5_with_optional_file.native\ncat /etc/passwd | ./basic_md5_with_default_file.native\n"
},
{
"path": "code/command-line-parsing/run_basic_md5.sh",
"chars": 38,
"preview": "./basic_md5.native ./basic_md5.native\n"
},
{
"path": "code/command-line-parsing/run_basic_md5_as_filename.errsh",
"chars": 43,
"preview": "./basic_md5_as_filename.native nonexistent\n"
},
{
"path": "code/command-line-parsing/run_basic_md5_flags_help.sh",
"chars": 83,
"preview": "./basic_md5_with_flags.native -help\n./basic_md5_with_flags.native -s \"ocaml rocks\"\n"
},
{
"path": "code/command-line-parsing/run_basic_md5_with_custom_arg.errsh",
"chars": 92,
"preview": "./basic_md5_with_custom_arg.native /etc/passwd\n./basic_md5_with_custom_arg.native /dev/null\n"
},
{
"path": "code/command-line-parsing/run_cal_add_sub_days.sh",
"chars": 97,
"preview": "./cal_add_sub_days.native add 2012-12-25 40\n./cal_add_sub_days.native diff 2012-12-25 2012-11-01\n"
},
{
"path": "code/command-line-parsing/single_anon_filename.topscript",
"chars": 61,
"preview": "open Command.Spec ;;\nempty +> anon (\"filename\" %: string) ;;\n"
},
{
"path": "code/command-line-parsing/step.topscript",
"chars": 179,
"preview": "open Command.Spec ;;\nstep (fun m (base:Date.t) days ->\n match days with\n | Some days -> m base days\n | None ->\n p"
},
{
"path": "code/corebuild",
"chars": 422,
"preview": "#!/bin/sh\n\nocamlbuild \\\n -use-ocamlfind \\\n -classic-display \\\n -syntax camlp4o \\\n -pkg core,core_extended,as"
},
{
"path": "code/ctypes/ctypes.mli",
"chars": 1313,
"preview": "type 'a typ\n\n(* part 1 *)\nval void : unit typ\nval char : char typ\nval schar : int typ\nval short : int "
},
{
"path": "code/ctypes/ctypes_impl.ml",
"chars": 93,
"preview": "let string = \n view (char ptr)\n ~read:string_of_char_ptr \n ~write:char_ptr_of_string \n"
},
{
"path": "code/error-handling/blow_up.ml",
"chars": 214,
"preview": "open Core.Std\nexception Empty_list\n\nlet list_max = function\n | [] -> raise Empty_list\n | hd :: tl -> List.fold tl ~ini"
},
{
"path": "code/error-handling/build_blow_up.errsh",
"chars": 38,
"preview": "corebuild blow_up.byte\n./blow_up.byte\n"
},
{
"path": "code/error-handling/build_blow_up_notrace.errsh",
"chars": 53,
"preview": "corebuild blow_up.byte\nOCAMLRUNPARAM= ./blow_up.byte\n"
},
{
"path": "code/error-handling/exn_cost.ml",
"chars": 633,
"preview": "open Core.Std\nopen Core_bench.Std\n\nlet simple_computation () =\n List.range 0 10\n |> List.fold ~init:0 ~f:(fun sum x ->"
},
{
"path": "code/error-handling/main.topscript",
"chars": 4992,
"preview": "List.find;;\n#part 1\nList.find [1;2;3] ~f:(fun x -> x >= 2) ;;\nList.find [1;2;3] ~f:(fun x -> x >= 10) ;;\n#part 2\nlet com"
},
{
"path": "code/error-handling/result.ml",
"chars": 89,
"preview": "module Result : sig\n type ('a,'b) t = | Ok of 'a\n | Error of 'b\nend\n"
},
{
"path": "code/error-handling/result.mli",
"chars": 89,
"preview": "module Result : sig\n type ('a,'b) t = | Ok of 'a\n | Error of 'b\nend\n"
},
{
"path": "code/error-handling/run_exn_cost.sh",
"chars": 74,
"preview": "corebuild -pkg core_bench exn_cost.native\n./exn_cost.native -ascii cycles\n"
},
{
"path": "code/error-handling/run_exn_cost_notrace.sh",
"chars": 47,
"preview": "OCAMLRUNPARAM= ./exn_cost.native -ascii cycles\n"
},
{
"path": "code/error-handling/sexpr.scm",
"chars": 30,
"preview": "(This (is an) (s expression))\n"
},
{
"path": "code/error-handling/try_with.syntax",
"chars": 60,
"preview": "try <expr> with\n| <pat1> -> <expr1>\n| <pat2> -> <expr2>\n...\n"
},
{
"path": "code/exec_script.sh",
"chars": 123,
"preview": "#!/usr/bin/env bash\ncd $(dirname $1)\nwhile IFS= read -r line ; do\n echo \"$ $line\"\n bash -c \"$line\"\ndone < $(basename $"
},
{
"path": "code/exec_topscript.sh",
"chars": 123,
"preview": "#!/usr/bin/env bash\n\ntopscript=`pwd`/../scripts/_build/run_core_toplevel.byte\ncd $(dirname $1)\n$(topscript) $(basename $"
},
{
"path": "code/fcm/build_query_handler.sh",
"chars": 29,
"preview": "corebuild query_handler.byte\n"
},
{
"path": "code/fcm/build_query_handler_loader.sh",
"chars": 36,
"preview": "corebuild query_handler_loader.byte\n"
},
{
"path": "code/fcm/fcm.syntax",
"chars": 34,
"preview": "(module <Module> : <Module_type>)\n"
},
{
"path": "code/fcm/loader_cli1.rawsh",
"chars": 108,
"preview": "$ ./query_handler_loader.byte\n>>> (loader known_services)\n(ls unique)\n>>> (loader active_services)\n(loader)\n"
},
{
"path": "code/fcm/loader_cli2.rawsh",
"chars": 47,
"preview": ">>> (ls .)\nCould not find matching handler: ls\n"
},
{
"path": "code/fcm/loader_cli3.rawsh",
"chars": 258,
"preview": ">>> (loader (load ls /var))\n()\n>>> (ls /var)\n(agentx at audit backups db empty folders jabberd lib log mail msgs named\n "
},
{
"path": "code/fcm/loader_cli4.rawsh",
"chars": 60,
"preview": ">>> (loader (unload loader))\nIt's unwise to unload yourself\n"
},
{
"path": "code/fcm/main.topscript",
"chars": 2087,
"preview": "module type X_int = sig val x : int end;;\n#part 1\nmodule Three : X_int = struct let x = 3 end;;\nThree.x;;\n#part 2\nlet th"
},
{
"path": "code/fcm/pack.syntax",
"chars": 34,
"preview": "(module <Module> : <Module_type>)\n"
},
{
"path": "code/fcm/query-syntax.scm",
"chars": 19,
"preview": "(query-name query)\n"
},
{
"path": "code/fcm/query_example.rawscript",
"chars": 302,
"preview": "$ ./query_handler.byte \n>>> (unique ())\n0\n>>> (unique ())\n1\n>>> (ls .)\n(agentx at audit backups db empty folders jabberd"
},
{
"path": "code/fcm/query_handler.ml",
"chars": 127,
"preview": "open Core.Std\nopen Query_handler_core\n\n(* part 1 *)\nlet () =\n cli (build_dispatch_table [unique_instance; list_dir_inst"
},
{
"path": "code/fcm/query_handler.topscript",
"chars": 4448,
"preview": "module type Query_handler = sig\n\n (** Configuration for a query handler. Note that this can be\n converted to "
},
{
"path": "code/fcm/query_handler_core.ml",
"chars": 5323,
"preview": "open Core.Std\n\nmodule type Query_handler = sig\n\n (** Configuration for a query handler. Note that this can be\n co"
},
{
"path": "code/fcm/query_handler_loader.ml",
"chars": 385,
"preview": "open Core.Std\nopen Query_handler_core\n(* part 1 *)\nlet () =\n let loader = Loader.create [(module Unique); (module List_"
},
{
"path": "code/fcm/unpack.syntax",
"chars": 43,
"preview": "(val <first_class_module> : <Module_type>)\n"
},
{
"path": "code/ffi/build_datetime.sh",
"chars": 85,
"preview": "corebuild -pkg ctypes.foreign datetime.native\n./datetime.native\n./datetime.native -a\n"
},
{
"path": "code/ffi/build_hello.sh",
"chars": 69,
"preview": "corebuild -pkg ctypes.foreign -lflags -cclib,-lncurses hello.native \n"
},
{
"path": "code/ffi/build_qsort.sh",
"chars": 172,
"preview": "corebuild -pkg ctypes.foreign qsort.native\ncat input.txt\n./qsort.native < input.txt\ncorebuild -pkg ctypes.foreign qsort."
},
{
"path": "code/ffi/datetime.ml",
"chars": 1335,
"preview": "open Core.Std\nopen Ctypes\nopen PosixTypes\nopen Foreign\n\nlet time = foreign \"time\" (ptr time_t @-> returning time_t)\n"
},
{
"path": "code/ffi/hello.ml",
"chars": 311,
"preview": "open Ncurses\n\nlet () =\n let main_window = initscr () in\n ignore(cbreak ());\n let small_window = newwin 10 10 5 5 in\n "
},
{
"path": "code/ffi/infer_ncurses.sh",
"chars": 84,
"preview": "corebuild -pkg ctypes.foreign ncurses.inferred.mli\ncp _build/ncurses.inferred.mli .\n"
},
{
"path": "code/ffi/input.txt",
"chars": 10,
"preview": "5\n3\n2\n1\n4\n"
},
{
"path": "code/ffi/install.rawsh",
"chars": 105,
"preview": "$ brew install libffi # for MacOS X users\n$ opam install ctypes\n$ utop\n# require \"ctypes.foreign\" ;;\n"
},
{
"path": "code/ffi/ncurses.h",
"chars": 405,
"preview": "typedef struct _win_st WINDOW;\ntypedef unsigned int chtype;\n\nWINDOW *initscr (void);\nWINDOW *newwin (int, int, int,"
},
{
"path": "code/ffi/ncurses.inferred.mli",
"chars": 421,
"preview": "type window = unit Ctypes.ptr\nval window : window Ctypes.typ\nval initscr : unit -> window\nval endwin : unit -> unit\nval "
}
]
// ... and 397 more files (download for full content)
About this extraction
This page contains the full source code of the realworldocaml/examples GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 597 files (412.3 KB), approximately 157.5k tokens, and a symbol index with 12 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.