From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 5B73281799 for ; Sun, 28 Jul 2013 10:43:16 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of michipili@gmail.com) identity=pra; client-ip=74.125.83.44; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="michipili@gmail.com"; x-sender="michipili@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of michipili@gmail.com designates 74.125.83.44 as permitted sender) identity=mailfrom; client-ip=74.125.83.44; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="michipili@gmail.com"; x-sender="michipili@gmail.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@mail-ee0-f44.google.com) identity=helo; client-ip=74.125.83.44; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="michipili@gmail.com"; x-sender="postmaster@mail-ee0-f44.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: At0BAPHY9FFKfVMsjWdsb2JhbABawnQWDgEBAQEHCwsJEgYkglIRAgYBGx4DEhApNREBBQGIMgEDDwSYAIJ+jE+Cf4NpChknDWSHdAEFDJAOgwBvA48biESPZz+EPA X-IPAS-Result: At0BAPHY9FFKfVMsjWdsb2JhbABawnQWDgEBAQEHCwsJEgYkglIRAgYBGx4DEhApNREBBQGIMgEDDwSYAIJ+jE+Cf4NpChknDWSHdAEFDJAOgwBvA48biESPZz+EPA X-IronPort-AV: E=Sophos;i="4.89,763,1367964000"; d="scan'208";a="22550570" Received: from mail-ee0-f44.google.com ([74.125.83.44]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 28 Jul 2013 10:43:15 +0200 Received: by mail-ee0-f44.google.com with SMTP id c13so2361536eek.3 for ; Sun, 28 Jul 2013 01:43:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:from:to:content-type:content-transfer-encoding :mime-version:subject:date:x-mailer; bh=4fnjC+exMsYKelkIIoVnMMMlDP5QlFDAhKxQ2lyBb2k=; b=bUoRg1SjO4G0G2NXyIf/OJxkwLOd9y+hv8VikUrZZV/zkPCU/8D4/zh1gZxVXXpNQC 47QRuFQAPm+jGXoZiYN9hUKJ7wXXvxkygZdEQ9alH4QK9jTtKcgiwRpOx0jsZo8y0NvB Q2Diyq96YOYq1NGNZ9M5S3Hd0/dYooIlBgqAz86LzAa9BHkCZyvqQsr2zJyiuro+v+4r wnGcYH7hrLTOWK/SL06ezzNj34b83qWPL9+iF713MwdR6LAVHW44UrmL+KE25RKxiSTn M6kenaJoTQco+PLr44GIxXeLR4mB7pHo0bRwK80NtoC4XQs7rt5CzBT52cem59XaGq9I p+DA== X-Received: by 10.15.52.201 with SMTP id p49mr5994675eew.125.1375000995186; Sun, 28 Jul 2013 01:43:15 -0700 (PDT) Received: from medbh.celt.neu (xdsl-89-0-155-146.netcologne.de. [89.0.155.146]) by mx.google.com with ESMTPSA id n45sm93653091eew.1.2013.07.28.01.43.13 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 28 Jul 2013 01:43:14 -0700 (PDT) Message-Id: From: Michael To: caml-list@inria.fr Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v936) Date: Sun, 28 Jul 2013 10:43:12 +0200 X-Mailer: Apple Mail (2.936) Subject: [Caml-list] Writing Awk in OCaml Hi list! I am trying to write a Awk in OCaml and would like to write it as a variadic function. I have seen several examples of variadic functions in OCaml, but I am still unsure if it is possible. Maybe can someone help me to solve this? DEFINITION OF (MINI)-AWK (Mini)-Awk is a module with the following (probably wrong) signature: sig type 'a field type row = string array val make : int -> (string -> 'a) -> 'a field val get : 'a field -> row -> 'a val bind : (row -> 'a -> 'b) -> 'a field -> row -> 'b end With this signature [make 1 int_of_string] if a field [f] such that [get f row = int_of_string (row.(1))]. Now assume you have two fields f1 : int field and f2 : string field and two functions u : int -> state -> state and v : int -> string -> state -> state (where state is a random type). With the above signature, we can write (1) bind u f1: row -> state -> stat bind (bind v f1) f2 : row -> state -> stat But it would be quite nice to be able to write the following expressions so that they are defined and correctly type (2): bind u f1 : row -> state -> state bind v f1 f2 : row -> state -> state Is there any way to rewrite things so that the cumbersome (1) can be replaced by the slick (2) ? Thank you for your insight! Michael