caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Oleg <oleg@okmij.org>
To: caml-list@inria.fr
Subject: [Caml-list] (ANN) Lightweight HList -- typed heterogeneous collections
Date: Thu, 20 Aug 2020 22:41:51 +0900	[thread overview]
Message-ID: <20200820134151.GA4611@Melchior.localnet> (raw)


This is a (very late) announcement of the pure OCaml lightweight
analogue of HList -- typed heterogeneous collections. Such collections
store data of various types, and offer element access/modification
plus bulk operations such as mapping and iteration. In HList, the type
of the collection reflects the types of the elements; therefore all
type mismatches can be detected statically. Correspondingly, there
is no need to store any type information at run-time.

The library was actually written two years ago. I have just realized I
neglected to announce it. The implementation is fairly trivial, but
does come useful from time to time, e.g., to implement polyvariadic
functions. One interesting facility is the ability to replace an
element somewhere in a collection with a new one of a different
type. The type of the returned collection is changed
accordingly. 

A more detailed description, and the pointer to the code is:
          http://okmij.org/ftp/ML/ML.html#hlist

The code contains several examples, including multi-dimensional
cartesian product: converting an HList of regular lists to a list of
tuples, elements of the cartesian product.

A somewhat non-trivial application of HList (specifically,
type-changing update) is the tagless-final embedding of simply-typed
lambda-calculus with De Bruijn *levels*:
        http://okmij.org/ftp/tagless-final/cookbook.html#dblevels
At first glance, an embedding that relies on OCaml typechecker to
check and infer types of lambda-terms seems impossible.


                 reply	other threads:[~2020-08-20 13:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200820134151.GA4611@Melchior.localnet \
    --to=oleg@okmij.org \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).