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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 4075B7EE34 for ; Sun, 27 Mar 2016 08:20:40 +0200 (CEST) IronPort-PHdr: 9a23:nYdumhbnQYH1lImdh+7fZpn/LSx+4OfEezUN459isYplN5qZpcm5bnLW6fgltlLVR4KTs6sC0LqG9fq6EjZdvN6oizMrTt9lb1c9k8IYnggtUoauKHbQC7rUVRE8B9lIT1R//nu2YgB/Ecf6YEDO8DXptWZBUiv2OQc9HOnpAIma153xjLDivceJKF8V2XKUWvBbElaflU3prM4YgI9veO4a6yDihT92QdlQ3n5iPlmJnhzxtY+a9Z9n9DlM6bp6r5YTGfayQ6NtRrVdCHw7KG0v/4W/vhDGSU6L52AAemQQiBtBRQbfukLURJD05wTgu+V6wjjSGMTyQLs0UHz24KJiTBLjiC4vODsw8WWRgct12vEI6Cm9rgByltaHKLqeM+BzK/vQ Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=gmalecha@gmail.com; spf=Pass smtp.mailfrom=gmalecha@gmail.com; spf=None smtp.helo=postmaster@mail-ob0-f177.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of gmalecha@gmail.com) identity=pra; client-ip=209.85.214.177; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="gmalecha@gmail.com"; x-sender="gmalecha@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of gmalecha@gmail.com designates 209.85.214.177 as permitted sender) identity=mailfrom; client-ip=209.85.214.177; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="gmalecha@gmail.com"; x-sender="gmalecha@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-ob0-f177.google.com) identity=helo; client-ip=209.85.214.177; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="gmalecha@gmail.com"; x-sender="postmaster@mail-ob0-f177.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0CJAAAXe/dWi7HWVdFdhH4GqEIEA4cpinQBDYFwhycHOBQBAQEBAQEBARABAQEICwsJHzGCLYItEQQZARseAxIDDTcCJAERAQUBIhsTB4dvAQMSkxeNOoIHgTE+MYs2gWqCV4YxChknDVGEQQEFCgWFF3iMAIJWBY4whFaEW4hjhSOPC41NER6BDx4BAYJWgXEcMIhWAQEB X-IPAS-Result: A0CJAAAXe/dWi7HWVdFdhH4GqEIEA4cpinQBDYFwhycHOBQBAQEBAQEBARABAQEICwsJHzGCLYItEQQZARseAxIDDTcCJAERAQUBIhsTB4dvAQMSkxeNOoIHgTE+MYs2gWqCV4YxChknDVGEQQEFCgWFF3iMAIJWBY4whFaEW4hjhSOPC41NER6BDx4BAYJWgXEcMIhWAQEB X-IronPort-AV: E=Sophos;i="5.24,399,1454972400"; d="scan'208,217";a="210475725" Received: from mail-ob0-f177.google.com ([209.85.214.177]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 27 Mar 2016 08:20:15 +0200 Received: by mail-ob0-f177.google.com with SMTP id fp4so80877045obb.2 for ; Sat, 26 Mar 2016 23:20:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to; bh=XiubgAi4xMlFwRw1hQrSMNgchLBsaTmwFT77YRaCW04=; b=pzJ807rqDjzGMbjiL3OUesLitWz5HT7H+L7tYZr2r/g94oj+Tr/ex29n08Fuascxqd T0U8ugS6tgpK1RA45g8w/Q8bAbSIC7iJS54IAxrGUnQkLgQo66aW1613iVMIW6obi9f3 SxtfSy4amhSs19TjKT2UhG+T7LElqr2/a/7y84g4Go8aNaay0VhPQq28OLQxmlDxOCWb TkFIy8+EWTZkmVCell5Do+cT/6/RYlWFM+PrqHHnunC8tkhSyB0kyFVvDHi7NWpS5e0/ cULyhNW5rRIu43eEHsSOs6zxVlT9PZOKw8G1LhMhqTVIdHo1TuVXZecykn8SArwXUHFp ICGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=XiubgAi4xMlFwRw1hQrSMNgchLBsaTmwFT77YRaCW04=; b=TGKtrQMte2n2vKj8VM/YRh22f8pwwl5KrS8O1tCUxl/cR8yXkUKGEHwNKuJxO5NHzr LWiItu7geNHCNjnz1Jbi7stJzrb2uQUlHDuSb4tJSWLvX3GKymcyAd6ykidJw2gQdl26 ryEP3nKuwY+A9JvrN3i3ONE/psFuqFUdjWYi3Nl4yy086ZAHFexWqOVyY5NyjcCP7rAg LvSrd6IApYPZLsO/wCN3qNdGxb38F3lp5+ad5q0zjZUnSDkzlRPFrSWmGOqppnjb7p8o w15kqy6HyicAxtSHQtiYEaOP1DYEw/LQWNDH+dRrtWsnjwvmcsOlUue43GSPNs4J3POD zKzg== X-Gm-Message-State: AD7BkJKEI+P3924eG8a6VgS7lhc13MiqO1HLUfP3mgFAV1argAx6HHlwRYdgGo5TzW4VA8W9Xv2BUkoAnps2Lw== X-Received: by 10.182.24.8 with SMTP id q8mr9505750obf.67.1459059613697; Sat, 26 Mar 2016 23:20:13 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.19.43 with HTTP; Sat, 26 Mar 2016 23:19:34 -0700 (PDT) From: Gregory Malecha Date: Sat, 26 Mar 2016 23:19:34 -0700 Message-ID: To: caml users Content-Type: multipart/alternative; boundary=001a11c24b38fb268f052f01c9d9 Subject: [Caml-list] "Type constructor b would escape its scope" --001a11c24b38fb268f052f01c9d9 Content-Type: text/plain; charset=UTF-8 Hello -- I've encountered a typing error that I'm not sure how to track down. I assume that what I'm doing is running up against the limitations of the type system, so I assume there is some technical detail that I am missing. Here's my problem: I have defined the following type: (* essentially the eliminator for lists *) type ('a,'b) result_stream = ('a -> ('a,'b) result_stream -> 'b) -> (unit -> 'b) -> 'b (* I have the following function, which seems to type check *) let stream_declarations (type a) : (internal_result,a) result_stream = ... (* I am unable to implement this function *) let generic_search_stream (type b) (glnumopt : int option) : (internal_result, b) result_stream = stream_declarations Ocaml complains with the following error message: Error: This expression has type (internal_result, b) result_stream = (internal_result -> (internal_result, b) result_stream -> b) -> (unit -> b) -> b but an expression was expected of type (internal_result, b) result_stream = (internal_result -> (internal_result, b) result_stream -> b) -> (unit -> b) -> b The type constructor b would escape its scope Since the types match up exactly, I can only assume that this has something to do with the type declaration (type b) but I can't see what is wrong. My expectation is that the scope of [b] ends at the end of the [generic_search_stream] function and is used as the type parameter to [stream_declarations], this seems to not be the case though. Wondering if OCaml requires arguments in order to instantiate polymorphic functions, I tried to eta-expand the definition as follows: let generic_search_stream (type b) (glnumopt : int option) : (internal_result, b) result_stream = fun cons nil -> stream_declarations cons nil With this code, the "error" is with 'cons' and says: Error: This expression has type internal_result -> (internal_result, b) result_stream -> b but an expression was expected of type internal_result -> (internal_result, b) result_stream -> b Type (internal_result, b) result_stream = (internal_result -> (internal_result, b) result_stream -> b) -> (unit -> b) -> b is not compatible with type (internal_result, b) result_stream = (internal_result -> (internal_result, b) result_stream -> b) -> (unit -> b) -> b The type constructor b would escape its scope Essentially the same error, but it doesn't seem to lead me to any potential solutions. Can someone explain this error to me? Thanks. -- gregory malecha --001a11c24b38fb268f052f01c9d9 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hello --

I've encountered a typing = error that I'm not sure how to track down. I assume that what I'm d= oing is running up against the limitations of the type system, so I assume = there is some technical detail that I am missing. Here's my problem:

I have defined the following type:
(* essentially the eliminat= or for lists *)
t= ype ('a,'b) result_stream =3D
=C2=A0 ('a -> ('a,'b) result_stream -> &#= 39;b) ->
=C2=A0 (un= it -> 'b) -> 'b

(* = I have the following function, which seems to type check *)
let stream_declarations (type a)=
: (internal_result,a)= result_stream =3D ...

(* I am unable t= o implement this function *)
let generic_search_stream (type b) (glnumopt : int option)
: (internal_result, b) res= ult_stream =3D
=C2=A0 = stream_declarations

Ocaml complains w= ith the following error message:

Error: This expression has type
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(inte= rnal_result, b) result_stream =3D
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(internal_result ->= (internal_result, b) result_stream -> b) ->
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(unit= -> b) -> b
=C2= =A0 =C2=A0 =C2=A0 =C2=A0but an expression was expected of type
=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= (internal_result, b) result_stream =3D
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(internal_result = -> (internal_result, b) result_stream -> b) ->
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= (unit -> b) -> b
=C2=A0 =C2=A0 =C2=A0 =C2=A0The type constructor b would escape its scope

=
Since the types match up e= xactly, I can only assume that this has something to do with the type decla= ration (type b) but I can't see what is wrong. My expectation is that t= he scope of [b] ends at the end of the [generic_search_stream] function and= is used as the type parameter to [stream_declarations], this seems to not = be the case though.

Won= dering if OCaml requires arguments in order to instantiate polymorphic func= tions, I tried to eta-expand the definition as follows:

let generic_search_stream (type b) (glnumopt = : int option)
: (inter= nal_result, b) result_stream =3D
=C2=A0 fun cons nil -> stream_declarations cons nil

With this code, the "err= or" is with 'cons' and says:

Error: This expression has type
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0internal_result -> (i= nternal_result, b) result_stream -> b
=C2=A0 =C2=A0 =C2=A0 =C2=A0but an expression was expecte= d of type
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0internal_result -> (internal_result, b) result_s= tream -> b
=C2=A0 = =C2=A0 =C2=A0 =C2=A0Type
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(internal_result, b) result_stream =3D=
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0(internal_result -> (internal_result, b) result_stre= am -> b) ->
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(unit -> b) -> b
=C2=A0 =C2=A0 =C2=A0 =C2=A0is not co= mpatible with type
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(internal_result, b) result_stream =3D
=C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0(internal_result -> (internal_result, b) result_stream -&g= t; b) ->
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(unit -> b) -> b=C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0The type c= onstructor b would escape its scope

Essentially the same error, but it doesn't seem to lead= me to any potential solutions.

Can someone = explain this error to me?

Thanks.

--
gregory malecha
--001a11c24b38fb268f052f01c9d9--