Version française
Home     About     Download     Resources     Contact us    
Browse thread
module type...
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Pietro Abate <Pietro.Abate@a...>
Subject: module type...
Hi all,
I've a problem that boils down to this code below.

If I define
			
(* -------------- *)
module TermType =
    struct
        type t = int
        let copy t = t
        let to_string t = "this is a string"
    end
;;

let l : TermType.t list = [1;2];;

(* -------------- *)

everything is ok. and I get 
val l : TermType.t list = [1; 2]

but if I define:

(* -------------- *)
module type ElType =
    sig
        type t
        val copy : t -> t
        val to_string : t -> string
    end
;;
module TermType : ElType =
    struct
        type t = int
        let copy t = t
        let to_string t = "this is a string"
    end
;;
let l : TermType.t list = [1;2];;

(* -------------- *)

now the compiler tells me that:

This expression has type int but is here used with type TermType.t

but TermType.t should be unified with int...

why ? I can I solve this problem ?

and an other small question... why functor sigs are not defined in the std
library (ie for the Set.Make module ?)

thanks.

p

-- 
++ "All great truths begin as blasphemies." -George Bernard Shaw
++ Please avoid sending me Word or PowerPoint attachments.
   See http://www.fsf.org/philosophy/no-word-attachments.html