From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 7B939BC37 for ; Wed, 9 Dec 2009 19:33:05 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvYBALJ7H0vRVd7Li2dsb2JhbACULIZ1PwEBAQoLCgcRBaxwMIUrIohHAQIDBYQnBIsm X-IronPort-AV: E=Sophos;i="4.47,369,1257116400"; d="scan'208";a="41701432" Received: from mail-pz0-f203.google.com ([209.85.222.203]) by mail1-smtp-roc.national.inria.fr with ESMTP; 09 Dec 2009 19:33:04 +0100 Received: by pzk41 with SMTP id 41so7655869pzk.0 for ; Wed, 09 Dec 2009 10:33:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type:content-transfer-encoding; bh=657Vvi9vNBZQ7zwhQMzrNm29QITeZvnPttXUYb0AOWk=; b=rg056VMDtohKLaWEo2ZReD6PW0r4cYZiniMKj7c28mVL76A4O7+VsR5vcYPOGjbfgK fFg8vZxxeBzHfKkI2e/LVpUwRXJYAHYpzIfA/IgYvwXyCLjFEQncCalN4QGJElHDoTVm RdAZ/HpPfHelqKezbx9RolgJmqiZQrrivQ/xo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=ABw24KnIRY0d7XKTl0R6/0z7GTlvXNcapIrQ/W3MGBFDoYYui/LPq0FPuFPiAIdPuj dve3vrWoS9MI3Vd2cD5FscK0cjRyiIbOjQa5RVvxKPAtxZO8TdiMuwBRD0MCcjBEnrV/ Ndkw1EjIju5hDerc2JAL+xguR6n3RlyX+C11A= MIME-Version: 1.0 Sender: aaron678@gmail.com Received: by 10.143.154.29 with SMTP id g29mr1356780wfo.267.1260383583681; Wed, 09 Dec 2009 10:33:03 -0800 (PST) In-Reply-To: <91a3da520912090843n451b5592x27105b353ef7c65b@mail.gmail.com> References: <91a3da520912090843n451b5592x27105b353ef7c65b@mail.gmail.com> Date: Wed, 9 Dec 2009 13:33:03 -0500 X-Google-Sender-Auth: 7a8a283839d760d5 Message-ID: Subject: Re: more on frp (was Re: [Caml-list] Re: Recursion on React.events) From: Aaron Bohannon To: =?ISO-8859-1?Q?Daniel_B=FCnzli?= Cc: Richard Jones , OCaml List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; recursion:01 bunzli:01 buenzli:01 occurences:01 combinator:01 occurence:01 occurence:01 occurences:01 semantics:01 semantics:01 2009:98 wrote:01 upenn:01 caml-list:01 semantic:02 On Wed, Dec 9, 2009 at 11:43 AM, Daniel B=FCnzli wrote: >> Personally I've yet to read any comprehensible introduction to FRP. > In fact events and signals are duals. One can be implemented in terms > of the other (signals can be seen as the event occurences of its value ch= anges), > However it makes sense to keep the two concepts separate (code > clarity, efficiency issues, semantic details with comparison). > Suppose we want to remember the last keysym that was issued. That's a > signal, it is defined at any point in time. For that the S.hold > combinator can be used, it remembers the last occurence of an event : > > =A0let last_keysym =3D S.hold null_keysym keydown > > Each time keydown gets an occurence S.hold updates the signal with the > new occurence value. null_keysym is used to initalize the signal (it > needs a value at the time it is created and the keydown event may not > give us one at that time). > > Now we would like to concatenate the stream of keychar occurences into > a string. Your example perfectly illustrates what makes understanding FRP hard: when I type the string "programming", should I expect to get a signal with a value of "programming" or "programing"? Signals without events have an semantics that seems straightforward (to me). But I have very little intuition for events, as represented by a type such as "time -> 'a option", and their conversion to and from signals. Also, I like the idea of making different choices for what "time" is, but doesn't the semantics of FRP depend on time being continuous? - Aaron