Version française
Home     About     Download     Resources     Contact us    
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: Francois Pottier <francois.pottier@i...>
Subject: Re: [Caml-list] Re: variance, subtyping and monads... oh, my!

Hello everyone,

Just a few thoughts about this discussion. As Andreas and Alan said, there is
no need to understand ocaml's object system in order to experiment with
functional programming. The core features of ocaml are functions, (possibly
mutable) data structures and pattern matching, exceptions, and modules. These
features do not require subtyping at all. Notions of subtyping appear when
using objects or so-called `polymorphic' variants.

James Woodyatt wrote:
> 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.

I don't think that's what Andreas meant. I think `pure' merely meant
`non-OO' here.

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

Isn't that a bit harsh? Monads offer abstraction with respect to the way
certain side effects are performed. Because of ocaml's natural support for
many side effects (references, exceptions, I/O, ...), monads are seldom
needed in ocaml. Furthermore, because of ocaml's lack of support for
overloading, their use is more cumbersome in ocaml than in Haskell.

Nevertheless, I am sure there are situations where abstracting your code
with respect to a monad is desirable. For instance, if you're writing
non-deterministic code, you may want the machinery that explores multiple
threads of evaluation, handles backtracking, etc. to be hidden inside a
monad.

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

Sounds perfectly OK.

-- 
François Pottier
Francois.Pottier@inria.fr
http://pauillac.inria.fr/~fpottier/
-------------------
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