Code Monkey home page Code Monkey logo

ocaml's Introduction

xOCaml

Exercism Exercises in OCaml

Contributing Guide

Contributions to the OCaml track (or any other part of Exercism) are very welcome!

Please see the contributing guide for overall guidance. The below notes contain a few details specific to Ocaml.

Prerequisites

The OCaml track assumes installation of OCaml version 4.07.0, and installation of Core_kernel, OUnit, and React (for the Hangman exercise). Assuming you have opam, these can be installed with

opam install core_kernel ounit react

Notes on prerequisite libraries

Core_kernel is a standard library replacement. If you prefer to write your exercises using the standard library distributed with OCaml, or to use other standard library replacements (such as Batteries), that is also an option. If you find any difficulties doing so please raise an issue.

OUnit is a unit testing library.

React is a reactive library, just used in the hangman exercise.

Running Tests

To run all the tests, type make from the top level ocaml directory.

To run tests for an individual exercise, make test-assignment ASSIGNMENT=luhn

The Makefile is a slim wrapper around dune. Each exercise has a dune file which describes how to build it.

Adding an Exercise

The contributing guide provides guidance on how to add a new exercise, or port an existing exercise from another language track. This is a brief guide, with specifics for the OCaml stream.

Firstly, register the exercise in config json. The name of the exercise should go in the "slug" entry.

Then, write the exercise tests & proof of concept implementation. A folder layout for an exercise called "ocaml-exercise" is below.

└── exercises
    └── ocaml-exercise
        ├── .merlin (provided IDE assistance - copy this from any of the other Ocaml exercises)
        ├── example.ml (a proof of concept implementation)
        ├── ocaml_exercise.mli (the interface definition for the exercise)
        ├── HINTS.md (additional hints to anyone trying the exercise - optional)
        ├── Makefile (standard - copy this from any of the other Ocaml exercises)
        ├── test.ml (unit tests)

In this example, the Makefile would look for an implementation in ocaml_exercise.ml - as it matches the .mli file name. When developing it is easier to create and edit ocaml_exercise.ml, but the code should be copied to example.ml prior to submitting a pull request (and ocaml_exercise.ml should not be submitted).

All pull requests are run through a Travis CI build, which compiles and runs tests.

Canonical test data

If you are implementing an existing test, there may be "canonical data" for it in the x-common repository. An example: https://github.com/exercism/x-common/blob/master/exercises/bracket-push/canonical-data.json

You should base your tests off this data, in order to provide consistency across different language tracks.

There is a test generator which can create test code from these json files and an OCaml template file that you would need to create. It is a work in progress, so may not work for every exercise. If you wish to use it, there is documentation here.

Feedback

If you find this documentation is inaccurate or incomplete, or can be improved in any way, please don't hesitate to raise an issue or submit a pull request.

OCaml icon

The OCaml logo is released under the Attribution-ShareAlike 4.0 International license.

ocaml's People

Contributors

stevejb71 avatar dvberkel avatar marionebl avatar kytrinyx avatar sshine avatar pminten avatar tmcgilchrist avatar sbl avatar austinlyons avatar mboeh avatar jackhughesweb avatar petertseng avatar mziener avatar dkinzer avatar dcorking avatar daveyarwood avatar voila avatar gosma avatar chellbell avatar vrotaru avatar tejasbubane avatar rootulp avatar peaupote avatar citizen428 avatar michaelavila avatar kevgathuku avatar ismaelga avatar erikschierboom avatar dop avatar catb0t avatar

Watchers

James Cloos avatar

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.