Skip to content

liftIO in Widget causes strange behavior #8

@mpdairy

Description

@mpdairy

I'm working on a nifty way to do forms, which will also hopefully be able to handle text inputs that update every key press. However, I ran into my form elements returning some really weird results, and I narrowed it down to it being caused by widgets that have liftIO in them. For example, here's a Widget I made as I was trying to figure out the problem:

testNonStateT :: Widget HTML b
testNonStateT = forever $ do
  _ <- simStateT ("one", "two", "three")
  return ()
  where
    simStateT s = do
      r <- (do
               r <- inputEnter' $ s ^. _1
               liftIO $ print "hey there!"
               return $ s & _1 .~ r)
           <|>
           (do
               r <- inputEnter' $ s ^. _2
               liftIO $ print "hey there!"
               return $ s & _2 .~ r)
           <|>
           (do
               r <- inputEnter' $ s ^. _3
               liftIO $ print "hey there!"
               return $ s & _3 .~ r )
      liftIO $ print r
      simStateT r

inputEnter' :: String -> Widget HTML String
inputEnter' t = inputEnter [ A.value . JS.pack $ t ]

When I try this, the third one will work fine, but the second one gets the third input box's return value, and the first gets the second's. However, if I uncomment the liftIO $ print "hey there!" lines, it works fine.

I'm using Concur.VDOM.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions