caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Ivan Gotovchits <ivg@ieee.org>
To: oleg@okmij.org
Cc: Didier.Cassirame@gmail.com,  caml-list@inria.fr
Subject: [Caml-list] Re: Higher order functors over tuples
Date: Mon, 12 Nov 2012 10:29:53 +0400	[thread overview]
Message-ID: <87wqxrtjtq.fsf@golf.niidar.ru> (raw)
In-Reply-To: <20121106114823.63702.qmail@www1.g3.pair.com> (oleg@okmij.org's message of "6 Nov 2012 11:48:23 -0000")


oleg@okmij.org writes:
> That seems to be the right problem for existentials -- which exist in
> OCaml under the name of objects. Methods are the interface and fields
> are private data. Of course we can get by with mere records -- but if
> we have objects anyway we might as well use them.

Yes, but objects suffer from two slight problems: lower performance due
to dynamic method dispatching and some issues with type system. Well,
not an issues really, but I think that you understood me. Though it
seems that this problems do not outweight the power of object system,
that was gracefully demonstrated by you.

In my real application I do shifted to objects. Though I still define
modules and then use functors as factories, producing objects of the
particular types. I'm not sure that this dual solution worths, but I
feel myself more comfortable with modules, rather than objects.

And, by the way, I've met the following signatures many times in
different frameworks written in different languages (matlab functional
objects, GnuRadio blocks, to name a few):

>>    module type Generator =
>>    sig
>>      type t
>>      type r
>>      val create: unit  -> t
>>      val result: t -> r option
>>      val step:   t -> t option
>>    end

extended with Transformer and Consumer:

  module type Consumer = 
  sig 
    type t
    type d
    val push: d -> t -> t
    val step: t -> t option
  end

  module type Transformer =
  sig
    type t
    type d
    type r
    val push: d -> t -> t
    val step: t -> t option
    val result: t -> r option
    (* or include Transformer and Consumer in ocaml 3.12+ *)        
  end

Haven't you seen this pattern in functional programming? May be it can
be expressed in a more natural way using FP idioms?


-- 
         (__) 
         (oo) 
   /------\/ 
  / |    ||   
 *  /\---/\ 
    ~~   ~~   
...."Have you mooed today?"...

  reply	other threads:[~2012-11-12  6:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-06 11:48 [Caml-list] " oleg
2012-11-12  6:29 ` Ivan Gotovchits [this message]
2012-11-13  8:19   ` [Caml-list] " oleg
2012-11-15  3:17     ` Ivan Gotovchits

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=87wqxrtjtq.fsf@golf.niidar.ru \
    --to=ivg@ieee.org \
    --cc=Didier.Cassirame@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=oleg@okmij.org \
    /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).