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] How to find out if a function is tail recursive?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: John Max Skaller <skaller@o...>
Subject: [Caml-list] This is so nice ..
I can hardly believe this works.
I copied this trick from Jacque's code

Thanks! This is really great stuff.
I feel like a dill: its exactly the same
as the parameterised class trick I already
knew about.

type 'a s1 = [`A | `B of 'a]
type  'a s2 = ['a s1 | `C]

type ss1 = 'a s1 as 'a
type ss2 = 'a s2 as 'a

let rec reduce : ss2 -> ss1 = function
     | `A -> `A
     | `B z -> `B (reduce z)
     | `C -> raise Not_found

reduce (`B `C);;

John Max Skaller,
snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia.

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: