Coder Social home page Coder Social logo

moodules's Introduction

Moodules

Prototype of OO style Libraries for Dune. This is mostly just a much more limited implementation of virtual libraries, but with some fixes for bugs that I discovered in virtual libraries.

  • Jump to location working correctly.
  • Mysterious link time bugs gone.

This works by simply copying modules around, which simplifies the implementation.

  • Allows depending on a concrete library that "extends" a virtual library, and then rely on additional modules inside of that concrete library that were not part of the virtual library.
  • Allows different concrete implementations to diverge in their .rei files.

The major downside is that (for now) consumers must specify exactly which concrete implementation they rely on - you cannot just depend on a virtual "base class" library, and then defer selection of concrete library until link time (executable). I could try to add that feature though.

Usage

Each moodule library is defined like this:

(* -*- tuareg -*- *)
open Jbuild_plugin.V1;;
send (String.concat "\n" (run_and_read_lines "Moodules"));;
{|
  PUT YOUR CUSTOM DUNE CONFIG FOR THIS LIBRARY HERE
|};;

Moodules currently only work within the same repo/package, and must always use public names.

For example:

(* -*- tuareg -*- *)
open Jbuild_plugin.V1;;
send (String.concat "\n" (run_and_read_lines "Moodules"));;
{|
  (library
    (public_name virtualish.baseclass)
    (name VirtualishBaseclass)
  )
|};;

Then other modules may "extend" that "moodule" by using (extends_moodule ).

(* -*- tuareg -*- *)
open Jbuild_plugin.V1;;
send (String.concat "\n" (run_and_read_lines "Moodules"));;
{|
(library
  (public_name virtualish.subclass)
  (extends_moodule virtualish.virtual)
  (name VirtualishSubclass)
)
|};;

The contents of the subclass "inherit" the base class.

If you want the base library to never be instantiable, or perhaps even be misformed until extended, it is by default considered abstract just by nature of using the Moodules plugin, and not specifying an (extends ) directive.

(* -*- tuareg -*- *)
open Jbuild_plugin.V1;;
send (String.concat "\n" (run_and_read_lines "Moodules"));;
{|
  (library
    (public_name virtualish.baseclass)
    (name VirtualishBaseclass)
  )
|};;

moodules's People

Contributors

jordwalke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.