caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Higher-kinded bounded polymorphism
@ 2021-09-13 12:21 Oleg
  2021-09-14 17:03 ` Carette, Jacques
  0 siblings, 1 reply; 2+ messages in thread
From: Oleg @ 2021-09-13 12:21 UTC (permalink / raw)
  To: caml-list


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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: [Caml-list] Higher-kinded bounded polymorphism
  2021-09-13 12:21 [Caml-list] Higher-kinded bounded polymorphism Oleg
@ 2021-09-14 17:03 ` Carette, Jacques
  0 siblings, 0 replies; 2+ messages in thread
From: Carette, Jacques @ 2021-09-14 17:03 UTC (permalink / raw)
  To: Oleg, caml-list

This trick reminds me of a similar trick used by Goguen in OBJ.  See "Higher Order Functions Considered Unnecessary for Higher Order Programming" https://cseweb.ucsd.edu/~goguen/pps/utyop.pdf from 1987.

> -----Original Message-----
> From: caml-list-request@inria.fr <caml-list-request@inria.fr> On Behalf Of Oleg
> Sent: September 13, 2021 8:22 AM
> To: caml-list@inria.fr
> Subject: [Caml-list] Higher-kinded bounded polymorphism
> 
> 
> 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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-14 17:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-13 12:21 [Caml-list] Higher-kinded bounded polymorphism Oleg
2021-09-14 17:03 ` Carette, Jacques

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