caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Brian Hurt <bhurt@spnz.org>
To: Jonathan Roewen <jonathan.roewen@gmail.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Type inference problem
Date: Tue, 1 Nov 2005 10:21:05 -0600 (CST)	[thread overview]
Message-ID: <Pine.LNX.4.63.0511011019160.1006@localhost.localdomain> (raw)
In-Reply-To: <ad8cfe7e0510312358qb5d7fd5s78f3487ce9fac6f7@mail.gmail.com>



On Tue, 1 Nov 2005, Jonathan Roewen wrote:

> Hi,
>
> I can't figure out what's wrong with my code =(
>
> It's on a paste site, so will only last about 24 hours or so.
> http://rafb.net/paste/results/Uux57B97.html
>
> jonathan@moonbeam:~/dst/stdlib$ ocamlc VFS.ml
> File "VFS.ml", line 106, characters 3-6:
> This expression has type int but is here used with type unit
>
> It -has- to return int ;-) But I have no idea where the type
> constraint is coming from that wants it to return unit. Change it to
> return unit, and where it's used complains it doesn't return type int
> (so that constraint is correct).

A general tactic I use in cases like this is to add type annotations. 
What is almost certainly happening is that somewhere else before this line 
in your code you are returning unit as a value, so Ocaml thinks it's 
supposed to return unit.  If you add a type annotation to explicitly state 
that it returns int, Ocaml will instead give an error where you return 
unit, allowing you to fix the problem.

Brian


  parent reply	other threads:[~2005-11-01 16:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-01  7:58 Jonathan Roewen
2005-11-01  8:19 ` Jonathan Roewen
2005-11-01  8:50   ` skaller
2005-11-01  8:34 ` skaller
2005-11-01 16:21 ` Brian Hurt [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-06-28 15:23 Vasilij Karpow
2001-06-28 15:40 ` Remi VANICAT
2001-06-28 19:08 ` Nils Goesche
2001-06-29  2:41 ` Jacques Garrigue

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=Pine.LNX.4.63.0511011019160.1006@localhost.localdomain \
    --to=bhurt@spnz.org \
    --cc=caml-list@yquem.inria.fr \
    --cc=jonathan.roewen@gmail.com \
    /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).