digestive-functors-hsp 0.4.7 → 0.5.0
raw patch · 2 files changed
+30/−30 lines, 2 filesdep ~hspdep ~hsxdep ~text
Dependency ranges changed: hsp, hsx, text
Files
- Text/Digestive/HSP/Html4.hs +24/−24
- digestive-functors-hsp.cabal +6/−6
Text/Digestive/HSP/Html4.hs view
@@ -8,8 +8,8 @@ import Data.Monoid (Monoid(mempty), mconcat) import Data.Text (Text) import qualified Data.Text as Text-import HSP (XMLGenerator, XMLGenT, EmbedAsChild(..), EmbedAsAttr(..), Attr(..), genElement, genEElement, set)-import qualified HSX.XMLGenerator as HSX+import HSP (XMLGenerator, XMLGen(..), XMLGenT, EmbedAsChild(..), EmbedAsAttr(..), Attr(..), set)+import HSX.XMLGenerator (GenXML) import Text.Digestive (FormId, Form(..), Result(..), View(..), getFormId, getFormInput, isFormInput, mapView) import Text.Digestive.Common as Common import Text.Digestive.Forms as Forms@@ -20,7 +20,7 @@ -- text input box that returns a 'String' inputString :: (Monad m, Functor m, XMLGenerator x, FormInput i f) => Maybe String -- ^ initial value- -> Form m i e [XMLGenT x (HSX.XML x)] String+ -> Form m i e [XMLGenT x (XMLType x)] String inputString = Forms.inputString $ \id' inp -> [<input type="text" name=(showFormId id') id=(showFormId id') value=(fromMaybe "" inp) />]@@ -28,7 +28,7 @@ -- FIXME: use inputText from Forms when it becomes available inputText :: (Monad m, Functor m, XMLGenerator x, FormInput i f) => Maybe Text- -> Form m i e [XMLGenT x (HSX.XML x)] Text+ -> Form m i e [XMLGenT x (XMLType x)] Text inputText v = Text.pack <$> ((Forms.inputString $ \id' inp ->@@ -38,7 +38,7 @@ Maybe Int -- ^ cols -> Maybe Int -- ^ rows -> Maybe String- -> Form m i e [XMLGenT x (HSX.XML x)] String+ -> Form m i e [XMLGenT x (XMLType x)] String inputTextArea c r = Forms.inputString $ \id' inp -> [<textarea name=(showFormId id') id=(showFormId id') (rows r ++ cols c)><% fromMaybe "" inp %></textarea>]@@ -51,13 +51,13 @@ inputTextRead :: (Monad m, Functor m, Show a, Read a, XMLGenerator x, FormInput i f) => String -> Maybe a- -> Form m i String [XMLGenT x (HSX.XML x)] a+ -> Form m i String [XMLGenT x (XMLType x)] a inputTextRead error' = flip inputRead error' $ \id' inp -> [<input type="text" name=(showFormId id') id=(showFormId id') value=(fromMaybe "" inp) />] inputPassword :: (Monad m, Functor m, XMLGenerator x, FormInput i f)- => Form m i e [XMLGenT x (HSX.XML x)] String+ => Form m i e [XMLGenT x (XMLType x)] String inputPassword = flip Forms.inputString Nothing $ \id' inp -> [<input type="password" name=(showFormId id') id=(showFormId id') value=(fromMaybe "" inp) />]@@ -70,7 +70,7 @@ inputCheckBox :: (Monad m, Functor m, XMLGenerator x, FormInput i f) => Bool- -> Form m i e [XMLGenT x (HSX.XML x)] Bool+ -> Form m i e [XMLGenT x (XMLType x)] Bool inputCheckBox inp = flip inputBool inp $ \id' inp -> [<input type="checkbox" name=(showFormId id') id=(showFormId id') (checked inp) />]@@ -79,7 +79,7 @@ => Bool -- ^ Use @<br>@ tags -> [a] -- ^ Default option -> [(a, c)] -- ^ Choices with their names- -> Form m i e [XMLGenT x (HSX.XML x)] [a] -- ^ Resulting form+ -> Form m i e [XMLGenT x (XMLType x)] [a] -- ^ Resulting form inputCheckboxes br defs choices = inputChoices toView defs (map fst choices) where@@ -101,7 +101,7 @@ => Bool -- ^ Use @<br>@ tags -> a -- ^ Default option -> [(a, c)] -- ^ Choices with their names- -> Form m i e [XMLGenT x (HSX.XML x)] a -- ^ Resulting form+ -> Form m i e [XMLGenT x (XMLType x)] a -- ^ Resulting form inputRadio br def choices = inputChoice toView def (map fst choices) where@@ -113,7 +113,7 @@ inputSelect :: (Monad m, Functor m, Eq a, XMLGenerator x, EmbedAsChild x c, Monoid c, FormInput i f) => a -- ^ Default option -> [(a, c)] -- ^ Choices with their names- -> Form m i e [XMLGenT x (HSX.XML x)] a -- ^ Resulting form+ -> Form m i e [XMLGenT x (XMLType x)] a -- ^ Resulting form inputSelect def choices = Form $ do id' <- getFormId unForm $ mapView (\cs -> [<select name=(showFormId id') id=(showFormId id')><% cs %></select>])@@ -125,7 +125,7 @@ inputMultiSelect :: (Monad m, Functor m, Eq a, XMLGenerator x, EmbedAsChild x c, Monoid c, FormInput i f) => [a] -- ^ Default options -> [(a, c)] -- ^ Choices with their names- -> Form m i e [XMLGenT x (HSX.XML x)] [a] -- ^ Resulting form+ -> Form m i e [XMLGenT x (XMLType x)] [a] -- ^ Resulting form inputMultiSelect defs choices = Form $ do id' <- getFormId unForm $ mapView (\cs -> [<select multiple="" name=(showFormId id') id=(showFormId id')><% cs %></select>])@@ -138,7 +138,7 @@ submit :: (Monad m, Functor m, XMLGenerator x, FormInput i f) => String- -> Form m i e [XMLGenT x (HSX.XML x)] String+ -> Form m i e [XMLGenT x (XMLType x)] String submit v = Forms.inputString (\id' inp -> [<input type="submit" name=(showFormId id') id=(showFormId id') value=(fromMaybe "" inp) />]) (Just v)@@ -146,7 +146,7 @@ -- TODO: add hiddenText when new digestive functors is availabe on hackage that adds Forms.inputText inputHiddenString :: (Monad m, Functor m, XMLGenerator x, FormInput i f) => String- -> Form m i e [XMLGenT x (HSX.XML x)] String+ -> Form m i e [XMLGenT x (XMLType x)] String inputHiddenString str = Forms.inputString (\id' inp ->@@ -154,17 +154,17 @@ (Just str) -- | file upload form inputFile :: (Monad m, Functor m, XMLGenerator x, FormInput i f) => - Form m i e [XMLGenT x (HSX.XML x)] (Maybe f)+ Form m i e [XMLGenT x (XMLType x)] (Maybe f) inputFile = Forms.inputFile $ \id' -> [<input type="file" name=(show id') id=(show id') />] label :: (Monad m, XMLGenerator x, EmbedAsChild x c, EmbedAsAttr x (Attr String String)) => c- -> Form m i e [XMLGenT x (HSX.XML x)] ()+ -> Form m i e [XMLGenT x (XMLType x)] () label string = Common.label $ \id' -> [<label for=(showFormId id')><% string %></label>] -errorList :: (XMLGenerator x, EmbedAsChild x c, EmbedAsChild x [HSX.XML x]) => [c] -> [XMLGenT x (HSX.XML x)]+errorList :: (XMLGenerator x, EmbedAsChild x c, EmbedAsChild x [XMLType x]) => [c] -> [XMLGenT x (XMLType x)] errorList [] = [] errorList children = [<ul>@@ -172,12 +172,12 @@ </ul> ] -errors :: (Monad m, XMLGenerator x, EmbedAsChild x [HSX.XML x]) => - Form m i String [XMLGenT x (HSX.XML x)] ()+errors :: (Monad m, XMLGenerator x, EmbedAsChild x [XMLType x]) => + Form m i String [XMLGenT x (XMLType x)] () errors = Common.errors errorList -childErrors :: (Monad m, XMLGenerator x, EmbedAsChild x [HSX.XML x]) => - Form m i String [XMLGenT x (HSX.XML x)] ()+childErrors :: (Monad m, XMLGenerator x, EmbedAsChild x [XMLType x]) => + Form m i String [XMLGenT x (XMLType x)] () childErrors = Common.childErrors errorList {-@@ -198,9 +198,9 @@ -} setAttrs :: (EmbedAsAttr x attr, XMLGenerator x, Monad m, Functor m) =>- Form m i e [HSX.GenXML x] a + Form m i e [GenXML x] a -> attr - -> Form m i e [HSX.GenXML x] a+ -> Form m i e [GenXML x] a setAttrs form attrs = mapView (map (`set` attrs)) form lookups :: (Eq a) => a -> [(a, b)] -> [b]@@ -219,7 +219,7 @@ form :: (XMLGenerator x, EmbedAsAttr x (Attr String action), EmbedAsChild x c) => action -- ^ value for action attribute -> c -- ^ contents of form tag- -> XMLGenT x (HSX.XML x)+ -> XMLGenT x (XMLType x) form action xml = <form action=action method="POST" enctype="multipart/form-data" accept-charset="UTF-8"> <% xml %>
digestive-functors-hsp.cabal view
@@ -1,5 +1,5 @@ Name: digestive-functors-hsp-Version: 0.4.7+Version: 0.5.0 Synopsis: HSP support for digestive-functors Description: This is an HSP frontend for the digestive-functors library. Homepage: http://src.seereason.com/digestive-functors-hsp@@ -14,11 +14,11 @@ Library Exposed-modules: Text.Digestive.HSP.Html4- Build-depends: base == 4.*,- digestive-functors >= 0.2 && < 0.3,- hsp,- hsx,- text+ Build-depends: base == 4.*,+ digestive-functors >= 0.2 && < 0.3,+ hsp >= 0.7.1 && < 0.8,+ hsx >= 0.10.2 && < 0.11,+ text == 0.11.* if !os(windows) -- Cabal has a bug on windows and cannot find trhsx Build-Tools: trhsx