caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: John Max Skaller <skaller@ozemail.com.au>
To: caml-list@inria.fr
Subject: [Caml-list] This is so nice ..
Date: Fri, 13 Jun 2003 17:23:28 +1000	[thread overview]
Message-ID: <3EE97BF0.8000005@ozemail.com.au> (raw)
In-Reply-To: <3EE8AC5E.6080409@ozemail.com.au>

I can hardly believe this works.
I copied this trick from Jacque's code

http://wwwfun.kurims.kyoto-u.ac.jp/~garrigue/papers/mixev3.04.ml.txt

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, mailto:skaller@ozemail.com.au
snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia.
voice:61-2-9660-0850


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2003-06-13  7:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-12 14:15 [Caml-list] How to find out if a function is tail recursive? Richard Jones
2003-06-12 14:31 ` Paul Steckler
2003-06-12 14:43   ` Luc Maranget
2003-06-12 16:15     ` John Max Skaller
2003-06-12 16:37       ` John Max Skaller
2003-06-13  7:23         ` John Max Skaller [this message]
2003-06-12 14:37 ` Wolfgang Müller
2003-06-12 14:49 ` Neel Krishnaswami
2003-06-12 15:14 ` Chris Uzdavinis
2003-06-12 15:33 ` Brian Hurt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3EE97BF0.8000005@ozemail.com.au \
    --to=skaller@ozemail.com.au \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).