Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] [Q]: Co(ntra)variance and subtyping?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: james woodyatt <jhw@w...>
Subject: [Caml-list] Re: variance, subtyping and monads... oh, my!

I would like to thank all of the OCaml experts who contributed responses 
to the thread about co-variance, contra-variance and subtyping issues.  
It helped me confirm for myself that I have a good intuitive grasp of 
the subject.  The next step is learning how to teach it.

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

That helped a great deal.  Gives me a way to describe something I've 
never liked about C++ and Java.

Oh, and I have a quip to add to the mix, and a question of my own:

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>

Now for the question.  First the background:

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

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 

My approach for abstracting DNS resource record types so that my client 
and server implementations have a modular interface for section 
processing uses polymorphic variant types and module signatures.  It 
seems pretty lightweight and does what I want.

For a brief moment there, I had this nagging concern that maybe I should 
learn more about these "monad" things before I move on to implementing 
the DNS client and server modules.  I looked into it a little bit, and I 
decided to stick with the interface I have.

As near as I can tell, OCaml doesn't keep me from building monads if I 
really feel a deep and burning need to do so, but for the life of me I 
can't figure out what I might get out of it that would be useful and new.

The covariant polymorphic type parameter trick that I saw posted to this 
list a month or so ago seems to produce the same degree of encapsulation 
and polymorphism I can get with a monad, and I don't *seem* to have all 
the overhead associated with lazy evaluation and building mad closure 
chains all over the place.

Here's my question: Am I missing some important clue about what monads 
will get me?  Other than further advancement in the Order of the Mystic 
Knights of the Lambda Calculus, of course.

j h woodyatt <>
"...the antidote to misinformation is more information, not less."
                                                      --vinton cerf

Bug reports:  FAQ:
To unsubscribe, mail  Archives: