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
Re: [Caml-list] type abbreviation is cyclic
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-10-25 (11:23)
From: William Smith <sesquized@s...>
Subject: Re: [Caml-list] type abbreviation is cyclic

I was just writing the simplest example of the recursive definition.   I 
didn't know about -recftypes.

The distilled version of the actual case follows

type b = ((tree -> bool) * (b-> tree ->  int)) list

The first function of each pair determines whether the second function 
will be called.   The second function recurses over the subtrees, 
possibly with different b control lists as their first argument.  My 
actual example is more complex because of the details of the tree, but I 
think this is gives the flavor of what I'm trying to do. (snd b) can 
pass different list's into subtrees when it recurses.  

The actual example gets messier because another argument to snd b is a 
function that can use different rules to choose a row (or rows) from b.

It's the recursion that can happen is related to the technique of 
writing recursive functions without using let rec..

let f1 it a1 b2 = ...
let f2 it a1 b2 = ....
let f3 it a1 b2 = ...

let items = [f1; f2; f3]

let x =  f1 items a b...

Till Varoquaux wrote:

Type b doesn't exactly make much sens to me.
While I could easilly define a value of type b (fun x:int _ -> x ) I
really don't see the point. I'm gessing you'r trying to pass a chain
of alternative functions (In which case this seems to be the  wrong
Could you give an exemple (without using Obj.magic) were you'd
actually need such a type.
On 10/24/07, William W Smith <> wrote:

I wonder whether this error is an example of the language being defined more
restrictively than required.  What is the reason that I get these results?

type a  = int -> one -> int and one = Unused | One of a;;
type b = int -> b -> int

type a is accepted while type b is not. (b gives "The type abbreviation b is
cyclic"  However, in the uses that I intended, there won't be any actual
difference between the two.

I'd appreciate an explanation about why there is difference  between a and


Bill Smith