I have the following program:
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecursiveDo #-}
module Main where
import Control.FRPNow
import Control.Monad.Trans.Class
import Data.Bool
import Data.Char
import Francium
import Francium.Components.Form.Input
import Francium.HTML
import Francium.Hooks
import GHCJS.Foreign
import GHCJS.Types
import VirtualDom
one
:: String -> Behavior Bool -> Now (HTML Behavior (), EvStream String)
one label hasFocus =
do (clickHook,clicks) <- newClickHook
return (do suffix <-
fmap (bool "" "!")
(lift hasFocus)
div_ (applyHooks clickHook)
(do text (toJSString label)
suffix)
,label <$ clicks)
main :: IO ()
main =
react (mdo (item1,focus1) <-
one "One" (fmap ("One" ==) focus)
(item2,focus2) <-
one "Two" (fmap ("Two" ==) focus)
focus <-
sample (fromChanges "One"
(merge focus1 focus2))
return (do item1
item2))
Unfortunately it's quite deeply tied to work I'm doing, and not a standalone example. It shows two HTML <div> elements that can be clicked, which changes the focused element. It begins with "One" having focus.
If I use the Hackage release, I can click "Two" which immediately gives it focus. From that point on, rendering always seems to lag a frame behind - meaning I have to click "One" twice to shift focus back to "One".
If I change memoB to be the same as id, then the behavior changes. Now, I have to click on "Two" twice, right from the start, in order for it to have focus, rather than once as observed previously.
Neither of these do what I expect (it should only require a single click to change focus), but the fact that the behavior has changed makes me think that memoB and memoE are not semantically acting as identity.
In both programs a single click does cause a re-render, but it appears that the behavior containing the rendered view of each element ("One!" or "Two!") changes after the composed rendering (do item1 ; item2) is observed to change. This is probably a separate bug, and I'm trying to work out what's going on with that next.
I have the following program:
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecursiveDo #-} module Main where import Control.FRPNow import Control.Monad.Trans.Class import Data.Bool import Data.Char import Francium import Francium.Components.Form.Input import Francium.HTML import Francium.Hooks import GHCJS.Foreign import GHCJS.Types import VirtualDom one :: String -> Behavior Bool -> Now (HTML Behavior (), EvStream String) one label hasFocus = do (clickHook,clicks) <- newClickHook return (do suffix <- fmap (bool "" "!") (lift hasFocus) div_ (applyHooks clickHook) (do text (toJSString label) suffix) ,label <$ clicks) main :: IO () main = react (mdo (item1,focus1) <- one "One" (fmap ("One" ==) focus) (item2,focus2) <- one "Two" (fmap ("Two" ==) focus) focus <- sample (fromChanges "One" (merge focus1 focus2)) return (do item1 item2))Unfortunately it's quite deeply tied to work I'm doing, and not a standalone example. It shows two HTML
<div>elements that can be clicked, which changes the focused element. It begins with "One" having focus.If I use the Hackage release, I can click "Two" which immediately gives it focus. From that point on, rendering always seems to lag a frame behind - meaning I have to click "One" twice to shift focus back to "One".
If I change
memoBto be the same asid, then the behavior changes. Now, I have to click on "Two" twice, right from the start, in order for it to have focus, rather than once as observed previously.Neither of these do what I expect (it should only require a single click to change focus), but the fact that the behavior has changed makes me think that
memoBandmemoEare not semantically acting as identity.In both programs a single click does cause a re-render, but it appears that the behavior containing the rendered view of each element ("One!" or "Two!") changes after the composed rendering (
do item1 ; item2) is observed to change. This is probably a separate bug, and I'm trying to work out what's going on with that next.