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] Higher-kinded bounded polymorphism
Date: Mon, 13 Sep 2021 21:21:39 +0900	[thread overview]
Message-ID: <20210913122139.GA3696@Melchior.localnet> (raw)


Abstraction over polymorphic types is something that one comes across
from time to time, especially when implementing operations generic
over collections, or embedding typed DSLs (particularly in
tagless-final style). One immediately learns that OCaml does not have
higher-kinded type variables (type variables that range over type
constructors like list and array); does not permit type constructors
appearing by themselves, without being applied to the right number of
arguments; and restricts polymorphic types in other ways (e.g., not
allowing them in type constraints of package types). One soon learns
that the module system (using functors) is a way to realize
higher-kinded polymorphism in OCaml. It takes longer to learn it is
not the only way, however.

The following web page is written to speed up this learning. It
collects what I have learned and rediscovered on this topic, arranged
into a single story and with new explanations and attributions (and
occasionally, new variations).

        http://okmij.org/ftp/ML/higher-kind-poly.html

One interesting discovery is that some problems that ostensibly
require higher-kinded polymorphism really do not.

The article comes with the complete accompanying code.

             reply	other threads:[~2021-09-13 12:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-13 12:21 Oleg [this message]
2021-09-14 17:03 ` Carette, Jacques

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=20210913122139.GA3696@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).