caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Pierre-Alexandre Voye <ontologiae@gmail.com>
To: caml-list <caml-list@inria.fr>
Subject: [Caml-list] Module inside an object
Date: Wed, 23 Apr 2014 11:50:00 +0200	[thread overview]
Message-ID: <CANnJ5GfrB_i14AH9eT1TPubcM-9garBPOPs+OvAWhk-q8jYfBg@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1987 bytes --]

Hello,
I would like to define a parameterized module inside an object by the type
of this object.


I have two module interlocked :

(* Parameters*)
module type A = sig
        type agent
        type intern_agent = { i : agent}
        val create : agent -> intern_agent
end

module type E = sig
        type event
end



module  type StateType = sig

  type agent
  type event

  type  state_t = {
    mutable name : string;
    mutable parentstate  :  state_t option;
  }
end


module State (A : A) (E : E) = struct

        type agent = A.agent
        type event = E.event
    type  state_t = {
            mutable name : string;
             mutable parentstate  :  state_t option;
    }


    (*...*)
end



module Agent (S : StateType) =
        struct
          type agent = S.agent
          type event = S.event
          type state_t = S.state_t

      type  agent_t = {
          mutable agent      : agent ;
      }

      let create a1   = {
          agent          = a1;
      }
end


(* An implementation of E*)
type event1 = Event1 | Event2;;
module E = struct type event = event1 end;;




What I would like to do is something like that (which is syntacticly
incorrect but represents what I would like to do) :


class  character = object (self :'self)
 val mutable position        = (0,0)
 val agent                         =
                let A = (module Ag  = struct
                                type agent = 'self
                                type intern_agent = { i : agent}
                                let create a = { i = a }
                              end)
                     in
                let Ag = (module Agent(State(A)(E)) ) in
                Ag.create self

 method getPosition          = position

end;;



How can I write this to be able to define a value which is an Agent
parametrized by itself ?

Thank you,

-- 
Pierre-Alexandre Voye
---------------------
https://twitter.com/#!/ontologiae/
http://linuxfr.org/users/montaigne

[-- Attachment #2: Type: text/html, Size: 2890 bytes --]

             reply	other threads:[~2014-04-23  9:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-23  9:50 Pierre-Alexandre Voye [this message]
2014-04-24 14:44 ` Goswin von Brederlow

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=CANnJ5GfrB_i14AH9eT1TPubcM-9garBPOPs+OvAWhk-q8jYfBg@mail.gmail.com \
    --to=ontologiae@gmail.com \
    --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).