validity-containers-0.5.0.5/src/0000755000000000000000000000000014552240067014631 5ustar0000000000000000validity-containers-0.5.0.5/src/Data/0000755000000000000000000000000014552240067015502 5ustar0000000000000000validity-containers-0.5.0.5/src/Data/Validity/0000755000000000000000000000000014672603477017302 5ustar0000000000000000validity-containers-0.5.0.5/src/Data/Validity/Containers.hs0000644000000000000000000000065214672575307021746 0ustar0000000000000000{-# OPTIONS_GHC -fno-warn-dodgy-exports #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-} 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 import Data.Validity.Tree validity-containers-0.5.0.5/src/Data/Validity/IntMap.hs0000644000000000000000000000114014672603477021022 0ustar0000000000000000{-# 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 validity-containers-0.5.0.5/src/Data/Validity/Map.hs0000644000000000000000000000137614625706051020350 0ustar0000000000000000{-# OPTIONS_GHC -fno-warn-orphans #-} module Data.Validity.Map ( decorateMap, ) where import Data.Map (Map) import qualified Data.Map as M import Data.Validity -- | A 'Map' of things is valid if all the keys and values are valid and the 'Map' itself -- is valid. 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] ] 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 validity-containers-0.5.0.5/src/Data/Validity/Sequence.hs0000644000000000000000000000050114625706051021370 0ustar0000000000000000{-# OPTIONS_GHC -fno-warn-orphans #-} module Data.Validity.Sequence where 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" validity-containers-0.5.0.5/src/Data/Validity/Set.hs0000644000000000000000000000103514625706051020356 0ustar0000000000000000{-# OPTIONS_GHC -fno-warn-orphans #-} module Data.Validity.Set where import Data.Containers.ListUtils import Data.Set (Set) import qualified Data.Set as S import Data.Validity -- | A 'Set' of things is valid if all the elements are valid and the 'Set' itself -- is valid. instance (Ord v, Validity v) => Validity (Set v) where validate s = mconcat [ declare "The set structure is valid." $ S.valid s, annotate (S.toList s) "Set elements" ] distinctOrd :: (Ord a) => [a] -> Bool distinctOrd ls = nubOrd ls == ls validity-containers-0.5.0.5/src/Data/Validity/Tree.hs0000644000000000000000000000050514625706051020523 0ustar0000000000000000{-# OPTIONS_GHC -fno-warn-orphans #-} module Data.Validity.Tree where 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"] validity-containers-0.5.0.5/CHANGELOG.md0000644000000000000000000000114214672767071015665 0ustar0000000000000000# Changelog ## [0.5.0.5] - 2024-09-19 ### Added * `Validity v => Validity (IntMap v)` ## [0.5.0.4] - 2020-06-17 ### Added * `distinctOrd` ## [0.5.0.3] - 2020-04-23 ### Changed * The same as 0.5.0.2, but now it actually works. ## [0.5.0.2] - 2020-04-23 ### Changed * Exposed `decorateMap` from `Data.Validity.Containers` ## [0.5.0.1] - 2019-09-23 ### Changed * Improved the cabal file * Used `++` instead of `<>` for a string, for compatibility purposes ## [0.5.0.0] - 2019-09-23 ### Added * `decorateMap` ### Changed * The validity instance for maps now requires that keys are `Show`able. validity-containers-0.5.0.5/LICENSE0000644000000000000000000000210414552240067015044 0ustar0000000000000000The MIT License (MIT) 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 in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. validity-containers-0.5.0.5/validity-containers.cabal0000644000000000000000000000212014672767071021025 0ustar0000000000000000cabal-version: 1.12 -- This file has been generated from package.yaml by hpack version 0.36.0. -- -- see: https://github.com/sol/hpack name: validity-containers 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-2021 Tom Sydney Kerckhove license: MIT license-file: LICENSE build-type: Simple extra-source-files: CHANGELOG.md source-repository head type: git location: https://github.com/NorfairKing/validity library exposed-modules: Data.Validity.Containers Data.Validity.IntMap Data.Validity.Map Data.Validity.Sequence Data.Validity.Set Data.Validity.Tree other-modules: Paths_validity_containers hs-source-dirs: src build-depends: base >=4.7 && <5 , containers >=0.6.0.1 , validity >=0.5 default-language: Haskell2010