packages feed

ditto-lucid 0.1.1.1 → 0.1.1.2

raw patch · 3 files changed

+46/−54 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Ditto.Lucid.Named: arbitraryHtml :: Monad m => view -> Form m input error view ()
+ Ditto.Lucid.Named: arbitraryHtml :: Monad m => view -> Form m input err view ()
- Ditto.Lucid.Named: button :: (Monad m, FormError error, Monad f) => String -> HtmlT f () -> Form m input error (HtmlT f ()) ()
+ Ditto.Lucid.Named: button :: (Monad m, FormError err, Monad f) => String -> HtmlT f () -> Form m input err (HtmlT f ()) ()
- Ditto.Lucid.Named: buttonReset :: (Monad m, FormError error, Monad f) => String -> HtmlT f () -> Form m input error (HtmlT f ()) ()
+ Ditto.Lucid.Named: buttonReset :: (Monad m, FormError err, Monad f) => String -> HtmlT f () -> Form m input err (HtmlT f ()) ()
- Ditto.Lucid.Named: buttonSubmit :: (Monad m, FormError error, PathPiece text, ToHtml children, Monad f) => (input -> Either error text) -> String -> text -> children -> Form m input error (HtmlT f ()) (Maybe text)
+ Ditto.Lucid.Named: buttonSubmit :: (Monad m, FormError err, PathPiece text, ToHtml children, Monad f) => (input -> Either err text) -> String -> text -> children -> Form m input err (HtmlT f ()) (Maybe text)
- Ditto.Lucid.Named: inputButton :: (Monad m, FormError error, PathPiece text, Applicative f) => String -> text -> Form m input error (HtmlT f ()) ()
+ Ditto.Lucid.Named: inputButton :: (Monad m, FormError err, PathPiece text, Applicative f) => String -> text -> Form m input err (HtmlT f ()) ()
- Ditto.Lucid.Named: inputCheckbox :: forall x error input m f. (Monad m, FormInput input, FormError error, ErrorInputType error ~ input, Applicative f) => Bool -> String -> Form m input error (HtmlT f ()) Bool
+ Ditto.Lucid.Named: inputCheckbox :: forall x err input m f. (Monad m, FormError err, ErrorInputType err ~ input, Applicative f) => Bool -> String -> Form m input err (HtmlT f ()) Bool
- Ditto.Lucid.Named: inputCheckboxes :: (Functor m, Monad m, FormError error, ErrorInputType error ~ input, FormInput input, ToHtml lbl, Monad f) => String -> [(a, lbl)] -> (a -> Bool) -> Form m input error (HtmlT f ()) [a]
+ Ditto.Lucid.Named: inputCheckboxes :: (Functor m, Monad m, FormError err, ErrorInputType err ~ input, FormInput input, ToHtml lbl, Monad f) => String -> [(a, lbl)] -> (a -> Bool) -> Form m input err (HtmlT f ()) [a]
- Ditto.Lucid.Named: inputFile :: (Monad m, FormError error, FormInput input, ErrorInputType error ~ input, Applicative f) => String -> Form m input error (HtmlT f ()) (FileType input)
+ Ditto.Lucid.Named: inputFile :: (Monad m, FormError err, FormInput input, ErrorInputType err ~ input, Applicative f) => String -> Form m input err (HtmlT f ()) (FileType input)
- Ditto.Lucid.Named: inputHidden :: (Monad m, FormError error, PathPiece text, Applicative f) => (input -> Either error text) -> String -> text -> Form m input error (HtmlT f ()) text
+ Ditto.Lucid.Named: inputHidden :: (Monad m, FormError err, PathPiece text, Applicative f) => (input -> Either err text) -> String -> text -> Form m input err (HtmlT f ()) text
- Ditto.Lucid.Named: inputPassword :: (Monad m, FormError error, PathPiece text, Applicative f) => (input -> Either error text) -> String -> text -> Form m input error (HtmlT f ()) text
+ Ditto.Lucid.Named: inputPassword :: (Monad m, FormError err, PathPiece text, Applicative f) => (input -> Either err text) -> String -> text -> Form m input err (HtmlT f ()) text
- Ditto.Lucid.Named: inputRadio :: (Functor m, Monad m, FormError error, ErrorInputType error ~ input, FormInput input, ToHtml lbl, Monad f) => String -> [(a, lbl)] -> (a -> Bool) -> Form m input error (HtmlT f ()) a
+ Ditto.Lucid.Named: inputRadio :: (Functor m, Monad m, FormError err, ErrorInputType err ~ input, FormInput input, ToHtml lbl, Monad f) => String -> [(a, lbl)] -> (a -> Bool) -> Form m input err (HtmlT f ()) a
- Ditto.Lucid.Named: inputReset :: (Monad m, FormError error, PathPiece text, Applicative f) => String -> text -> Form m input error (HtmlT f ()) ()
+ Ditto.Lucid.Named: inputReset :: (Monad m, FormError err, PathPiece text, Applicative f) => String -> text -> Form m input err (HtmlT f ()) ()
- Ditto.Lucid.Named: inputSubmit :: (Monad m, FormError error, PathPiece text, Applicative f) => (input -> Either error text) -> String -> text -> Form m input error (HtmlT f ()) (Maybe text)
+ Ditto.Lucid.Named: inputSubmit :: (Monad m, FormError err, PathPiece text, Applicative f) => (input -> Either err text) -> String -> text -> Form m input err (HtmlT f ()) (Maybe text)
- Ditto.Lucid.Named: inputText :: (Monad m, FormError error, PathPiece text, Applicative f) => (input -> Either error text) -> String -> text -> Form m input error (HtmlT f ()) text
+ Ditto.Lucid.Named: inputText :: (Monad m, FormError err, PathPiece text, Applicative f) => (input -> Either err text) -> String -> text -> Form m input err (HtmlT f ()) text
- Ditto.Lucid.Named: label :: (Monad m, Monad f) => HtmlT f () -> String -> Form m input error (HtmlT f ()) ()
+ Ditto.Lucid.Named: label :: (Monad m, Monad f) => HtmlT f () -> String -> Form m input err (HtmlT f ()) ()
- Ditto.Lucid.Named: select :: (Functor m, Monad m, FormError error, ErrorInputType error ~ input, FormInput input, ToHtml lbl, Monad f) => String -> [(a, lbl)] -> (a -> Bool) -> Form m input error (HtmlT f ()) a
+ Ditto.Lucid.Named: select :: (Functor m, Monad m, FormError err, ErrorInputType err ~ input, FormInput input, ToHtml lbl, Monad f) => String -> [(a, lbl)] -> (a -> Bool) -> Form m input err (HtmlT f ()) a
- Ditto.Lucid.Named: selectMultiple :: (Functor m, Monad m, FormError error, ErrorInputType error ~ input, FormInput input, ToHtml lbl, Monad f) => String -> [(a, lbl)] -> (a -> Bool) -> Form m input error (HtmlT f ()) [a]
+ Ditto.Lucid.Named: selectMultiple :: (Functor m, Monad m, FormError err, ErrorInputType err ~ input, FormInput input, ToHtml lbl, Monad f) => String -> [(a, lbl)] -> (a -> Bool) -> Form m input err (HtmlT f ()) [a]
- Ditto.Lucid.Named: textarea :: (Monad m, FormError error, ToHtml text, Monad f) => (input -> Either error text) -> Int -> Int -> String -> text -> Form m input error (HtmlT f ()) text
+ Ditto.Lucid.Named: textarea :: (Monad m, FormError err, ToHtml text, Monad f) => (input -> Either err text) -> Int -> Int -> String -> text -> Form m input err (HtmlT f ()) text
- Ditto.Lucid.Unnamed: inputCheckbox :: forall x error input m f. (Monad m, FormInput input, FormError error, ErrorInputType error ~ input, Applicative f) => Bool -> Form m input error (HtmlT f ()) Bool
+ Ditto.Lucid.Unnamed: inputCheckbox :: forall x error input m f. (Monad m, FormError error, ErrorInputType error ~ input, Applicative f) => Bool -> Form m input error (HtmlT f ()) Bool

Files

ditto-lucid.cabal view
@@ -1,5 +1,5 @@ Name:                ditto-lucid-Version:             0.1.1.1+Version:             0.1.1.2 Synopsis:            Add support for using lucid with Ditto Description:         Ditto is a library for building and validating forms using applicative functors. This package add support for using ditto with lucid. License:             BSD3
src/Ditto/Lucid/Named.hs view
@@ -18,71 +18,71 @@ import qualified Text.Read  inputText-  :: (Monad m, FormError error, PathPiece text, Applicative f)-  => (input -> Either error text)+  :: (Monad m, FormError err, PathPiece text, Applicative f)+  => (input -> Either err text)   -> String   -> text-  -> Form m input error (HtmlT f ()) text+  -> Form m input err (HtmlT f ()) text inputText getInput name initialValue = G.input getInput inputField initialValue name   where     inputField i a = input_ [type_ "text", id_ (toPathPiece i), name_ (toPathPiece i), value_ (toPathPiece a)]  inputPassword-  :: (Monad m, FormError error, PathPiece text, Applicative f)-  => (input -> Either error text)+  :: (Monad m, FormError err, PathPiece text, Applicative f)+  => (input -> Either err text)   -> String   -> text-  -> Form m input error (HtmlT f ()) text+  -> Form m input err (HtmlT f ()) text inputPassword getInput name initialValue = G.input getInput inputField initialValue name   where     inputField i a = input_ [type_ "password", id_ (toPathPiece i), name_ (toPathPiece i), value_ (toPathPiece a)]  inputSubmit-  :: (Monad m, FormError error, PathPiece text, Applicative f)-  => (input -> Either error text)+  :: (Monad m, FormError err, PathPiece text, Applicative f)+  => (input -> Either err text)   -> String   -> text-  -> Form m input error (HtmlT f ()) (Maybe text)+  -> Form m input err (HtmlT f ()) (Maybe text) inputSubmit getInput name initialValue = G.inputMaybe getInput inputField initialValue name   where     inputField i a = input_ [type_ "submit", id_ (toPathPiece i), name_ (toPathPiece i), value_ (toPathPiece a)]  inputReset-  :: (Monad m, FormError error, PathPiece text, Applicative f)+  :: (Monad m, FormError err, PathPiece text, Applicative f)   => String   -> text-  -> Form m input error (HtmlT f ()) ()+  -> Form m input err (HtmlT f ()) () inputReset name lbl = G.inputNoData inputField lbl name   where     inputField i a = input_ [type_ "submit", id_ (toPathPiece i), name_ (toPathPiece i), value_ (toPathPiece a)]  inputHidden-  :: (Monad m, FormError error, PathPiece text, Applicative f)-  => (input -> Either error text)+  :: (Monad m, FormError err, PathPiece text, Applicative f)+  => (input -> Either err text)   -> String   -> text-  -> Form m input error (HtmlT f ()) text+  -> Form m input err (HtmlT f ()) text inputHidden getInput name initialValue = G.input getInput inputField initialValue name   where     inputField i a = input_ [type_ "hidden", id_ (toPathPiece i), name_ (toPathPiece i), value_ (toPathPiece a)]  inputButton-  :: (Monad m, FormError error, PathPiece text, Applicative f)+  :: (Monad m, FormError err, PathPiece text, Applicative f)   => String   -> text-  -> Form m input error (HtmlT f ()) ()+  -> Form m input err (HtmlT f ()) () inputButton name label = G.inputNoData inputField label name   where     inputField i a = input_ [type_ "button", id_ (toPathPiece i), name_ (toPathPiece i), value_ (toPathPiece a)]  textarea-  :: (Monad m, FormError error, ToHtml text, Monad f)-  => (input -> Either error text)+  :: (Monad m, FormError err, ToHtml text, Monad f)+  => (input -> Either err text)   -> Int -- ^ cols   -> Int -- ^ rows   -> String   -> text -- ^ initial text-  -> Form m input error (HtmlT f ()) text+  -> Form m input err (HtmlT f ()) text textarea getInput cols rows name initialValue = G.input getInput textareaView initialValue name   where     textareaView i txt =@@ -98,21 +98,21 @@ -- -- This control may succeed even if the user does not actually select a file to upload. In that case the uploaded name will likely be \"\" and the file contents will be empty as well. inputFile-  :: (Monad m, FormError error, FormInput input, ErrorInputType error ~ input, Applicative f)+  :: (Monad m, FormError err, FormInput input, ErrorInputType err ~ input, Applicative f)   => String-  -> Form m input error (HtmlT f ()) (FileType input)+  -> Form m input err (HtmlT f ()) (FileType input) inputFile name = G.inputFile fileView name   where     fileView i = input_ [type_ "file", id_ (toPathPiece i), name_ (toPathPiece i)]  -- | Create a @\<button type=\"submit\"\>@ element buttonSubmit-  :: (Monad m, FormError error, PathPiece text, ToHtml children, Monad f)-  => (input -> Either error text)+  :: (Monad m, FormError err, PathPiece text, ToHtml children, Monad f)+  => (input -> Either err text)   -> String   -> text   -> children-  -> Form m input error (HtmlT f ()) (Maybe text)+  -> Form m input err (HtmlT f ()) (Maybe text) buttonSubmit getInput name text c = G.inputMaybe getInput inputField text name   where     inputField i a = button_ [type_ "submit", id_ (toPathPiece i), name_ (toPathPiece i), value_ (toPathPiece a)] $ toHtml c@@ -121,10 +121,10 @@ -- -- This element does not add any data to the form data set. buttonReset-  :: (Monad m, FormError error, Monad f)+  :: (Monad m, FormError err, Monad f)   => String   -> HtmlT f ()-  -> Form m input error (HtmlT f ()) ()+  -> Form m input err (HtmlT f ()) () buttonReset name c = G.inputNoData inputField Nothing name   where     inputField i a = button_ [type_ "reset", id_ (toPathPiece i), name_ (toPathPiece i)] c@@ -133,10 +133,10 @@ -- -- This element does not add any data to the form data set. button-  :: (Monad m, FormError error, Monad f)+  :: (Monad m, FormError err, Monad f)   => String   -> HtmlT f ()-  -> Form m input error (HtmlT f ()) ()+  -> Form m input err (HtmlT f ()) () button name c = G.inputNoData inputField Nothing name   where     inputField i a = button_ [type_ "button", id_ (toPathPiece i), name_ (toPathPiece i)] c@@ -150,12 +150,12 @@   :: (Monad m, Monad f)   => HtmlT f ()   -> String-  -> Form m input error (HtmlT f ()) ()+  -> Form m input err (HtmlT f ()) () label c name = G.label mkLabel name   where     mkLabel i = label_ [for_ (toPathPiece i)] c -arbitraryHtml :: Monad m => view -> Form m input error view ()+arbitraryHtml :: Monad m => view -> Form m input err view () arbitraryHtml = view  inputInt@@ -189,12 +189,11 @@ -- returns a 'Bool' indicating if it was checked or not. -- -- see also 'inputCheckboxes'--- FIXME: Should this built on something in Generalized? inputCheckbox-  :: forall x error input m f. (Monad m, FormInput input, FormError error, ErrorInputType error ~ input, Applicative f)+  :: forall x err input m f. (Monad m, FormError err, ErrorInputType err ~ input, Applicative f)   => Bool -- ^ initially checked   -> String -- ^ name-  -> Form m input error (HtmlT f ()) Bool+  -> Form m input err (HtmlT f ()) Bool inputCheckbox initiallyChecked name =   Form $ do     i <- getNamedFormId name@@ -202,10 +201,7 @@     case v of       Default -> mkCheckbox i initiallyChecked       Missing -> mkCheckbox i False -- checkboxes only appear in the submitted data when checked-      (Found input) ->-        case getInputString input of-          (Right _) -> mkCheckbox i True-          (Left (e :: error)) -> mkCheckbox i False+      Found _ -> mkCheckbox i True   where     mkCheckbox i checked =       let checkbox =@@ -226,11 +222,11 @@ -- | Create a group of @\<input type=\"checkbox\"\>@ elements -- inputCheckboxes-  :: (Functor m, Monad m, FormError error, ErrorInputType error ~ input, FormInput input, ToHtml lbl, Monad f)+  :: (Functor m, Monad m, FormError err, ErrorInputType err ~ input, FormInput input, ToHtml lbl, Monad f)   => String   -> [(a, lbl)] -- ^ value, label, initially checked   -> (a -> Bool) -- ^ function which indicates if a value should be checked initially-  -> Form m input error (HtmlT f ()) [a]+  -> Form m input err (HtmlT f ()) [a] inputCheckboxes name choices isChecked = G.inputMulti choices mkCheckboxes isChecked name   where     mkCheckboxes nm choices' = mconcat $ concatMap (mkCheckbox nm) choices'@@ -244,11 +240,11 @@  -- | Create a group of @\<input type=\"radio\"\>@ elements inputRadio-  :: (Functor m, Monad m, FormError error, ErrorInputType error ~ input, FormInput input, ToHtml lbl, Monad f)+  :: (Functor m, Monad m, FormError err, ErrorInputType err ~ input, FormInput input, ToHtml lbl, Monad f)   => String   -> [(a, lbl)] -- ^ value, label, initially checked   -> (a -> Bool) -- ^ isDefault-  -> Form m input error (HtmlT f ()) a+  -> Form m input err (HtmlT f ()) a inputRadio name choices isDefault =   G.inputChoice isDefault choices mkRadios name   where@@ -265,11 +261,11 @@ -- -- see also: 'selectMultiple' select-  :: (Functor m, Monad m, FormError error, ErrorInputType error ~ input, FormInput input, ToHtml lbl, Monad f)+  :: (Functor m, Monad m, FormError err, ErrorInputType err ~ input, FormInput input, ToHtml lbl, Monad f)   => String   -> [(a, lbl)] -- ^ value, label   -> (a -> Bool) -- ^ isDefault, must match *exactly one* element in the list of choices-  -> Form m input error (HtmlT f ()) a+  -> Form m input err (HtmlT f ()) a select name choices isDefault = G.inputChoice isDefault choices mkSelect name   where     mkSelect :: (ToHtml lbl, Monad f) => FormId -> [(a, Int, lbl, Bool)] -> HtmlT f ()@@ -288,11 +284,11 @@ -- -- This creates a @\<select\>@ element which allows more than one item to be selected. selectMultiple-  :: (Functor m, Monad m, FormError error, ErrorInputType error ~ input, FormInput input, ToHtml lbl, Monad f)+  :: (Functor m, Monad m, FormError err, ErrorInputType err ~ input, FormInput input, ToHtml lbl, Monad f)   => String   -> [(a, lbl)] -- ^ value, label, initially checked   -> (a -> Bool) -- ^ isSelected initially-  -> Form m input error (HtmlT f ()) [a]+  -> Form m input err (HtmlT f ()) [a] selectMultiple name choices isSelected = G.inputMulti choices mkSelect isSelected name   where     mkSelect :: (ToHtml lbl, Monad f) => FormId -> [(a, Int, lbl, Bool)] -> HtmlT f ()@@ -308,9 +304,9 @@         (toHtml lbl)  {--inputMultiSelectOptGroup :: (Functor m, XMLGenerator x, EmbedAsChild x groupLbl, EmbedAsChild x lbl, EmbedAsAttr x (Attr String FormId), FormError error, ErrorInputType error ~ input, FormInput input, Monad m, Applicative f) =>+inputMultiSelectOptGroup :: (Functor m, XMLGenerator x, EmbedAsChild x groupLbl, EmbedAsChild x lbl, EmbedAsAttr x (Attr String FormId), FormError err, ErrorInputType err ~ input, FormInput input, Monad m, Applicative f) =>                    [(groupLbl, [(a, lbl, Bool)])]  -- ^ value, label, initially checked-                -> Form m input error (HtmlT f ()) [a]+                -> Form m input err (HtmlT f ()) [a] inputMultiSelectOptGroup choices =     G.inputMulti choices mkSelect     where
src/Ditto/Lucid/Unnamed.hs view
@@ -186,9 +186,8 @@ -- returns a 'Bool' indicating if it was checked or not. -- -- see also 'inputCheckboxes'--- FIXME: Should this built on something in Generalized? inputCheckbox-  :: forall x error input m f. (Monad m, FormInput input, FormError error, ErrorInputType error ~ input, Applicative f)+  :: forall x error input m f. (Monad m, FormError error, ErrorInputType error ~ input, Applicative f)   => Bool -- ^ initially checked   -> Form m input error (HtmlT f ()) Bool inputCheckbox initiallyChecked =@@ -198,10 +197,7 @@     case v of       Default -> mkCheckbox i initiallyChecked       Missing -> mkCheckbox i False -- checkboxes only appear in the submitted data when checked-      (Found input) ->-        case getInputString input of-          (Right _) -> mkCheckbox i True-          (Left (e :: error)) -> mkCheckbox i False+      Found input -> mkCheckbox i True   where     mkCheckbox i checked =       let checkbox =