caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Andreas Rossberg <rossberg@ps.uni-sb.de>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Re: variance, subtyping and monads... oh, my!
Date: Mon, 19 Nov 2001 11:39:08 +0100	[thread overview]
Message-ID: <3BF8E14C.BE31359E@ps.uni-sb.de> (raw)
In-Reply-To: <DCC4EB14-DC73-11D5-963F-000502DB38F5@wetware.com>

james woodyatt wrote:
> 
> I'm grateful for the bit about the binomial function type constructor
> that I can conceptually think about like this:
> 
>    type (+'domain,-'range) (->) = <fun>  (* yeah, this is pseudo-syntax *)

Almost, except for the inverted variance annotation. It should be:

	type (-'domain,+'range) (->)


> On Sunday, November 18, 2001, at 05:34 , Andreas Rossberg wrote:
> >
> > I hope my explanations clarified that these terms are mainly important
> > if
> > you do OO in the presence of polymorphic types. Functional programming
> > in
> > its purer forms usually does not use nor require subtyping, so need not
> > bother with them ;-)
> 
> <quip>How do you do OOP in the *absence* of polymorphic types?</quip>

By programming in Java, for example? ;-)

Seriously, when speaking about type systems the term "polymorphism"
usually refers to parametric polymorphism, witnessed by type
constructors like "list" or polymorphic functions like List.map, where
type variables pop up. Some OO languages have this kind of polymorphism,
e.g. Eiffel, or C++ with its templates (although the latter is rather a
macro language than a typeful concept). Many do not.

The OO world tends to use the same term to describe subtyping
polymorphism, but that arguably is a slight abuse of terminology, at
least IMHO.

There are even more forms of polymorphism, but I stop here.

> I'm guessing that these "purer forms" of functional programming involve
> convoluted gyrations with monads and the higher order "things" that you
> can construct with them by layering them one on top of the other.  (What
> would you call those things?  Molecules?)

No, as Francois suggested here I just meant functional programming
without mixing in OO.

> Now, is it my imagination, or is all that research into what you can
> build out of monads primarily a way for Haskell people to rediscover
> everything we already know about polymorphism, inheritance and
> encapsulation?

Mh, I don't see what monads have to do with object-oriented concepts.
Monads are (besides other things) useful to integrate imperative stuff
into a language without giving up referential transparency, or to
sequentialise actions in a non-strict language. But this is only related
to OO in the sense that OO usually builds upon imperative programming
(so that stateful objects have to live inside a monad in pure functional
languages).

Also, I am not sure what particular concept of encapsulation you are
referring to. Monads are a tool to build abstractions and as such they
of course encapsulate stuff. But I would argue that the sort of
encapsulation usually performed with classes and objects is more related
to modules and plain closures (1st-class functions).

> Here's my question: Am I missing some important clue about what monads
> will get me?

Maybe. I don't often use monads myself, so I am by no means an expert,
but there are quite some useful applications, even outside the realm of
lazy evaluation and purely functional languages. Examples are
encapsulating state, failure, non-determinism, etc. I think Markus Mottl
posted an OCaml example of a simple monadic evaluator some time ago. And
here is one of the more readable, not too Haskell-centric papers:


http://cm.bell-labs.com/cm/cs/who/wadler/topics/monads.html#marktoberdorf

-- 
Andreas Rossberg, rossberg@ps.uni-sb.de

"Computer games don't affect kids; I mean if Pac Man affected us
 as kids, we would all be running around in darkened rooms, munching
 magic pills, and listening to repetitive electronic music."
 - Kristian Wilson, Nintendo Inc.
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


  parent reply	other threads:[~2001-11-19 10:39 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-16 19:37 [Caml-list] [Q]: Co(ntra)variance and subtyping? Clemens Hintze
2001-11-17 14:18 ` Mark Wotton
2001-11-17 14:55   ` Mark Wotton
2001-11-17 17:50   ` [Caml-list] " Clemens Hintze
2001-11-17 23:17     ` Mark Wotton
2001-11-18  9:16       ` Clemens Hintze
2001-11-18 13:18         ` Alain Frisch
2001-11-19  9:54           ` Remi VANICAT
     [not found]       ` <9t7v4d$gij$1@qrnik.zagroda>
2001-11-18 11:57         ` Marcin 'Qrczak' Kowalczyk
2001-11-18 13:34 ` [Caml-list] " Andreas Rossberg
2001-11-18 21:22   ` Pixel
2001-11-19  0:33     ` Jacques Garrigue
2001-11-18 22:35       ` David Gurr
2001-11-19  7:24         ` [Caml-list] " Clemens Hintze
2001-11-19 12:03           ` Markus Mottl
2001-11-19  8:29         ` [Caml-list] " Xavier Leroy
2001-11-19 11:03       ` Alain Frisch
2001-11-20  9:58         ` Didier Remy
2001-11-19 11:14       ` Pixel
2001-11-18 22:30   ` [Caml-list] Re: variance, subtyping and monads... oh, my! james woodyatt
2001-11-19  8:11     ` Francois Pottier
2001-11-19  9:02       ` james woodyatt
2001-11-19  9:58         ` Markus Mottl
2001-11-19 20:47           ` james woodyatt
2001-11-19 12:56       ` Frank Atanassow
2001-11-19 10:39     ` Andreas Rossberg [this message]
2001-11-19 12:21       ` Markus Mottl
2001-11-19 13:43         ` [Caml-list] Kylix and OCaml Christophe Raffalli
2001-11-20  2:05           ` Vitaly Lugovsky
2001-11-20  8:51             ` Christophe Raffalli
2001-11-22  1:42               ` Vitaly Lugovsky
2001-11-20 10:00             ` Benjamin Monate
2001-11-20 10:24               ` [Caml-list] [Bug in an interface between C++ and OCAML due to some pointer encapsulation] Sylvain Kerjean
2001-11-20 12:14             ` [Caml-list] Kylix and OCaml Maxence Guesdon

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=3BF8E14C.BE31359E@ps.uni-sb.de \
    --to=rossberg@ps.uni-sb.de \
    --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).