Version française
Home     About     Download     Resources     Contact us    
Browse thread
any types in signatures of functor arguments
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Brian Hurt <bhurt@s...>
Subject: Re: [Caml-list] any types in signatures of functor arguments


On Mon, 24 Oct 2005, Keiko Nakata wrote:

> Hello.
>
> Why I cannot have *any types* in signatures of functor arguments?
> Concretely, the following F is not typable.
>
> module F(X:sig type t = [`A of _ ] val f : t -> int end) =
>  struct
>    let f = function `A x as a -> X.f a | `B -> 0
>  end

I think the problem is that `A holds something, but you're not giving 
Ocaml any idea of what.  For example, the following compiles:

module F(X:sig type 'a t = [`A of 'a ] val f : 'a t -> int end) =
   struct
     let f = function `A x as a -> X.f a | `B -> 0
   end

Hope this helps.

Brian