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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by sympa.inria.fr (Postfix) with ESMTPS id 3E45B7EDC2 for ; Wed, 21 Nov 2012 03:58:26 +0100 (CET) Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of bobzhang1988@gmail.com) identity=pra; client-ip=209.85.220.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="bobzhang1988@gmail.com"; x-sender="bobzhang1988@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail4-smtp-sop.national.inria.fr: domain of bobzhang1988@gmail.com designates 209.85.220.182 as permitted sender) identity=mailfrom; client-ip=209.85.220.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="bobzhang1988@gmail.com"; x-sender="bobzhang1988@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-vc0-f182.google.com) identity=helo; client-ip=209.85.220.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="bobzhang1988@gmail.com"; x-sender="postmaster@mail-vc0-f182.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqoCAD9CrFDRVdy2m2dsb2JhbABEwk4IFg4BAQEBAQgJCwkUJ4IeAQEBAwEBAQE1CAEbHAEBAwwGBQsNCRYPCQMCAQIBDwIRAQUBHAYNAQUCAQEXh18BAwkGoF6MMYFugQqFDwoZJw1ZiHUBBQyLP4VLA4hchTSGGYFVgRyKFoMvP4Qu X-IronPort-AV: E=Sophos;i="4.83,290,1352070000"; d="scan'208";a="163214945" Received: from mail-vc0-f182.google.com ([209.85.220.182]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 21 Nov 2012 03:58:25 +0100 Received: by mail-vc0-f182.google.com with SMTP id fo13so12536940vcb.27 for ; Tue, 20 Nov 2012 18:58:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:newsgroups:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=dtf0OOGCkifexnuwx7Rw6w4Fxux+8u9wJ13urTcTCTU=; b=aDmO81+XmpI81V5YhLVj2KXZg/cF/n3auMCSw9W+28FjaeAHNwPMnuTk8FuTGDMTJ3 eiiMj4Vp6Ldnl3mZPAPRIhn/4iE6d/qlWHZE9uGEcivS3/cUtYwo8fuBaeXQQY8awKDz bQACd6GyugH/+5pWXYUgR+xTdQ1a+FffJKKcnpx5cMf0EWRJxVSeqWfwjQI4mjfm5D64 f2mmJz/U6w3c83JI/PteOJCjHbdzuBZq3TBaTKIFxvYNqj1IE/OgnMA6ON6ls1E1HhBh JlKtZv3Gi7yT6372dFN34xyRe+R6UrkCK33Mot+ByfByPPefgfdcHeL39tmAfeKi1byv jcaA== Received: by 10.58.137.7 with SMTP id qe7mr25134914veb.23.1353466704255; Tue, 20 Nov 2012 18:58:24 -0800 (PST) Received: from bobzhangs-iMac.local ([66.250.143.158]) by mx.google.com with ESMTPS id cz16sm8528784vdb.15.2012.11.20.18.58.22 (version=SSLv3 cipher=OTHER); Tue, 20 Nov 2012 18:58:23 -0800 (PST) Message-ID: <50AC434D.8080508@gmail.com> Date: Tue, 20 Nov 2012 21:58:21 -0500 From: bobzhang User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 MIME-Version: 1.0 Newsgroups: gmane.comp.lang.caml.inria To: Wojciech Meyer CC: Caml List References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Caml-list] Re: How to add a hook to Stream.junk? On 11/20/12 8:35 PM, Wojciech Meyer wrote: > bob zhang writes: > >> Hi List, >> Does anyone know any trick to add a hook to Stream.junk, I have >> tried different ways, but did not find any solution, yet >> I want to trigger an action each time when I junk a token from the >> stream. (copy the whole file from stdlib is fine, but I don't >> know how to make the type checker happy :-() >> -- >> Regards >> -- Bob > Greetings, > You can parametrise the Stream.t type with your desired type and the > hook. > > Then you can substitute type using destructive substitution of a type: > > module Stream : module type of Stream with type 'elt t := ('hook, 'elt) > CustomStream.t = Stream > > Finally you can implement your own CustomStream.junk function that > operates on the parametrised type and include the CustomStream module. > > This should work, but I've not tested or compiled it. > Stream specialized on char stream :-( > -- > Wojciech Meyer > http://danmey.org >