directory-layout 0.1.0.0 → 0.2.0.0
raw patch · 2 files changed
+26/−3 lines, 2 filesdep +QuickCheckPVP ok
version bump matches the API change (PVP)
Dependencies added: QuickCheck
API changes (from Hackage documentation)
Files
directory-layout.cabal view
@@ -1,7 +1,7 @@ name: directory-layout-version: 0.1.0.0+version: 0.2.0.0 synopsis: Declare, construct and verify directory layout-description: Friendly language to express directory layouts+description: Language to express directory layouts category: System license: MIT license-file: LICENSE@@ -22,9 +22,11 @@ filepath, transformers, parsec,- text+ text,+ QuickCheck ghc-options: -Wall -fno-warn-unused-do-bind+ source-repository head type: git
src/System/Directory/Layout/Internal.hs view
@@ -4,7 +4,11 @@ ( DL(..), Layout ) where +import Control.Applicative+import Control.Arrow+ import Data.Text (Text)+import Test.QuickCheck -- | Abstract data type representing directory tree is nice@@ -30,3 +34,20 @@ E x >>= f = f x F fp c x >>= f = F fp c (x >>= f) D fp x y >>= f = D fp x (y >>= f)+++-- Make arbitrary layout of reasonable size+-- Frequencies are pretty /arbitrary/ chosen with layout construction termination in mind+instance Arbitrary a ⇒ Arbitrary (DL a) where+ arbitrary = snd <$> generator 0+ where+ generator ∷ Arbitrary a ⇒ Int → Gen (Int, DL a)+ generator n = frequency+ [ (8, do+ (n', g') ← generator (succ n)+ generator n' <&> second (D (show n) g'))+ , (20, generator (succ n) <&> second (F (show n) Nothing))+ , (10, arbitrary <&> \r → (n, E r))+ ]+ where+ (<&>) = flip fmap