HackerPapers

arXiv:1512.01895cs.PL

Modular implicits

Leo White, Frédéric Bour, Jeremy Yallop

Abstract

We present modular implicits, an extension to the OCaml language for ad-hoc polymorphism inspired by Scala implicits and modular type classes. Modular implicits are based on type-directed implicit module parameters, and elaborate straightforwardly into OCaml's first-class functors. Basing the design on OCaml's modules leads to a system that naturally supports many features from other languages with systematic ad-hoc overloading, including inheritance, instance constraints, constructor classes and associated types.

arXiv comments
In Proceedings ML/OCaml 2014, arXiv:1512.01438
Journal reference
EPTCS 198, 2015, pp. 22-63
DOI
doi:10.4204/EPTCS.198.2
Subjects
cs.PLProgramming Languages

On Hacker News

Linked by 12 identifiable commenters in 13 comments across 11 threads, from Mar 2016 to Aug 2025. Found in 1 HN submission from Dec 2015 to Dec 2015. Open submission discussions.

Comments linking this paper, per year.

Discussed in comments11 threads

  1. OCaml as my primary language 1 comment
    • - Extremely dated: we have almost one new release every six month and in recent releases, the language runtime has been changed and user-defined effects have been introduced. - No HKTs "in your sense" but: ```ocaml module type S = sig type 'a t end `` `type 'a t` is an Higher…

      nukifwView on HNParent context

    • > Ocaml messed up with their operators. ... I hope a future version adds module typeclasses Do you mean modular implicits?[1] The original paper was published in 2014. There's an internship report from 2023 that summarizes the design and implementation issues…

      nequoView on HNParent context

    • Type classes are useful but can be overly restrictive as implemented in languages such as Haskell. In particular, Haskell prevents multiple implementations of a type class for a particular type (a property called canonicity). But there are lots of situations where there are many…

      sgeisenhView on HNParent context

    • * GADTs: generalized algebraic data types. As the name suggests, GADTs broaden the set of type-level constraints that one can encode using ADTs. A canonical example involves using GADTs to strongly type an AST and evaluator function s.t. attempting to construct or operate on an…

      lpageView on HNParent context

  2. Exotic List Monads 1 comment
    • Part of this has to do with the fact that it is not possible (without tricks) to have multiple different typeclass implementations for one type in Haskell (I believe Rust also has this restriction). This language restriction has the tendency to seep into people's way of thinking…

      ShoopView on HNParent context

    • As a layman I would describe them as implicits like in current Scala [0] but better (easier to reason about). One thing which they allow is ad-hoc polymorphism like typeclasses. https://arxiv.org/pdf/1512.01895.pdf https://old.reddit.com/r/ocaml/comments/4qan0w/modular_type_...…

      tutanchamunView on HNParent context

    • > No, I mean that neither Elm nor Standard ML has nor needs typeclasses. No language needs typeclasses. Standard ML has less need for type classes because it has a much more expressive module system, but it still can be extremely tedious to pass around module definitions all the…

      bjz_View on HNParent context

    • Gluon recently added implicit arguments with the latest release (see http://marwes.github.io/2018/06/19/gluon-0.8.html). In spirit it is like modular implicits (https://arxiv.org/pdf/1512.01895.pdf). This is really exciting because modular implicits represent a pragmatic balance…

      jdreaverView on HNParent context

  3. Towards Scala 3 1 comment
    • If by "all constructions wiht HKTs", you mean what can be done with HKTs in Haskell, then I'd say yes. It is well-known that ML modules provide a very advanced level of expressiveness, especially since OCaml's introduction of first-class modules. Also, Scala took this idea…

      lptkView on HNParent context

    • If I'm not mistaken, this release is not the multicore release[0]. Also, if anyone's keen on reading the paper behind modular implicits in OCaml, its a fun read - http://arxiv.org/abs/1512.01895 [0] - https://blogs.janestreet.com/flambda/#comment-39958

      krat0sprakharView on HNParent context

    • This is exactly the problem that modular implicits will solve. See http://arxiv.org/pdf/1512.01895.pdf

      pauldirac137View on HNParent context

    • Modules are strictly more powerful than Haskell type classes (at least, more powerful than naive type classes; there are so many extensions that I'm not sure that is still the case). Modular implicits are described here: http://arxiv.org/pdf/1512.01895.pdf. The main problem with…

      pauldirac137View on HNParent context

    • If you don't mind reading a paper, there's a paper on it that actually is readable instead of just all whitepapery and overly-theoretical: http://arxiv.org/pdf/1512.01895.pdf

      ubertacoView on HNParent context

Submitted to Hacker News

Connected through shared HN threads, not inferred similarity or a recommendation.