haste-perch 0.1.0.6 → 0.1.0.7
raw patch · 4 files changed
+16/−33 lines, 4 files
Files
- Haste/App/Perch.hs +0/−9
- Haste/Perch.hs +2/−17
- README.md +13/−6
- haste-perch.cabal +1/−1
Haste/App/Perch.hs view
@@ -107,15 +107,6 @@ return e' - -instance JSType JSString where - toJSString x= x - fromJSString x= Just x - - - - - -- Leaf DOM nodes -- area = nelem "area"
Haste/Perch.hs view
@@ -17,8 +17,8 @@ , OverlappingInstances #-} module Haste.Perch where import Data.Typeable -import Haste -import Haste.DOM +import Haste hiding (Attribute, attr) +import Haste.DOM hiding (Attribute, attr) import Haste.Foreign import Data.Maybe import Data.Monoid @@ -109,22 +109,7 @@ -instance JSType JSString where - toJSString x= x - fromJSString x= Just x --- | unsafe event handler for arbitrary events --- --- listen element "click" doit --- --- > doit :: Int -> (Int,Int) -> IO () --- > doit i (x,y) = do --- > body <- getBody --- > (flip build) body $ do --- > p i --- > p (x,y) --- > return() --- It is unsafe. You must make sure that the event handler has the right types of parameters. The types for the known events are the ones of the used in haste `onEvent` listen :: JSType event => Elem -> event -> a -> IO Bool listen e event f= jsSetCB e (toJSString event) (mkCallback $! f)
README.md view
@@ -1,5 +1,6 @@-perch +Perch ================= + Perch defines builder elements (perchs) for Haste.DOM elements that are appendable, so that dynamic HTML can be created in the client in a natural way, like textual HTML, but programmatically and with the advantage of static type checking. It can be ported to other haskell-js compilers @@ -83,12 +84,17 @@ >cabal install haste-compiler -clone haskell-js-html-builder +boot Haste: + >haste-boot + +clone haste-perch + >git clone http://github.com/agocorona/haste-perch.git install perch + >cd haste-perch >haste-inst install compile the main program @@ -108,13 +114,14 @@ How it works ------------ -The basic element is a "builder" that has a "hole" parameter and a IO action about what element will be created. The hole will receive the parent (Elem) of the element/s that will be created by the builder. So a builder can be considered like a perch that has other perchs that hang from it. either a single element or an entire tree. +The basic element is a "builder" that has a "hole" parameter and a IO action which creates the DOM element. The hole will receive the parent (Elem) of the element/s that will be created by the builder. So a builder can be considered like a perch that has other perchs that hang from it. Either a no one or an entire tree. -the call `nelem` (new element) is a perch that creates a single tag element. Upon created, it is added to the parent and return itself as parent of the next elements that can be hooked. To append two elements, both are added to the parent. +the call `nelem` (new element) is a perch that creates a single DOM element. Upon created, it is added to the parent and return itself as parent of the next elements that can be hooked from it if `child` is used. When appending two elements, both are added to the parent. The Monad instance is there in order to use the do notation, that add a new level of syntax, in the style of the package blaze-html. This monad invokes the same appending mechanism. -A perch is a generalization of a list and it is handled in the same way; -while a list is an unary tree, perch create n-ary trees. While in a list the monoid instance add child nodes +A perch is a generalization of a list and it is handled in the same way. + +While a list is an unary tree, perch create n-ary trees. While in a list the monoid instance add child nodes down in the only direction that it can grow, the perch monoid add childs at the same level, horizontally. Is the `child` primitive the one that creates branches down.
haste-perch.cabal view
@@ -1,5 +1,5 @@ name: haste-perch -version: 0.1.0.6 +version: 0.1.0.7 cabal-version: >=1.10 build-type: Simple license: GPL-3