validity-containers 0.5.0.4 → 0.5.0.5
raw patch · 10 files changed
+52/−28 lines, 10 filessetup-changed
Files
- CHANGELOG.md +6/−0
- LICENSE +1/−1
- Setup.hs +0/−3
- src/Data/Validity/Containers.hs +2/−0
- src/Data/Validity/IntMap.hs +22/−0
- src/Data/Validity/Map.hs +8/−6
- src/Data/Validity/Sequence.hs +3/−4
- src/Data/Validity/Set.hs +2/−4
- src/Data/Validity/Tree.hs +4/−5
- validity-containers.cabal +4/−5
CHANGELOG.md view
@@ -1,5 +1,11 @@ # Changelog +## [0.5.0.5] - 2024-09-19++### Added++* `Validity v => Validity (IntMap v)`+ ## [0.5.0.4] - 2020-06-17 ### Added
LICENSE view
@@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2016-2020 Tom Sydney Kerckhove+Copyright (c) 2016-2021 Tom Sydney Kerckhove Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal
− Setup.hs
@@ -1,3 +0,0 @@-import Distribution.Simple--main = defaultMain
src/Data/Validity/Containers.hs view
@@ -3,12 +3,14 @@ module Data.Validity.Containers ( module Data.Validity.Map,+ module Data.Validity.IntMap, module Data.Validity.Sequence, module Data.Validity.Set, module Data.Validity.Tree, ) where +import Data.Validity.IntMap import Data.Validity.Map import Data.Validity.Sequence import Data.Validity.Set
+ src/Data/Validity/IntMap.hs view
@@ -0,0 +1,22 @@+{-# OPTIONS_GHC -fno-warn-orphans #-}++module Data.Validity.IntMap+ ( decorateIntMap,+ )+where++import Data.IntMap (IntMap)+import qualified Data.IntMap as IM+import Data.Validity++-- | A 'IntMap' of things is valid if all the keys and values are valid and the 'IntMap' itself+-- is valid.+instance (Validity v) => Validity (IntMap v) where+ validate m =+ decorate "IntMap elements" $+ decorateIntMap m validate++decorateIntMap :: IntMap v -> (v -> Validation) -> Validation+decorateIntMap m func = IM.foldMapWithKey go m+ where+ go k v = decorate ("The key/value at key " ++ show k) $ func v
src/Data/Validity/Map.hs view
@@ -1,8 +1,9 @@ {-# OPTIONS_GHC -fno-warn-orphans #-} module Data.Validity.Map- ( decorateMap- ) where+ ( decorateMap,+ )+where import Data.Map (Map) import qualified Data.Map as M@@ -13,12 +14,13 @@ instance (Show k, Ord k, Validity k, Validity v) => Validity (Map k v) where validate m = mconcat- [ declare "The Map structure is valid." $ M.valid m- , decorate "Map elements" $- decorateMap m $ \k v -> mconcat [delve "The key" k, delve "The value" v]+ [ declare "The Map structure is valid." $ M.valid m,+ decorate "Map elements" $+ decorateMap m $+ \k v -> mconcat [delve "The key" k, delve "The value" v] ] -decorateMap :: Show k => Map k v -> (k -> v -> Validation) -> Validation+decorateMap :: (Show k) => Map k v -> (k -> v -> Validation) -> Validation decorateMap m func = M.foldMapWithKey go m where go k v = decorate ("The key/value at key " ++ show k) $ func k v
src/Data/Validity/Sequence.hs view
@@ -2,11 +2,10 @@ module Data.Validity.Sequence where -import Data.Validity- import Data.Foldable (toList) import Data.Sequence (Seq)+import Data.Validity -- | A 'Seq'uence of things is valid if all the elements are valid.-instance Validity v => Validity (Seq v) where- validate s = annotate (toList s) "Seq elements"+instance (Validity v) => Validity (Seq v) where+ validate s = annotate (toList s) "Seq elements"
src/Data/Validity/Set.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module Data.Validity.Set where@@ -16,7 +15,6 @@ [ declare "The set structure is valid." $ S.valid s, annotate (S.toList s) "Set elements" ]-#if MIN_VERSION_containers(0,6,0)-distinctOrd :: Ord a => [a] -> Bool++distinctOrd :: (Ord a) => [a] -> Bool distinctOrd ls = nubOrd ls == ls-#endif
src/Data/Validity/Tree.hs view
@@ -2,11 +2,10 @@ module Data.Validity.Tree where -import Data.Validity- import Data.Tree+import Data.Validity -- | A 'Tree' of things is valid if all the things in the 'Tree' are valid.-instance Validity a => Validity (Tree a) where- validate (Node rl sf) =- mconcat [annotate rl "rootLabel", annotate sf "subForest"]+instance (Validity a) => Validity (Tree a) where+ validate (Node rl sf) =+ mconcat [annotate rl "rootLabel", annotate sf "subForest"]
validity-containers.cabal view
@@ -1,20 +1,18 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.33.0.+-- This file has been generated from package.yaml by hpack version 0.36.0. -- -- see: https://github.com/sol/hpack------ hash: 2e970343bc40866f2768fe78bd9427b658402d4bf787b23ad793a1cae658a82f name: validity-containers-version: 0.5.0.4+version: 0.5.0.5 synopsis: Validity instances for containers category: Validity homepage: https://github.com/NorfairKing/validity#readme bug-reports: https://github.com/NorfairKing/validity/issues author: Tom Sydney Kerckhove maintainer: syd@cs-syd.eu-copyright: Copyright: (c) 2016-2020 Tom Sydney Kerckhove+copyright: Copyright: (c) 2016-2021 Tom Sydney Kerckhove license: MIT license-file: LICENSE build-type: Simple@@ -28,6 +26,7 @@ library exposed-modules: Data.Validity.Containers+ Data.Validity.IntMap Data.Validity.Map Data.Validity.Sequence Data.Validity.Set