<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/11/a67170a9ced404324482eedfe2026978"
  from="Ville-Pertti Keinonen &lt;will@e...&gt;"
  author="Ville-Pertti Keinonen"
  date="2003-11-20T10:45:53"
  subject="Re: [Caml-list] Recursive apply function"
  prev="2003/11/94d3362b05f025d593538a0c9478ebd5"
  next="2003/11/fe1cf8257b6ab7bf556c839001ef56c6"
  prev-in-thread="2003/11/a98ffd2d35498010d7a28ae7289a6827"
  prev-thread="2003/11/a2140a10ae8f0fe8f4ff398f0fbd2ddc"
  next-thread="2003/11/200096eaceaa7d8ec65f137c52c25c57"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Recursive apply function">
<msg 
  url="2003/11/7e7da260aa46285715d49921794fa6a1"
  from="Peter Scott &lt;sketerpot@c...&gt;"
  author="Peter Scott"
  date="2003-11-20T03:32:19"
  subject="[Caml-list] Recursive apply function">
<msg 
  url="2003/11/461606c4d3157a5a76a31d3c6191a03b"
  from="Aleksey Nogin &lt;nogin@c...&gt;"
  author="Aleksey Nogin"
  date="2003-11-20T04:42:14"
  subject="Re: [Caml-list] Recursive apply function">
</msg>
<msg 
  url="2003/11/a98ffd2d35498010d7a28ae7289a6827"
  from="Brian Hurt &lt;bhurt@s...&gt;"
  author="Brian Hurt"
  date="2003-11-20T06:32:12"
  subject="Re: [Caml-list] Recursive apply function">
</msg>
<msg 
  url="2003/11/a67170a9ced404324482eedfe2026978"
  from="Ville-Pertti Keinonen &lt;will@e...&gt;"
  author="Ville-Pertti Keinonen"
  date="2003-11-20T10:45:53"
  subject="Re: [Caml-list] Recursive apply function">
</msg>
</msg>
</thread>

<contents>
On Wed, Nov 19, 2003 at 08:54:08PM -0700, Peter Scott wrote:

&gt; first element of the list. Unfortunately, I get this message when run: 
&gt; "This expression has type 'a but is here used with type 'b -&gt; 'a", 
&gt; referring to the "(f arg)" part.

You can get your "apply" function to typecheck using the -rectypes option,
but it still doesn't do what you want; it only accepts functions that
return functions of the same (recursive) type.

Static typing prevents things like Lisp apply from being implemented
even for the limited case where arguments have the same type.  The type
of a partially applied function is almost never identical to the fully
applied function (except for the case of recursively typed functions that
return functions, such as your "apply").

Note that the -rectypes option is probably not something you want to use
unless you know that you need it.  An example is if you want to have a
state machine with functions representing states without resorting to
side-effects (f : event -&gt; action * 'a as 'a).

-------------------
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

</contents>

</message>

