From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 5321D7EF28 for ; Fri, 26 Jun 2015 08:34:32 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of bmillwood@janestreet.com) identity=pra; client-ip=38.105.200.112; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="bmillwood@janestreet.com"; x-sender="bmillwood@janestreet.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of bmillwood@janestreet.com designates 38.105.200.112 as permitted sender) identity=mailfrom; client-ip=38.105.200.112; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="bmillwood@janestreet.com"; x-sender="bmillwood@janestreet.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mxout1.mail.janestreet.com) identity=helo; client-ip=38.105.200.112; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="bmillwood@janestreet.com"; x-sender="postmaster@mxout1.mail.janestreet.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0AoAgCK8YxVnHDIaSZbg2VfBoMYqnKOWoIPAQmFeAKBLwdMAQEBAQEBEgEBAQEBBhYJT4QiAQEBAwESER0BASwLAQQLCwsNDR0CAiISAQUBChIGExIQh3gDCggDCqtKPjGKT3CEZAEFi2MDhX0BAQEBAQEBAQIBAQEBAQEBAQEBEgYKi0CFAgQHgi07EoExhV8KjiKEWIZ6gTpCkmGCERIjgRYRBoQKboJIAQEB X-IPAS-Result: A0AoAgCK8YxVnHDIaSZbg2VfBoMYqnKOWoIPAQmFeAKBLwdMAQEBAQEBEgEBAQEBBhYJT4QiAQEBAwESER0BASwLAQQLCwsNDR0CAiISAQUBChIGExIQh3gDCggDCqtKPjGKT3CEZAEFi2MDhX0BAQEBAQEBAQIBAQEBAQEBAQEBEgYKi0CFAgQHgi07EoExhV8KjiKEWIZ6gTpCkmGCERIjgRYRBoQKboJIAQEB X-IronPort-AV: E=Sophos;i="5.13,682,1427752800"; d="scan'208";a="137920094" Received: from mxout1.mail.janestreet.com ([38.105.200.112]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 26 Jun 2015 08:34:31 +0200 Received: from tot-qpr-mailcore2.delacy.com ([172.27.56.106] helo=tot-qpr-mailcore2) by mxout1.mail.janestreet.com with esmtps (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.82) (envelope-from ) id 1Z8NDZ-0003zY-90 for caml-list@inria.fr; Fri, 26 Jun 2015 02:34:29 -0400 X-JS-Flow: external Received: by tot-qpr-mailcore2 with JS-mailcore (0.1) (envelope-from ) id BVjPJ1-AAAH1G-HR; 2015-06-26 02:34:29.233504-04:00 Received: from mail-qk0-f171.google.com ([209.85.220.171]) by mxgoog1.mail.janestreet.com with esmtps (UNKNOWN:AES128-GCM-SHA256:128) (Exim 4.72) (envelope-from ) id 1Z8NDZ-00075S-4k for caml-list@inria.fr; Fri, 26 Jun 2015 02:34:29 -0400 Received: by qkhu186 with SMTP id u186so50726140qkh.0 for ; Thu, 25 Jun 2015 23:34:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=OWnom9hKxTohnydFe1eDK9MmNsGc7bUj/GKVxjNNIT0=; b=dC5XiD/O3ZD4nlX06fCuwLUrS/IETq1ESt4ZlO7j86XeFTbtI2a0v6fZo5Aid9+vBI NN0GElLHXs3XYsZWRHASJG9/0Jo+1ycfXATkVapZJfGPUJBX77ICYAWDjaCZ8Nq5FV/9 hyW1JTPC3TS9aidSVgIY0fsrjgznHsAEY5cTo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=OWnom9hKxTohnydFe1eDK9MmNsGc7bUj/GKVxjNNIT0=; b=V/9Oj3AF2Ec8qyux6b0+V/X9/+Hdw+T6IMY5LF4kUJ58phRcurv/QKVEiuLt+WGiQD qSGKLxritJSnTAeY55u3r7NmKzCMpfjj+B5+vNWHZWIaO93djtSpgsSsSuAICef4sM2s H9BG1Tk7gAdHUfDsP0EnrSyBk+e5KS0SmZbj2ONpm3uve6rm7qT2zqUBb8LVI34KnpH4 J68V840iLg3PMkBdVLzIXjWYzqdrmoSYsUjxQKWpZ+/JzeICr+7LrgvRKztbX7SKgvgA f+BrG55AxFPtfUqOOQQ8tBRbBGPSSiEzn/MBN2SH6K9VPs3O1FDcDA8uORjvq8hHiBx3 RpCg== X-Gm-Message-State: ALoCoQmaGVf08diqNkKb0RQCYsX20JptbUOZCaOkL56OWFG3T1AP99sum3F0XDmifXWiPNGEj6X/SSxTE5h2lGqZQ2DSwfYTFOi5STtUqYwxb3358hUZ4HfKwCRs5NWTsg0RojTK3r1v X-Received: by 10.140.108.6 with SMTP id i6mr41018qgf.73.1435300468896; Thu, 25 Jun 2015 23:34:28 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.140.108.6 with SMTP id i6mr41011qgf.73.1435300468756; Thu, 25 Jun 2015 23:34:28 -0700 (PDT) Received: by 10.96.223.194 with HTTP; Thu, 25 Jun 2015 23:34:28 -0700 (PDT) In-Reply-To: <558BB3F4.4050209@inria.fr> References: <558BB3F4.4050209@inria.fr> Date: Fri, 26 Jun 2015 07:34:28 +0100 Message-ID: From:Ben Millwood To:Francois Berenger Cc:caml users Content-Type: multipart/alternative; boundary=001a113a6d6e963022051965eeea X-JS-Processed-by: mailcore Subject: Re: [Caml-list] Core Overlay --001a113a6d6e963022051965eeea Content-Type: text/plain; charset=UTF-8 Core does not have its own list type, only its own list functions. ['a Core.Std.List.t] is equal to ['a list], and the compiler only tells you one or the other based on its heuristics for what would be most useful for you to hear (which can't be right every time). Opening Core.Std at the beginning of your program is still the recommended way to use Core, but you can also do something less invasive like just using Core.Std.List.map directly. You may also find it useful that Core's List.map takes a named argument ~f, whereas the standard List.map can't do that (although ListLabels.map can). On 25 June 2015 at 08:55, Francois Berenger wrote: > Just an idea, maybe you can put 'open Core.Std' (I'm not sure that's > anymore the correct way to use Core but ...) on top of each > ml file of the project, then try to recompile it like that. > > I guess you will then have many compilation errors that > will force you to fix code to use Core's version of everything. > After that, very few non tail rec. functions should remain > in the code base. > > > On 06/24/2015 06:02 PM, Kenneth Adam Miller wrote: > >> I'm trying to upgrade a library that has a lot of existing code that >> makes calls to List.map; the core overlay is really nice, and I'd like >> to make use of a tail recursive implementation because that much is >> pretty much imperative. >> >> I've refactored the code of the library to make sure that the compiler >> identifies the list and the operation types being from Core.List, >> recompiled, opam pinned the project. But I keep getting blowups. I've >> executed the code in gdb, and gotten a backtrace with the stack overflow >> and I can see that it's still going to List.map. >> >> So I'm thinking it has to be one of a few errors: >> >> I've fixed it, but it's linking against a different, older version of >> the library. >> * Problem with this is, the makefile generates ocamlfind calls, and >> those resolve the package correctly. I've check the file dates, removed >> the packages and readded them a multi-tude of times. Unless there's some >> invisible /usr/local compiler selection over the opam stuff despite it >> being specifically pointed there, I don't see how this could be. But I >> could be wrong. >> >> I've fixed the library some, but it some how resolves to a Pervasives >> type that's not tail recursive somewhere in the library that I missed. >> * I still don't see how this could be. I'm looking in the gdb backtrace, >> and I can see where it flows from my code into the library-the library. >> I've tracked the naming convention down to the exact function definition >> and checked via Emacs Merlin that it's the type it should be. >> >> >> I've fixed the library correctly, but somehow a mismatch between >> pervasives and Core definitions causes some fallback to the pervasives >> via some kind of invisible typing rules or language specifics that I >> don't know about. >> * Maybe, but wouldn't the compiler complain if it expected a >> Core.Std.List.t and got a list instead? >> > > -- > Regards, > Francois. > "When in doubt, use more types" > > -- > 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 > --001a113a6d6e963022051965eeea Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Core does not have its own list type, only its own list fu= nctions. ['a Core.Std.List.t] is equal to ['a list], and the compil= er only tells you one or the other based on its heuristics for what would b= e most useful for you to hear (which can't be right every time).
Opening Core.Std at the beginning of your program is still the= recommended way to use Core, but you can also do something less invasive l= ike just using Core.Std.List.map directly. You may also find it useful that= Core's List.map takes a named argument ~f, whereas the standard List.m= ap can't do that (although ListLabels.map can).

On 25 June 2015 at 08:55, F= rancois Berenger <francois.berenger@inria.fr> wrote= :
Just an idea, maybe you can put 'op= en Core.Std' (I'm not sure that's
anymore the correct way to use Core but ...) on top of each
ml file of the project, then try to recompile it like that.

I guess you will then have many compilation errors that
will force you to fix code to use Core's version of everything.
After that, very few non tail rec. functions should remain
in the code base.


On 06/24/2015 06:02 PM, Kenneth Adam Miller wrote:
I'm trying to upgrade a library that has a lot of existing code that
makes calls to List.map; the core overlay is really nice, and I'd like<= br> to make use of a tail recursive implementation because that much is
pretty much imperative.

I've refactored the code of the library to make sure that the compiler<= br> identifies the list and the operation types being from Core.List,
recompiled, opam pinned the project. But I keep getting blowups. I've executed the code in gdb, and gotten a backtrace with the stack overflow
and I can see that it's still going to List.map.

So I'm thinking it has to be one of a few errors:

I've fixed it, but it's linking against a different, older version = of
the library.
* Problem with this is, the makefile generates ocamlfind calls, and
those resolve the package correctly. I've check the file dates, removed=
the packages and readded them a multi-tude of times. Unless there's som= e
invisible /usr/local compiler selection over the opam stuff despite it
being specifically pointed there, I don't see how this could be. But I<= br> could be wrong.

I've fixed the library some, but it some how resolves to a Pervasives type that's not tail recursive somewhere in the library that I missed.<= br> * I still don't see how this could be. I'm looking in the gdb backt= race,
and I can see where it flows from my code into the library-the library.
I've tracked the naming convention down to the exact function definitio= n
and checked via Emacs Merlin that it's the type it should be.


I've fixed the library correctly, but somehow a mismatch between
pervasives and Core definitions causes some fallback to the pervasives
via some kind of invisible typing rules or language specifics that I
don't know about.
* Maybe, but wouldn't the compiler complain if it expected a
Core.Std.List.t and got a list instead?

--
Regards,
Francois.
"When in doubt, use more types"

--
Caml-list mailing list.=C2=A0 Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocam= l_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

--001a113a6d6e963022051965eeea--