Giter Site home page Giter Site logo

ocaml-effects-tutorial's Introduction

๐Ÿ“ข Note ๐Ÿ“ข

Multicore OCaml project has now been merged into OCaml ๐ŸŽ‰. This repository is no longer developed or maintained. Please follow the updates at the OCaml Github repository.

Citation

If you are citing this work in an academic paper, please cite the ICFP 2020 paper "Retrofitting Parallelism onto OCaml": https://dl.acm.org/doi/10.1145/3408995


Branch trunk Branch 4.14 Branch 4.13 Branch 4.12

Github CI Build Status (trunk branch) Github CI Hygiene Status (trunk branch) AppVeyor Build Status (trunk branch)

Github CI Build Status (4.14 branch) AppVeyor Build Status (4.14 branch)

TravisCI Build Status (4.13 branch) AppVeyor Build Status (4.13 branch)

TravisCI Build Status (4.12 branch) AppVeyor Build Status (4.12 branch)

README

Overview

OCaml is a functional, statically-typed programming language from the ML family, offering a powerful module system extending that of Standard ML and a feature-rich, class-based object system.

OCaml comprises two compilers. One generates bytecode which is then interpreted by a C program. This compiler runs quickly, generates compact code with moderate memory requirements, and is portable to many 32 or 64 bit platforms. Performance of generated programs is quite good for a bytecoded implementation. This compiler can be used either as a standalone, batch-oriented compiler that produces standalone programs, or as an interactive REPL system.

The other compiler generates high-performance native code for a number of processors. Compilation takes longer and generates bigger code, but the generated programs deliver excellent performance, while retaining the moderate memory requirements of the bytecode compiler. The native-code compiler currently runs on the following platforms:

Tier 1 (actively maintained) Tier 2 (maintained when possible)

x86 64 bits

Linux, macOS, Windows, FreeBSD

NetBSD, OpenBSD

x86 32 bits

Linux, Windows

FreeBSD, NetBSD, OpenBSD

ARM 64 bits

Linux, macOS

FreeBSD

ARM 32 bits

Linux

FreeBSD, NetBSD, OpenBSD

Power 64 bits

Linux

Power 32 bits

Linux

RISC-V 64 bits

Linux

IBM Z (s390x)

Linux

Other operating systems for the processors above have not been tested, but the compiler may work under other operating systems with little work.

All files marked "Copyright INRIA" in this distribution are Copyright ยฉ 1996-2021 Institut National de Recherche en Informatique et en Automatique (INRIA) and distributed under the conditions stated in file LICENSE.

Installation

See the file INSTALL.adoc for installation instructions on machines running Unix, Linux, macOS, WSL and Cygwin. For native Microsoft Windows, see README.win32.adoc.

Documentation

The OCaml manual is distributed in HTML, PDF, and Emacs Info files. It is available at

Availability

The complete OCaml distribution can be accessed at

Keeping in Touch with the Caml Community

There is an active and friendly discussion forum at

The OCaml mailing list is the longest-running forum for OCaml users. You can email it at

You can subscribe and access list archives via the Web interface at

An alternative archive of the mailing list is also available at

There also exist other mailing lists, chat channels, and various other forums around the internet for getting in touch with the OCaml and ML family language community. These can be accessed at

In particular, the IRC channel #ocaml on Libera has a long history and welcomes questions.

Bug Reports and User Feedback

Please report bugs using the issue tracker at https://github.com/ocaml/ocaml/issues

To be effective, bug reports should include a complete program (preferably small) that exhibits the unexpected behavior, and the configuration you are using (machine type, etc).

For information on contributing to OCaml, see HACKING.adoc and CONTRIBUTING.md.

Separately maintained components

Some libraries and tools which used to be part of the OCaml distribution are now maintained separately. Please use the issue trackers at their respective new homes:

ocaml-effects-tutorial's People

Contributors

ahmadrasyidsalim avatar dhil avatar i321takeji avatar kayceesrk avatar kevgathuku avatar ryangibb avatar sudha247 avatar tanelso2 avatar toastal avatar tryggvigy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ocaml-effects-tutorial's Issues

Solution for the example in 1.1

Adding a function run should suffice. No need to modify sum_up.

exception Conversion_failure of string

let int_of_string l =
  try int_of_string l with
  | Failure _ -> raise (Conversion_failure l)

let rec sum_up acc =
    let l = input_line stdin in
    acc := !acc + int_of_string l;
    sum_up acc

let rec run (acc: int ref) = (
  try sum_up acc with
  | End_of_file -> Printf.printf "Sum is %d\n" !acc
  | Conversion_failure s ->
    (Printf.fprintf stderr "Conversion failure \"%s\"\n%!" s; run acc)
)

let () =
  let r = ref 0 in
  run r

wrong type in README.md

in the section 1.2. Basics

The parameter k, is the delimited continuation between the point of performing the effect and the effect handler. The delimited continuation is like a dynamically defined function, that can be called and returns a value. The type of k in this case is (int, int) continuation, which says that the continuation expects an integer to continue (the first type parameter), and returns with an integer (the second type parameter).

I believe the type of k should be (int, unit) continuation instead of (int, int) continuation as the function sum_up does not return value.

gdb.ml debug difference in output

Following the steps described in the tutorial yields the following output:

(gdb) break caml_resume
Breakpoint 1 at 0x911f4
(gdb) break caml_perform
Breakpoint 2 at 0x91140
(gdb) r
Starting program: /home/sudha/dir/ocaml-effects-tutorial/sources/gdb.native 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 2, 0x00005555555e5140 in caml_perform ()
(gdb) bt
#0  0x00005555555e5140 in caml_perform ()
#1  0x0000555555599b64 in camlGdb__a_1004 () at gdb.ml:4
#2  0x0000555555599bd7 in camlGdb__b_1006 () at gdb.ml:5
#3  0x0000555555599c47 in camlGdb__c_1008 () at gdb.ml:6
#4  <signal handler called>
#5  0x0000555555599cd5 in camlGdb__d_1010 () at gdb.ml:10
#6  <signal handler called>
#7  0x0000555555599d75 in camlGdb__e_1015 () at gdb.ml:16
#8  0x0000555555599f46 in camlGdb__entry () at gdb.ml:23
#9  0x00005555555966eb in caml_program ()
#10 <signal handler called>
#11 caml_startup_common (argv=0x7fffffffddc8, pooling=<optimized out>, pooling@entry=0) at startup.c:137
#12 0x00005555555e5518 in caml_startup_exn (argv=<optimized out>) at startup.c:141
#13 caml_main (argv=<optimized out>) at startup.c:146
#14 0x000055555559646c in main (argc=<optimized out>, argv=<optimized out>) at main.c:44
(gdb) c
Continuing.
Raised by primitive operation at file "gdb.ml", line 4, characters 14-26
Called from file "gdb.ml", line 5, characters 14-17
Called from file "gdb.ml", line 6, characters 14-17
Called from file "gdb.ml", line 10, characters 2-62

Breakpoint 1, 0x00005555555e51f4 in caml_resume ()
(gdb) bt
#0  0x00005555555e51f4 in caml_resume ()
#1  0x0000555555599d75 in camlGdb__e_1015 () at gdb.ml:16
#2  0x0000555555599f46 in camlGdb__entry () at gdb.ml:23
#3  0x00005555555966eb in caml_program ()
#4  <signal handler called>
#5  caml_startup_common (argv=0x7fffffffddc8, pooling=<optimized out>, pooling@entry=0) at startup.c:137
#6  0x00005555555e5518 in caml_startup_exn (argv=<optimized out>) at startup.c:141
#7  caml_main (argv=<optimized out>) at startup.c:146
#8  0x000055555559646c in main (argc=<optimized out>, argv=<optimized out>) at main.c:44
(gdb) c
Continuing.
333
[Inferior 1 (process 7902) exited normally]

Not sure if the order of execution is same as described in the tutorial, there's a difference in order of hitting the breakpoints and the number of times breakpoints are encountered (lesser in this case). I shall try to gain more understanding on this and raise a PR.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.