validity-containers-0.5.0.4/src/0000755000000000000000000000000013644617172014636 5ustar0000000000000000validity-containers-0.5.0.4/src/Data/0000755000000000000000000000000013644617172015507 5ustar0000000000000000validity-containers-0.5.0.4/src/Data/Validity/0000755000000000000000000000000013671407511017266 5ustar0000000000000000validity-containers-0.5.0.4/src/Data/Validity/Containers.hs0000644000000000000000000000055513651777667021760 0ustar0000000000000000{-# OPTIONS_GHC -fno-warn-dodgy-exports #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-} module Data.Validity.Containers ( module Data.Validity.Map, module Data.Validity.Sequence, module Data.Validity.Set, module Data.Validity.Tree, ) where import Data.Validity.Map import Data.Validity.Sequence import Data.Validity.Set import Data.Validity.Tree validity-containers-0.5.0.4/src/Data/Validity/Map.hs0000644000000000000000000000135413644617172020350 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.4/src/Data/Validity/Sequence.hs0000644000000000000000000000050213644617172021375 0ustar0000000000000000{-# OPTIONS_GHC -fno-warn-orphans #-} module Data.Validity.Sequence where import Data.Validity import Data.Foldable (toList) import Data.Sequence (Seq) -- | 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.4/src/Data/Validity/Set.hs0000644000000000000000000000113013671407511020350 0ustar0000000000000000{-# LANGUAGE CPP #-} {-# 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" ] #if MIN_VERSION_containers(0,6,0) distinctOrd :: Ord a => [a] -> Bool distinctOrd ls = nubOrd ls == ls #endif validity-containers-0.5.0.4/src/Data/Validity/Tree.hs0000644000000000000000000000051213644617172020525 0ustar0000000000000000{-# OPTIONS_GHC -fno-warn-orphans #-} module Data.Validity.Tree where import Data.Validity import Data.Tree -- | 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.4/LICENSE0000644000000000000000000000210413644617172015051 0ustar0000000000000000The MIT License (MIT) Copyright (c) 2016-2020 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.4/Setup.hs0000644000000000000000000000005713644617172015505 0ustar0000000000000000import Distribution.Simple main = defaultMain validity-containers-0.5.0.4/validity-containers.cabal0000644000000000000000000000220213672427714021021 0ustar0000000000000000cabal-version: 1.12 -- This file has been generated from package.yaml by hpack version 0.33.0. -- -- see: https://github.com/sol/hpack -- -- hash: 2e970343bc40866f2768fe78bd9427b658402d4bf787b23ad793a1cae658a82f name: validity-containers version: 0.5.0.4 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 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.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 validity-containers-0.5.0.4/CHANGELOG.md0000644000000000000000000000102513672427700015653 0ustar0000000000000000# Changelog ## [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.