hplayground 0.1.0.4 → 0.1.0.5
raw patch · 3 files changed
+126/−122 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Haste.HPlay.View: instance Typeable1 MFOption
+ Haste.HPlay.View: instance Typeable MFOption
- Haste.HPlay.Cell: boxCell :: (Read a, Show a, Typeable a) => String -> Cell a
+ Haste.HPlay.Cell: boxCell :: (Typeable * a, Show a, Read a) => ElemID -> Cell a
- Haste.HPlay.View: (<!) :: (Monad m, FormInput v) => View v m a -> Attribs -> View v m a
+ Haste.HPlay.View: (<!) :: (FormInput v, Monad m) => View v m a -> Attribs -> View v m a
- Haste.HPlay.View: allOf :: (Monad (View view m), Functor m, MonadIO m, FormInput view) => [View view m a] -> View view m [a]
+ 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: delSessionData :: (Typeable a, MonadState m, ~ * (StateType m) MFlowState) => a -> m ()
+ Haste.HPlay.View: delSessionData :: (MonadState m, Typeable * a, (~) * (StateType m) MFlowState) => a -> m ()
- Haste.HPlay.View: getBool :: (Monad (View view m), Functor m, MonadIO m, FormInput view) => Bool -> String -> String -> View view m Bool
+ Haste.HPlay.View: getBool :: (FormInput view, MonadIO m, Functor m, Monad (View view m)) => Bool -> String -> String -> View view m Bool
- Haste.HPlay.View: setRadioActive :: (Eq a, Show a, Typeable a) => a -> String -> Widget (Radio a)
+ Haste.HPlay.View: setRadioActive :: (Typeable * a, Show a, Eq a) => a -> String -> Widget (Radio a)
- Haste.HPlay.View: setSessionData :: (Typeable a, MonadState m, ~ * (StateType m) MFlowState) => a -> m ()
+ Haste.HPlay.View: setSessionData :: (MonadState m, Typeable * a, (~) * (StateType m) MFlowState) => a -> m ()
Files
- hplayground.cabal +51/−51
- src/Haste/HPlay/Cell.hs +73/−70
- src/Main.hs +2/−1
hplayground.cabal view
@@ -1,51 +1,51 @@-name: hplayground-version: 0.1.0.4-cabal-version: >=1.8-build-type: Simple-license: BSD3-license-file: LICENSE-maintainer: agocorona@gmail.com-stability: experimental-bug-reports: https://github.com/agocorona/hplayground/issues-synopsis: a client-side haskell framework that compiles to javascript with the haste compiler-description: Formlets with reactive effects in the client side. See homepage--homepage: https://github.com/agocorona/hplayground-category: Web-author: Alberto Gómez Corona-data-dir: ""-extra-source-files: src/Main.hs, src/Main.html--source-repository head- type: git- location: http://github.com/agocorona/hplayground--Flag Haste-inst- Description: either if it is being compiled with haste-inst or with cabal- Default: False---library- hs-source-dirs: src .- exposed-modules: Haste.HPlay.View Haste.HPlay.Cell- if flag(haste-inst)- build-depends: base >4.0 && <5, transformers -any,- containers -any, data-default -any, monads-tf,- haste-lib -any, haste-perch -any- else- build-depends: base >4.0 && <5, transformers -any,- containers -any, data-default -any, monads-tf,- haste-compiler -any, haste-perch -any-------executable Main--- build-depends: base >4.0 && <5, transformers -any, monads-tf -any,--- containers -any, data-default -any,--- haste-lib -any, haste-perch--- main-is: Main.hs--- buildable: True--- hs-source-dirs: src .--+name: hplayground +version: 0.1.0.5 +cabal-version: >=1.8 +build-type: Simple +license: BSD3 +license-file: LICENSE +maintainer: agocorona@gmail.com +stability: experimental +bug-reports: https://github.com/agocorona/hplayground/issues +synopsis: a client-side haskell framework that compiles to javascript with the haste compiler +description: Formlets with reactive effects in the client side. See homepage + +homepage: https://github.com/agocorona/hplayground +category: Web +author: Alberto Gómez Corona +data-dir: "" +extra-source-files: src/Main.hs, src/Main.html + +source-repository head + type: git + location: http://github.com/agocorona/hplayground + +Flag Haste-inst + Description: either if it is being compiled with haste-inst or with cabal + Default: False + + +library + hs-source-dirs: src . + exposed-modules: Haste.HPlay.View Haste.HPlay.Cell + if flag(haste-inst) + build-depends: base >4.0 && <5, transformers -any, + containers -any, data-default -any, monads-tf, + haste-lib -any, haste-perch -any + else + build-depends: base >4.0 && <5, transformers -any, + containers -any, data-default -any, monads-tf, + haste-compiler -any, haste-perch -any + + + + +--executable Main +-- build-depends: base >4.0 && <5, transformers -any, monads-tf -any, +-- containers -any, data-default -any, +-- haste-lib -any, haste-perch +-- main-is: Main.hs +-- buildable: True +-- hs-source-dirs: src . + +
src/Haste/HPlay/Cell.hs view
@@ -1,70 +1,73 @@------------------------------------------------------------------------------------ Module : Cell--- Copyright :--- License : BSD3------ Maintainer : agocorona@gmail.com--- Stability : experimental--- Portability :------ |-----------------------------------------------------------------------------------module Haste.HPlay.Cell where-import Haste.HPlay.View-import Control.Monad.IO.Class-import Haste-import Data.Typeable-import Unsafe.Coerce---data Cell a = Cell { mk :: Maybe a -> Widget a- , setter :: a -> IO()- , getter :: IO a}----instance Functor Cell where--- fmap f cell = cell{setter= \c x -> c .= f x, getter = \cell -> get cell >>= return . f}----boxCell id = Cell{ mk= \mv -> getParam (Just id) "text" mv- , setter= \ x -> withElem id $ \e -> setProp e "value" (show1 x)- , getter= withElem id $ \e -> getProp e "value" >>= return . read1}- where- show1 x= if typeOf x== typeOf (undefined :: String)- then unsafeCoerce x- else show x- read1 s= if typeOf s== typeOf (undefined :: String)- then unsafeCoerce s- else read s--(.=) cell x = liftIO $ (setter cell ) x--get cell = liftIO $ getter cell---(..=) cell cell'= get cell' >>= (.=) . cell--infixr 0 .=, ..=---- experimental: to permit cell arithmetic--instance Num a => Num (Cell a) where- c + c'= Cell undefined undefined $- do r1 <- get c- r2 <- get c'- return $ r1 + r2-- c * c'= Cell undefined undefined $- do r1 <- get c- r2 <- get c'- return $ r1 * r2-- abs c= c{getter= get c >>= return . abs}-- signum c= c{getter= get c >>= return . signum}-- fromInteger i= Cell undefined undefined . return $ fromInteger i-+----------------------------------------------------------------------------- +-- +-- Module : Cell +-- Copyright : +-- License : BSD3 +-- +-- Maintainer : agocorona@gmail.com +-- Stability : experimental +-- Portability : +-- +-- | +-- +----------------------------------------------------------------------------- + +module Haste.HPlay.Cell where +import Haste.HPlay.View +import Control.Monad.IO.Class +import Haste +import Data.Typeable +import Unsafe.Coerce + + +data Cell a = Cell { mk :: Maybe a -> Widget a + , setter :: a -> IO() + , getter :: IO a} + +--instance Functor Cell where +-- fmap f cell = cell{setter= \c x -> c .= f x, getter = \cell -> get cell >>= return . f} + + + +boxCell id = Cell{ mk= \mv -> getParam (Just id) "text" mv + , setter= \ x -> withElem id $ \e -> setProp e "value" (show1 x) + , getter= get} + where + show1 x= if typeOf x== typeOf (undefined :: String) + then unsafeCoerce x + else show x + + get= r where r= withElem id $ \e -> getProp e "value" >>= return . read + read1 s= if typeOf(typeIO r) /= typeOf (undefined :: String) + then read s + else unsafeCoerce s + typeIO :: IO a -> a + typeIO = undefined + +(.=) cell x = liftIO $ (setter cell ) x + +get cell = liftIO $ getter cell + +(..=) cell cell'= get cell' >>= (.=) . cell + +infixr 0 .=, ..= + +-- experimental: to permit cell arithmetic + +instance Num a => Num (Cell a) where + c + c'= Cell undefined undefined $ + do r1 <- get c + r2 <- get c' + return $ r1 + r2 + + c * c'= Cell undefined undefined $ + do r1 <- get c + r2 <- get c' + return $ r1 * r2 + + abs c= c{getter= get c >>= return . abs} + + signum c= c{getter= get c >>= return . signum} + + fromInteger i= Cell undefined undefined . return $ fromInteger i +
src/Main.hs view
@@ -220,7 +220,8 @@ mouse :: Widget () mouse= do- wraw (div ! style "height:100px;background-color:lightgreen;position:relative" $ h1 "Mouse events here")+ wraw (div ! style "height:100px;background-color:lightgreen;position:relative"+ $ h1 "Mouse events here") `fire` OnMouseOut `fire` OnMouseOver `fire` OnMouseDown