caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Anil Madhavapeddy <anil@recoil.org>
To: Jean Saint-Remy <jeansaintremy@yahoo.com>
Cc: Gabriel Kerneis <gabriel@kerneis.info>,
	"caml-list@inria.fr" <caml-list@inria.fr>
Subject: Re: [Caml-list] applying labled argument error
Date: Sat, 9 Nov 2013 10:42:21 -0800	[thread overview]
Message-ID: <E5DD89FC-CA5E-40CF-ABE6-FABE22B7777E@recoil.org> (raw)
In-Reply-To: <1384019828.3098.YahooMailNeo@web160502.mail.bf1.yahoo.com>

Dear Jean,

Please do go through the installation instructions at:
https://realworldocaml.org/install

The Real World OCaml tutorials assume that you use the "utop" toplevel rather than than the standard toplevel.  You also need to "open Core.Std" at the beginning of the toplevel to ensure that you're using the Core standard library.

So you need:

$ utop
# open Core Std ;;
# let sum list = 
  let sum  = ref 0 in 
  List.iter list ~f:(fun x -> sum := !sum + x);
  !sum ;;
val sum : int list -> int = <fun> 

It's possible to use the standard OCaml toplevel if you really want to, but you need to manually configure several settings that Utop sets by default (short-paths, and evaluation of Async Deferred.t values at the toplevel).

best,
Anil

On 9 Nov 2013, at 09:57, Jean Saint-Remy <jeansaintremy@yahoo.com> wrote:

> Hi,
> 
> I've been working out some of the examples in the https://realworldocaml.org/v1/en/html/a-guided-tour.html, which does utilize JaneStreet 'core' library. The new ocaml website is very impressive, as it allows you to dive right in into very fascinating idiomatic ocaml expressions. Just launching ocaml toplevel though is not enough. 
> 
> let sum list = 
>   let sum  = ref 0 in 
>   List.iter list ~f:(fun x -> sum := !sum + x);
>   !sum ;;
> -: Error: The function applied to this argument has type 'a list -> unit
>    This argument cannot be applied with label ~f
> 
> Jean
> 
> 
> On Saturday, November 9, 2013 5:07 AM, Gabriel Kerneis <gabriel@kerneis.info> wrote:
> On Fri, Nov 08, 2013 at 07:33:35PM -0800, Jean Saint-Remy wrote:
> > I am running ocaml 3.12.1 and getting an error message. Is it an incompatible
> > version error or a missing 'core' module?
> 
> Since you mention 'core', are you learning OCaml with "Real-World OCaml" (and
> hence trying to use JaneStreet's Core library instead of the standard one)?
> That would explain the discrepancy you are seeing.
> 
> 
> Best,
> 
> -- 
> Gabriel
> 
> -- 
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
> 
> 
> 


      parent reply	other threads:[~2013-11-09 18:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-09  3:33 Jean Saint-Remy
2013-11-09  4:27 ` Eric Cooper
2013-11-09 10:07 ` Gabriel Kerneis
2013-11-09 17:57   ` Jean Saint-Remy
2013-11-09 18:39     ` Anthony Tavener
2013-11-09 18:42     ` Anil Madhavapeddy [this message]

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=E5DD89FC-CA5E-40CF-ABE6-FABE22B7777E@recoil.org \
    --to=anil@recoil.org \
    --cc=caml-list@inria.fr \
    --cc=gabriel@kerneis.info \
    --cc=jeansaintremy@yahoo.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).