validity 0.3.0.0 → 0.3.0.1
raw patch · 2 files changed
+15/−1 lines, 2 files
Files
- src/Data/Validity.hs +14/−0
- validity.cabal +1/−1
src/Data/Validity.hs view
@@ -28,6 +28,8 @@ module Data.Validity ( Validity(..)+ , constructValid+ , constructValidUnsafe ) where @@ -60,4 +62,16 @@ isValid Nothing = True isValid (Just a) = isValid a ++-- | Construct a valid element from an unchecked element+constructValid :: Validity a => a -> Maybe a+constructValid p = if isValid p then Just p else Nothing++-- | Construct a valid element from an unchecked element, throwing 'error'+-- on invalid elements.+constructValidUnsafe :: (Show a, Validity a) => a -> a+constructValidUnsafe p =+ case constructValid p of+ Nothing -> error $ show p ++ " is not valid"+ Just p -> p
validity.cabal view
@@ -1,5 +1,5 @@ name: validity-version: 0.3.0.0+version: 0.3.0.1 synopsis: Validity typeclass description: Please see README.md homepage: https://github.com/NorfairKing/validity#readme