packages feed

digestive-functors 0.8.0.1 → 0.8.1.0

raw patch · 5 files changed

+32/−12 lines, 5 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Text.Digestive.Form.Internal: App :: FormTree t v m (b -> a) -> FormTree t v m b -> FormTree t v m a
- Text.Digestive.Form.Internal: List :: DefaultList (FormTree t v m a) -> FormTree t v m [Int] -> FormTree t v m [a]
- Text.Digestive.Form.Internal: Map :: (b -> m (Result v a)) -> FormTree t v m b -> FormTree t v m a
- Text.Digestive.Form.Internal: Metadata :: [Metadata] -> FormTree t v m a -> FormTree t v m a
- Text.Digestive.Form.Internal: Monadic :: t (FormTree t v m a) -> FormTree t v m a
- Text.Digestive.Form.Internal: Pure :: Field v a -> FormTree t v m a
- Text.Digestive.Form.Internal: Ref :: Ref -> FormTree t v m a -> FormTree t v m a
- Text.Digestive.Form.Internal.Field: Bool :: Bool -> Field v Bool
- Text.Digestive.Form.Internal.Field: Choice :: [(Text, [(Text, (a, v))])] -> Int -> Field v (a, Int)
- Text.Digestive.Form.Internal.Field: File :: Field v (Maybe FilePath)
- Text.Digestive.Form.Internal.Field: Singleton :: a -> Field v a
- Text.Digestive.Form.Internal.Field: Text :: Text -> Field v Text
+ Text.Digestive.Form: fileMultiple :: (Monad m, Monoid v) => Form v m [FilePath]
+ Text.Digestive.Form: infixr 5 .:
+ Text.Digestive.Form.Internal: [App] :: FormTree t v m (b -> a) -> FormTree t v m b -> FormTree t v m a
+ Text.Digestive.Form.Internal: [List] :: DefaultList (FormTree t v m a) -> FormTree t v m [Int] -> FormTree t v m [a]
+ Text.Digestive.Form.Internal: [Map] :: (b -> m (Result v a)) -> FormTree t v m b -> FormTree t v m a
+ Text.Digestive.Form.Internal: [Metadata] :: [Metadata] -> FormTree t v m a -> FormTree t v m a
+ Text.Digestive.Form.Internal: [Monadic] :: t (FormTree t v m a) -> FormTree t v m a
+ Text.Digestive.Form.Internal: [Pure] :: Field v a -> FormTree t v m a
+ Text.Digestive.Form.Internal: [Ref] :: Ref -> FormTree t v m a -> FormTree t v m a
+ Text.Digestive.Form.Internal: infixr 5 .:
+ Text.Digestive.Form.Internal.Field: [Bool] :: Bool -> Field v Bool
+ Text.Digestive.Form.Internal.Field: [Choice] :: [(Text, [(Text, (a, v))])] -> Int -> Field v (a, Int)
+ Text.Digestive.Form.Internal.Field: [File] :: Field v [FilePath]
+ Text.Digestive.Form.Internal.Field: [Singleton] :: a -> Field v a
+ Text.Digestive.Form.Internal.Field: [Text] :: Text -> Field v Text
- Text.Digestive.Form: listOf :: (Monad m, Monoid v) => Formlet v m a -> Formlet v m [a]
+ Text.Digestive.Form: listOf :: (Monad m, Monoid v) => (Maybe a -> Form v m b) -> (Maybe [a] -> Form v m [b])
- Text.Digestive.View: fieldInputBool :: Text -> View v -> Bool
+ Text.Digestive.View: fieldInputBool :: forall v. Text -> View v -> Bool
- Text.Digestive.View: fieldInputChoice :: Text -> View v -> [(Text, v, Bool)]
+ Text.Digestive.View: fieldInputChoice :: forall v. Text -> View v -> [(Text, v, Bool)]
- Text.Digestive.View: fieldInputChoiceGroup :: Text -> View v -> [(Text, [(Text, v, Bool)])]
+ Text.Digestive.View: fieldInputChoiceGroup :: forall v. Text -> View v -> [(Text, [(Text, v, Bool)])]
- Text.Digestive.View: fieldInputFile :: Text -> View v -> Maybe FilePath
+ Text.Digestive.View: fieldInputFile :: forall v. Text -> View v -> [FilePath]
- Text.Digestive.View: fieldInputText :: Text -> View v -> Text
+ Text.Digestive.View: fieldInputText :: forall v. Text -> View v -> Text

Files

CHANGELOG view
@@ -1,3 +1,6 @@+- 0.8.1.0+    * Add support for a list of files via `<input type="file" multiple />`+ - 0.8.0.1     * Bump `HUnit` dependency to allow up to `HUnit-1.3` 
digestive-functors.cabal view
@@ -1,5 +1,5 @@ Name:     digestive-functors-Version:  0.8.0.1+Version:  0.8.1.0 Synopsis: A practical formlet library  Description:
src/Text/Digestive/Form.hs view
@@ -27,6 +27,7 @@     , groupedChoiceWith'     , bool     , file+    , fileMultiple        -- * Optional forms     , optionalText@@ -64,7 +65,7 @@ import           Control.Applicative import           Control.Monad                      (liftM, liftM2) import           Data.List                          (findIndex)-import           Data.Maybe                         (fromMaybe)+import           Data.Maybe                         (fromMaybe, listToMaybe) import           Data.Monoid                        (Monoid) import           Data.Text                          (Text) import qualified Data.Text                          as T@@ -203,10 +204,18 @@ -------------------------------------------------------------------------------- -- | Returns a 'Formlet' for file selection file :: (Monad m, Monoid v) => Form v m (Maybe FilePath)-file = Pure File+file = listToMaybe <$> Pure File   --------------------------------------------------------------------------------+-- | Returns a 'Formlet' for multiple file selection.  Intended for use with+-- the @multiple@ attribute, which allows for multiple files to be uploaded+-- with a single input element.+fileMultiple :: (Monad m, Monoid v) => Form v m [FilePath]+fileMultiple = Pure File+++-------------------------------------------------------------------------------- -- | Validate the results of a form with a simple predicate -- -- Example:@@ -388,12 +397,17 @@   ----------------------------------------------------------------------------------- | Dynamic lists+-- | Dynamic lists.+--+-- The type is a less restrictive version of:+--+-- > Formlet a -> Formlet [a] listOf :: (Monad m, Monoid v)-       => Formlet v m a-       -> Formlet v m [a]+       => (Maybe a -> Form v m b)+       -> (Maybe [a] -> Form v m [b]) listOf single def =     List (fmap single defList) (indicesRef .: listIndices ixs)+   where     ixs = case def of         Nothing -> [0]
src/Text/Digestive/Form/Internal/Field.hs view
@@ -14,7 +14,7 @@  -------------------------------------------------------------------------------- import           Control.Arrow        (second)-import           Data.Maybe           (fromMaybe, listToMaybe)+import           Data.Maybe           (fromMaybe, listToMaybe, mapMaybe) import           Data.Text            (Text)  @@ -32,7 +32,7 @@     -- the list.     Choice    :: [(Text, [(Text, (a, v))])] -> Int -> Field v (a, Int)     Bool      :: Bool -> Field v Bool-    File      :: Field v (Maybe FilePath)+    File      :: Field v [FilePath]   --------------------------------------------------------------------------------@@ -73,8 +73,11 @@ evalField Get  _                 (Bool x)      = x evalField Post (TextInput x : _) (Bool _)      = x == "on" evalField Post _                 (Bool _)      = False-evalField Post (FileInput x : _) File          = Just x-evalField _    _                 File          = Nothing+evalField Post xs                File          = mapMaybe maybeFile xs+  where+    maybeFile (FileInput x) = Just x+    maybeFile _             = Nothing+evalField _    _                 File          = []   --------------------------------------------------------------------------------
src/Text/Digestive/View.hs view
@@ -260,14 +260,14 @@  -------------------------------------------------------------------------------- -- | Return the FilePath referred to by the given serialized path, if set.-fieldInputFile :: forall v. Text -> View v -> Maybe FilePath+fieldInputFile :: forall v. Text -> View v -> [FilePath] fieldInputFile ref (View _ _ form input _ method) =     queryField path form eval'   where     path       = toPath ref     givenInput = lookupInput path input -    eval' :: Field v b -> Maybe FilePath+    eval' :: Field v b -> [FilePath]     eval' field = case field of         File -> evalField method givenInput File         f    -> error $ T.unpack ref ++ ": expected (File), " ++