Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion Generalized tagRec?

View parsed - Show only message text

Received: by 10.142.166.10 with SMTP id o10mr261338wfe.2.1244113519379;
        Thu, 04 Jun 2009 04:05:19 -0700 (PDT)
Return-Path: <artyom.shalkha...@gmail.com>
Received: from mail-pz0-f175.google.com (mail-pz0-f175.google.com [209.85.222.175])
        by gmr-mx.google.com with ESMTP id 18si970198pzk.2.2009.06.04.04.05.18;
        Thu, 04 Jun 2009 04:05:18 -0700 (PDT)
Received-SPF: pass (google.com: domain of artyom.shalkha...@gmail.com designates 209.85.222.175 as permitted sender) client-ip=209.85.222.175;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of artyom.shalkha...@gmail.com designates 209.85.222.175 as permitted sender) smtp.mail=artyom.shalkha...@gmail.com; dkim=pass (test mode) header...@gmail.com
Received: by mail-pz0-f175.google.com with SMTP id 5so321259pzk.14
        for <flapjax@googlegroups.com>; Thu, 04 Jun 2009 04:05:18 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:mime-version:received:date:message-id:subject
         :from:to:content-type:content-transfer-encoding;
        bh=6aYIThX2Tx5fDm96LIhbF3EGm7lJFejTkEs2rG3gqPM=;
        b=Znvm9JB+rdVZM5zesgtLyRUrTIHwOmvSOY2KbWeilxffcCadPCqg6NW2Eh+o+owRPE
         bxBD99nWKa/pEyfwhk7DE3l0WNhHQ+ik3k/nNGxj4kZWFl7vyWIMqcewV7Gc6DW6CZgI
         rE67QwfiThUkKUUBJ+5TRiH5FQTppjXSI0ES8=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=mime-version:date:message-id:subject:from:to:content-type
         :content-transfer-encoding;
        b=I9sxQDOA3or8y+nYX3R1WqjWzR5XnrH0J4JtU7FZv13+RthgC4KHqAodWQERdj0cic
         TASCtJYxPASkSP//xk9Jy3JxkeUyzUJay4hlhUgs2Q0DvKjXAyNBAuyeqk1xChL3oChS
         2K18ssmXrKsHS6JbUVFV8M/whbImsDP1aY55s=
MIME-Version: 1.0
Received: by 10.143.4.11 with SMTP id g11mr845538wfi.340.1244113516734; Thu, 
	04 Jun 2009 04:05:16 -0700 (PDT)
Date: Thu, 4 Jun 2009 17:05:16 +0600
Message-ID: <2076f2f90906040405x760e99fdj94d6ca4c4300b4ca@mail.gmail.com>
Subject: Generalized tagRec?
From: Artyom Shalkhakov <artyom.shalkha...@gmail.com>
To: flapjax@googlegroups.com
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

Hello,

I was writing a small file browser in Flapjax and have encountered
a problem with tagRec: there seems to be no way to make one
dynamically created tag to depend on another dynamically created
tag's events.

What I would like to achieve is a tree with branches that
can be shown or hidden.

The tree (or rather, a forest) for testing is the parse tree of an expression
a + b * c, which is translated to JS as follows:

> [{label: 'plus', children: [
>       {label: 'a', children: []},
>       {label: 'multiply', children: [
>            {label: 'b',children: []},
>            {label: 'c',children: []}]}]}]

Here's how it is converted to HTML:

> // fun :: Forest * Maybe Hash -> Dom
> function fun(y,vis) {
>     return UL(vis || {}, map(function(x) {
>          return tagRec(['click'],
>              function(e) {
>                  var db = toggleE('block','none',e).startsWith('block');
>                  return LI(A({href:'#'+x.label},x.label),
>                                 fun(x.children, {style: {display: db}}));
>              });
>     }, y));
> }

toggleE is defined as follows:

> function toggleE(a,b,e) {
>    return e.collectE(true, function(_,y) {
>        return !y;
>    }).mapE(function(x) {return x? a : b;});
> }

The tree behaves unexpectedly, because tagRec reacts to *all*
events happening inside a LI, while it should only react to events
of A.

I think I can come up with a hack but would like to write in the
most obvious (and declarative :-)) way possible.

Could anybody help me, please?

Cheers,
Artyom Shalkhakov.

PS here's a demo: http://www.sound-city.kz/fj/tree.html

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google