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
Retyping module to a new signature
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jean-Marie Gaillourdet <jmg@i...>
Subject: Re: [Caml-list] Retyping module to a new signature
Hash: SHA1


On 28.06.2006, at 12:49, Piotr Wieczorek wrote:

> Hi!
> I'm trying for quite a time, to make patch to Ocaml compiler which  
> makes possible taking a bytecompiled module and producing identical  
> module but conforming to a new signature.
> I've used some code from bytepackager to calculate coercion and  
> copy bytecode from original module to target one.
> It works ok. But if order of functions in target signature is  
> different then in source signature, calling a function may cause  
> not running right one, but another.
> Can you tell me what may I be doing wrong, or wether what i'm  
> trying to accomplish is possible.

Why do you try do that in the first place? Let us assume you have a  
module Foo which is stored in byte code file foo.cmo, which was  
compiled frome the file
- -- --
let foo x y= x + y

let bar x = x
- ------------

If you want to constraint Foo to a module Bar which includes only the  
first function you could use the following source:
- -- bar.mli ----
val foo : int -> int -> int
- ---------------
- -- -----
include Foo
- ---------------

I compiled everything with:

$ ocamlc
$ ocamlc bar.mli
$ ocamlc foo.cmo

The first step is in your step eventually not necessary, because you  
wanted to start with a binary module.
Hope this helps.

Best regards,

Version: GnuPG v1.4.1 (Darwin)