From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id FAA01892; Tue, 14 Oct 2003 05:03:00 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id FAA03467 for ; Tue, 14 Oct 2003 05:02:59 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h9E32v104795 for ; Tue, 14 Oct 2003 05:02:57 +0200 (MET DST) Received: from localhost (suiren.kurims.kyoto-u.ac.jp [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.9.3p2-20030924/3.7W) with ESMTP id MAA07260; Tue, 14 Oct 2003 12:02:46 +0900 (JST) To: oleg_trott@columbia.edu Cc: nick.name@inwind.it, caml-list@inria.fr Subject: Re: [Caml-list] Is arrow programming impossible in ocaml? In-Reply-To: <200310132133.13347.oleg_trott@columbia.edu> References: <200310140159.20515.nick.name@inwind.it> <200310132133.13347.oleg_trott@columbia.edu> X-Mailer: Mew version 1.94.2 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20031014120246F.garrigue@kurims.kyoto-u.ac.jp> Date: Tue, 14 Oct 2003 12:02:46 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 jacques:01 oleg:01 oleg:01 haskell:01 faq:01 3.07:01 3.07:01 covariant:01 covariant:01 jacques:01 semantics:01 ocaml:01 ocaml:01 caml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: Oleg Trott > On Monday 13 October 2003 07:59 pm, Nick Name wrote: > > Hi all, I am trying to work on a project where I need ocaml efficiency > > with rank-2 polymorphism, if I got it correctly (I am not an expert in > > programming language semantics). > > > > Basically I am trying to reproduce FRAN-like usage of arows as in > > > > http://haskell.cs.yale.edu/yampa/AFPLectureNotes.pdf > > > > so I have defined my own arrow module etc, but I faced the rank-1 > > polymorphism restriction of ocaml. I have cut down my example to: Looking at your example, this doesn't seem to be a problem with rank-2 polymorphism, but just one instance of the value restriction. (See the FAQ on caml.inria.fr) > > - > > type ('a,'b) t = 'a -> 'b > > > > let rec arr f = f > > > > let a = arr (fun x -> x) > > - > > > > and "a" is typed like '_a -> '_a , where I would like it to be typed 'a > > -> 'a. > > I think OCaml 3.07 makes this possible Unfortunately, no. OCaml 3.07 recovers polymorphism only if 'a appears only in covariant positions, and here it appears in both covariant and contravariant position. But as long as you represent arrows by normal functions (as this seems to be the case in the paper), eta-expanding should solve the problem. let a y = arr (fun x -> x) y Not also that there is no problem if Arr is a constructor: type ('a,'b) = Arr of ('a -> 'b) let a = Arr (fun x -> x) Jacques Garrigue ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners