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 2906C7FCEF for ; Thu, 2 Apr 2015 12:41:55 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of frederic.bour@lakaban.net) identity=pra; client-ip=213.251.185.180; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="frederic.bour@lakaban.net"; x-sender="frederic.bour@lakaban.net"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of frederic.bour@lakaban.net designates 213.251.185.180 as permitted sender) identity=mailfrom; client-ip=213.251.185.180; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="frederic.bour@lakaban.net"; x-sender="frederic.bour@lakaban.net"; 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.lakaban.net) identity=helo; client-ip=213.251.185.180; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="frederic.bour@lakaban.net"; x-sender="postmaster@mail.lakaban.net"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BbCwA2HB1V/7S5+9VTCYNaXIJPRsJJhXcCghEBAQEBAQF+QQGDXQEFDBcPAQUIAQE2Ag8JAhgCAgUWCwICCQMCAQIBRRMIAQGIL5dtnAxwhGIBBYFrkVkBCgEBAQEXBoEhigiEHWOCaIFFjmCBbIQYjRmNOiKDcG2CQwEBAQ X-IPAS-Result: A0BbCwA2HB1V/7S5+9VTCYNaXIJPRsJJhXcCghEBAQEBAQF+QQGDXQEFDBcPAQUIAQE2Ag8JAhgCAgUWCwICCQMCAQIBRRMIAQGIL5dtnAxwhGIBBYFrkVkBCgEBAQEXBoEhigiEHWOCaIFFjmCBbIQYjRmNOiKDcG2CQwEBAQ X-IronPort-AV: E=Sophos;i="5.11,510,1422918000"; d="scan'208";a="108041234" Received: from pepper.lakaban.net (HELO mail.lakaban.net) ([213.251.185.180]) by mail3-smtp-sop.national.inria.fr with ESMTP; 02 Apr 2015 12:41:54 +0200 Received: from [192.168.1.17] (mtg91-4-78-206-197-34.fbx.proxad.net [78.206.197.34]) (Authenticated sender: defre@ygg-drasil.fr) by mail.lakaban.net (Postfix) with ESMTPSA id 7472B3CDB06 for ; Thu, 2 Apr 2015 10:35:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=lakaban.net; s=default; t=1427970911; bh=DUY5xzWPTfKilcafMJ+dQwKPKu+xyR6LJ1Glh2CYvV0=; h=Date:From:Reply-To:To:Subject:References:In-Reply-To:From; b=Xpurz1vRZPiyo0E5VvT8psSa83179QvbAinrcU/exOsKUlOlhA3hgzci+dreR5ObE pIrOLlhgJgHLPsEH73WlZYHtFU1F3DxduP84S6mFXJBFez5GZ1prrm6GFIYCvKW00Q sUNvXvOCHH+3+iIgk8KlN+R43PidlvLdtU/MmEEg= Message-ID: <551D1C29.5010808@lakaban.net> Date: Thu, 02 Apr 2015 12:38:33 +0200 From: =?UTF-8?B?RnLDqWTDqXJpYyBCb3Vy?= Reply-To: =?UTF-8?B?RnLDqWTDqXJpYyBCb3Vy?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: caml-list@inria.fr References: <551C55F4.5080703@lakaban.net> In-Reply-To: <551C55F4.5080703@lakaban.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Caml-list] [ANN] OCamp - Reactive programming in the shell Code is finally available at: https://github.com/def-lkb/ocamp Sorry for the little delay! On 01/04/2015 22:32, Frédéric Bour wrote: > OCamp extends unix shells with constructions to express memoization, > sharing of computations and reactive programming. > > # Subcommands > > ## fire > > Just wrap a unix command with "ocamp fire" to enable the extension: > $ ocamp fire bash > > This will spawn a new bash session where the following subcommands are > enabled. > > ## hipp > > $ ocamp hipp > > Will memoize the output and exit status of . > Later calls to the same won't lead to actual execution, but > just to a duplication of its previous output. > Concurrent calls to will just share the same process, the > beginning of the output being replayed to later callers. > > The identity of a command is defined by its arguments and working > directory. > > ## stir > > $ ocamp stir > > Indicate potential changes in the output if was rerun. > Later calls to `hipp` will recompute as if it was not yet > memoized. > > ## (un)follow > > $ ocamp follow > > First, is memoized if it was not the case yet. > Then changes to dependencies of will trigger a reevaluation. > Use `stir` to notify a change. > > (to follow is an hipp/stir reactivity). > > ## pull > > $ ocamp pull > > Closely related to `hipp`, but instead of marking dependency on the > output of , the dependency applies to the "effects" of > . > > Thus, if `stir` is used: > - all pullers will be reevaluated. > - hippers will be reevaluated only if the output is different. > > ## Summary > > $ ocamp fire - setup a new session alive until > exits > pull - mark dependency on effects of > hipp - mark dependency on output of > stir - notify that might have been updated > follow - eval , and reactively recompute it > whenever one of its dependencies change. > unfollow - stop recomputing when > dependencies > change > > hipp and pull provide memoization. > stir and follow bring a flavor of reactive programming. > > # Examples > > ## Fibonacci > > $ cat fib.sh > #!/bin/sh > ARG="$1" > if [ "$ARG" -le 1 ]; then > echo "$ARG" > else > A=`ocamp hipp ./fib.sh $((ARG-1))` > B=`ocamp hipp ./fib.sh $((ARG-2))` > echo $((A+B)) > fi > > $ time ocamp fire ./fib.sh 50 > 12586269025 > real 0m0.391s > user 0m0.153s > sys 0m0.060s > > ## Build-system > > `ocamp` provides simple primitives to construct and manage a > dependency graph. > > This might be a saner foundation to base a build-system on than make(1): > - the command focus on one specific problem > - no dsl is involved; rules can be plain unix commands, including a > shell, rather than a make-flavored simulation of shell > - nothing is provided for resolving goals; indeed this is better left > to tools specifically built for goal-search. > > A quick'n'dirty script building ocamp itself is provided as an example. > > # Future > > The current release is a proof-of-concept and should be considered > alpha quality. > The two features planned next are a way to make the graph persistent > (all data is kept in memory atm) and an interface to debug and/or > observe graph construction. > > Note: code is undergoing legal review and should be available soon \o/ >