Version française
Home     About     Download     Resources     Contact us    
Browse thread
Polymorphic variants question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Andres Varon <avaron@g...>
Subject: Re: [Caml-list] Polymorphic variants question

On Sep 2, 2006, at 7:16 AM, Jacques Garrigue wrote:

> Just that the concrete type is much simpler.
> The abstract type does not work directly, as you need a way to ensure
> that B.t and C.t are compatible. Otherwise, one could write
>
> module D = A(struct type t = [ `A of int] ... end)
>             (struct type t = [ `A of string] ... end)
>
> which is clearly incorrect.

I use a more restricted version of polymorphic variants to ensure  
that two functions that are being composed through a match in the  
style of the question do not share a tag (and so one function will  
not override the expected behavior of the second one), even if the  
tags are fully compatible; being this the case, your example cannot  
occur.

I am not an expert in programming languages, and I cannot see - in  
this restricted case - a reason why that functor could still be  
problematic. Is there some?

Thanks!

Andres