hplayground 0.1.1.0 → 0.1.2.0
raw patch · 2 files changed
+19/−22 lines, 2 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Haste.HPlay.View: allOf :: (FormInput view, MonadIO m, Functor m, Monad (View view m)) => [View view m a] -> View view m [a]
+ Haste.HPlay.View: allOf :: [View Perch IO a] -> Widget [a]
- Haste.HPlay.View: validate :: (FormInput view, Monad m, Monad (View view m)) => View view m a -> (a -> WState view m (Maybe view)) -> View view m a
+ Haste.HPlay.View: validate :: Widget a -> (a -> WState Perch IO (Maybe Perch)) -> Widget a
Files
- hplayground.cabal +1/−1
- src/Haste/HPlay/View.hs +18/−21
hplayground.cabal view
@@ -1,5 +1,5 @@ name: hplayground -version: 0.1.1.0 +version: 0.1.2.0 cabal-version: >=1.8 build-type: Simple license: BSD3
src/Haste/HPlay/View.hs view
@@ -78,7 +78,7 @@ import Control.Concurrent.MVar import qualified Data.Map as M import Control.Monad.Trans.Maybe -import Prelude hiding(id) +import Prelude hiding(id,span) import Haste.Perch --import Debug.Trace @@ -144,12 +144,6 @@ let conf = process st case conf of EventF x' fs -> do --- let f' x = View $ do --- --- -- modify $ \s -> s{process= EventF (strip s $ f x) (unsafeCoerce fs) } --(unsafeCoerce $ tail fs) } --- runView $ f x - - let idx= strip st x put st{process= EventF idx ((f,id): unsafeCoerce fs) } return conf @@ -429,23 +423,26 @@ -- -- @getOdd= getInt Nothing `validate` (\x -> return $ if mod x 2==0 then Nothing else Just "only odd numbers, please")@ validate - :: (FormInput view, Monad m,Monad (View view m)) => - View view m a - -> (a -> WState view m (Maybe view)) - -> View view m a -validate formt val= do - mx <- View $ do - FormElm form mx <- runView formt - return $ FormElm form (Just mx) + :: Widget a + -> (a -> WState Perch IO (Maybe Perch)) + -> Widget a +validate w val= static $ do + idn <- genNewId + wraw $ span ! id idn $ noHtml + x <- w View $ do - case mx of - Just x -> do me <- val x case me of - Just str -> return $ FormElm (inred str) Nothing - Nothing -> return $ FormElm mempty mx - _ -> return $ FormElm mempty Nothing + Just str -> do + liftIO $ withElem idn $ build $ clear >> inred str + return $ FormElm mempty Nothing + Nothing -> do + liftIO $ withElem idn $ build $ clear + return $ FormElm mempty $ Just x + + + -- | Generate a new string. Useful for creating tag identifiers and other attributes. -- -- if the page is refreshed, the identifiers generated are the same. @@ -1021,7 +1018,7 @@ case r of EventF x fs -> do FormElm render mx <- runView w - let proc = runIt x (unsafeCoerce fs) >> return () -- runWidgetId (x >>= f)id >> return () + let proc = runIt x (unsafeCoerce fs) >> return () let nevent= evtName event :: String let putevdata dat= modifyMVar_ eventData $ const $ return dat let render' = case event of