Coder Social home page Coder Social logo

janestreet / learn-ocaml-workshop Goto Github PK

View Code? Open in Web Editor NEW
537.0 19.0 143.0 2.99 MB

Exercises and projects for Jane Street's OCaml Workshop

License: Apache License 2.0

Scheme 4.26% OCaml 94.83% Makefile 0.23% HTML 0.53% Dockerfile 0.02% Shell 0.14%

learn-ocaml-workshop's Introduction

Jane Street OCaml Workshop

This repo contains exercises and build instructions to help you get started developing in OCaml.

Installing build tools and libraries

See README.org in install-ocaml for instructions.

Exercises

The exercises directory contains a number of exercises to get you started with OCaml. Each one has some expect-tests embedded in it. The workflow is:

cd 02-exercises/$problem_dir

dune runtest # builds and runs inline tests
# Look at test output and compiler errors, edit problem.ml, rerun:
dune runtest

Snake, Lumines, and Frogger

Once you’re done with the exercises, you can also implement simplified clones of the following arcade games:

  • snake (runs on your computer)
  • lumines (runs on your computer)
  • frogger (runs in a web browser)

Async

The OCaml standard library has various low-level calls for working with sockets in the Unix module and Jane Street’s Core library wraps all of those. But, if you want your program to be able to wait for multiple events at the same time, you likely want to be able to program concurrently.

One library for writing code in this style is Async. Async provides Reader and Writer abstractions for I/O which, paired with the Tcp module should have most of what you need for either of the projects below.

Before proceeding, it would probably be a good idea to read Chapter 18 of Real World OCaml. There is some example code in the next section which should set you on your way.

Bigger projects

Once you’ve made it to this point, there are a few possible paths laid out for you:

  • You can work on writing a bot for a chat protocol called IRC. See the irc-bot README to get started!
  • You can work on writing your very own version of fzf in OCaml. See the fuzzy-finder README to get started!
  • Or, if you want, you can continue making improvements and extensions to your version of Frogger (see the frogger README for some ideas).

Documentation and resources

OCaml

Jane Street libraries and tools

dune

learn-ocaml-workshop's People

Contributors

adept avatar ajinjude avatar avsm avatar beizhedenglong avatar codingwithkittens avatar dra27 avatar haohangxu avatar kshitijl avatar leviroth avatar lucasweng avatar yminsky 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

learn-ocaml-workshop's Issues

Support arrow keys in lumines

The current controls are wasd + space, which anecdotally seem non-intuitive to most people. It's non-trivial to support arrow keys using the current framework, though.

Use ocamlformat in 02-exercises

Currently, some files are manually formatted to be more sparse for readability. It would be nice to write an ocamlformat config that does this to avoid having to think about formatting while going through the exercises.

Permissions issue when running dune build

I'm having some trouble running through this tutorial: https://github.com/janestreet/install-ocaml

I've cloned the files, installed the dependencies, but I'm not able to run 'dune' properly.

I'm running this command within the 01-install-ocaml folder: dune build hello_world.exe
I get this: -bash: ./dune: Permission denied

Then, I run using this command: sudo dune build hello_world.exe
I get this: sudo: dune: command not found

Here's my environment setup: macOS 10.15.2 (Catalina) and 'bash' in Terminal. Are there any steps I've missed? How would I check?

Use expect tests

It would be nice to have tests for functions that involve printing. Some of the current tests that check values are equal might work nicer as expect tests instead.

(We possibly want to do this instead of issue #24 altogether?)

Error in 03-Frogger when testing js-of-ocaml-install

Thank you for this workshop!
I have done all the exercises and now i am starting the games it is not building. It is frustrating ;-)

when 'make' inside test-js-of-ocaml-install =>

dune build @default
Entering directory '/Users/eewans/projets/learn-ocaml-workshop'
File "03-frogger/test-js-of-ocaml-install/dune", line 10, characters 0-53:
10 | (alias
11 | (name DEFAULT)
12 | (deps main.bc.js index.html))
Error: No rule found for 03-frogger/test-js-of-ocaml-install/main.bc.js
make: *** [all] Error 1

Discontinuation of concepts (if else )

Programming concepts like pattern matching were utilised in the chapters preceding to the one where range function was asked to implement (02-exercises/09-list_range), but if else wasn't utilised before . It would have been better if those concepts were also added at the basic level before implementing a more complicated function . So that way this workshop can also be a bit more continuous , so to say .

Change Array.iter to Array.map

In the chapter 13, you said I need to implement a double function that doubles all the values of an array with Array.iter. The function that Array.iter takes must need to be type unit. So the correct way of doing that is with Array.map.

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.