caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jeffrey Scofield <jeffsco@psellos.com>
To: caml-list@inria.fr
Subject: [Caml-list] Re: Strange behavior of mutualy recursive definitions
Date: 28 Apr 2011 01:24:33 -0500	[thread overview]
Message-ID: <m3zknavqou.fsf@pse.psellos.com> (raw)
In-Reply-To: <20110428040550.GB9733@yeeloong.happyleptic.org>

rixed@happyleptic.org writes:

> Why 'let rec f = f' is rejected is clear: you cannot type f.

In my thinking, f is typeable with type 'a (fully general type).
I don't think it's untypeable, it just doesn't have a useful type.
It's similar to the type of failwith : string -> 'a, but without
the string.

In Haskell the equivalent definition has useful purposes.
It represents "bottom" (erroneous computation).  In a strict
language you can't have such a value hanging around, seems
like.  So in OCaml you have failwith instead (a lazy version of an
erroneous computation).

So to me it makes sense that it's rejected not on typing but on
other grounds.

It's also worth noting that

    let rec f x = f x

is just a shorthand for

    let rec f = fun x -> f x

This also is typeable with type 'a -> 'b.  Again this isn't a
very useful type, but there's no problem with this value in a strict
language, because the lambda ("fun") essentially makes it lazy.

Jeffrey


  reply	other threads:[~2011-04-28  6:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-27 20:46 [Caml-list] " rixed
2011-04-27 20:54 ` Guillaume Yziquel
2011-04-27 21:28   ` rixed
2011-04-27 21:51     ` Guillaume Yziquel
2011-04-28  4:05       ` rixed
2011-04-28  6:24         ` Jeffrey Scofield [this message]
2011-04-28  8:45           ` [Caml-list] " Guillaume Yziquel
2011-04-28  8:57             ` rixed
     [not found]       ` <244248468.756230.1303963610378.JavaMail.root@zmbs4.inria.fr>
2011-04-28  7:26         ` [Caml-list] " Fabrice Le Fessant
2011-04-28  8:53           ` rixed

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=m3zknavqou.fsf@pse.psellos.com \
    --to=jeffsco@psellos.com \
    --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).