reform 0.2.7.1 → 0.2.7.2
raw patch · 2 files changed
+15/−10 lines, 2 filesdep +semigroups
Dependencies added: semigroups
Files
- Text/Reform/Core.hs +12/−8
- reform.cabal +3/−2
Text/Reform/Core.hs view
@@ -11,6 +11,7 @@ import Control.Monad.State (MonadState(get,put), StateT, evalStateT) import Control.Monad.Trans (lift) import Data.Monoid (Monoid(mempty, mappend))+import qualified Data.Semigroup as SG import Data.Text.Lazy (Text, unpack) import Text.Reform.Result (FormId(..), FormRange(..), Result(..), unitRange, zeroId) @@ -83,12 +84,10 @@ = Environment (FormId -> m (Value input)) | NoEnvironment --- | Not quite sure when this is useful and so hard to say if the rules for combining things with Missing/Default are correct-instance (Monoid input, Monad m) => Monoid (Environment m input) where- mempty = NoEnvironment- NoEnvironment `mappend` x = x- x `mappend` NoEnvironment = x- (Environment env1) `mappend` (Environment env2) =+instance (SG.Semigroup input, Monad m) => SG.Semigroup (Environment m input) where+ NoEnvironment <> x = x+ x <> NoEnvironment = x+ (Environment env1) <> (Environment env2) = Environment $ \id' -> do r1 <- (env1 id') r2 <- (env2 id')@@ -96,10 +95,15 @@ (Missing, Missing) -> return Missing (Default, Missing) -> return Default (Missing, Default) -> return Default- (Found x, Found y) -> return $ Found (x `mappend` y)+ (Found x, Found y) -> return $ Found (x SG.<> y) (Found x, _ ) -> return $ Found x (_ , Found y) -> return $ Found y +-- | Not quite sure when this is useful and so hard to say if the rules for combining things with Missing/Default are correct+instance (SG.Semigroup input, Monad m) => Monoid (Environment m input) where+ mempty = NoEnvironment+ mappend = (SG.<>)+ -- | Utility function: returns the current 'FormId'. This will only make sense -- if the form is not composed --@@ -119,7 +123,7 @@ -- newtype View error v = View { unView :: [(FormRange, error)] -> v- } deriving (Monoid)+ } deriving (SG.Semigroup, Monoid) instance Functor (View e) where fmap f (View g) = View $ f . g
reform.cabal view
@@ -1,5 +1,5 @@ Name: reform-Version: 0.2.7.1+Version: 0.2.7.2 Synopsis: reform is a type-safe HTML form generation and validation library Description: reform follows in the footsteps of formlets and digestive-functors <= 0.2. It provides a@@ -14,7 +14,7 @@ Build-type: Simple Homepage: http://www.happstack.com/ Cabal-version: >=1.6-tested-with: GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3+tested-with: GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3, GHC == 8.2.2, GHC == 8.4.1 source-repository head type: git@@ -31,5 +31,6 @@ Build-depends: base >= 4 && < 5, containers >= 0.4 && < 0.6, mtl >= 2.0 && < 2.3,+ semigroups >= 0.16 && < 0.19, text >= 0.11 && < 1.3