caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Chris Quinn <cq@htec.demon.co.uk>
To: Matteo Frigo <athena@fftw.org>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Problem with polymorphic letrec
Date: Wed, 19 Sep 2001 20:10:11 +0100	[thread overview]
Message-ID: <3BA8ED93.1D80A49E@htec.demon.co.uk> (raw)
In-Reply-To: <m3d74qhmf8.fsf@glauke.fftw.org>

> 
> let rec polymul mul p q =
>    polymul (polymul mul) (fun _ -> p) (fun _ -> q)
> 
> This expression does not typecheck in ocaml 2 because polymul is used
> polymorphically within its own body.
> 
> I could not come up with any hack to code polymul without changing the
> representation of polynomials, which I'd rather not change for other
> reasons.
> 
> Any suggestion on how to work around this problem?

You can certainly get the polymorphism back by abstracting out
the main functionality:

let rec polymul_aux f mul p q =
   f (f mul) (fun _ -> p) (fun _ -> q)

then :
let polymul = polymul_aux polymul_f

But maybe, ultimately, that will not be the problem!

I don't know if it has any relevance at all but the -rectypes
flag can sometimes help.
For instance:

type key
type 'data map = (key * ('data * 'data map)) list

This is a type which will not typecheck without -rectypes
but it is definitely meaningful and useful to me!

Chris Q.
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


  reply	other threads:[~2001-09-19 19:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-16 21:10 Matteo Frigo
2001-09-19 19:10 ` Chris Quinn [this message]
2001-09-24  6:25 ` Tyng-Ruey Chuang

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=3BA8ED93.1D80A49E@htec.demon.co.uk \
    --to=cq@htec.demon.co.uk \
    --cc=athena@fftw.org \
    --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).