packages feed

rose-trees 0.0.4 → 0.0.4.1

raw patch · 6 files changed

+36/−3 lines, 6 filesPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ Data.Tree.Hash: elemPath :: Eq a => [a] -> HashTree a -> Bool
+ Data.Tree.Hash: instance (GHC.Classes.Eq a, Data.Hashable.Class.Hashable a, Test.QuickCheck.Arbitrary.Arbitrary a) => Test.QuickCheck.Arbitrary.Arbitrary (Data.Tree.Hash.HashTree a)
+ Data.Tree.Knuth: elemPath :: Eq a => [a] -> KnuthTree a -> Bool
+ Data.Tree.Knuth.Forest: elemPath :: Eq a => [a] -> KnuthForest a -> Bool
+ Data.Tree.Rose: instance Data.Tree.Rose.RoseTree Data.Tree.Hash.HashTree
+ Data.Tree.Set: elemPath :: Eq a => [a] -> SetTree a -> Bool

Files

rose-trees.cabal view
@@ -1,5 +1,5 @@ Name:                   rose-trees-Version:                0.0.4+Version:                0.0.4.1 Author:                 Athan Clark <athan.clark@gmail.com> Maintainer:             Athan Clark <athan.clark@gmail.com> License:                BSD3
src/Data/Tree/Hash.hs view
@@ -21,6 +21,8 @@ import Data.Data import GHC.Generics import Control.DeepSeq+import Test.QuickCheck+import Test.QuickCheck.Instances   data HashTree a = HashTree@@ -34,6 +36,9 @@  instance NFData a => NFData (HashTree a) +instance (Eq a, Hashable a, Arbitrary a) => Arbitrary (HashTree a) where+  arbitrary = HashTree <$> arbitrary <*> arbitrary+ instance Foldable1 HashTree where   fold1 (HashTree x xs) = F.foldr (\a acc -> sNode a <> acc) x xs @@ -52,6 +57,11 @@ -- | set-like alias for @isDescendantOf@. elem :: Eq a => a -> HashTree a -> Bool elem = isDescendantOf++elemPath :: Eq a => [a] -> HashTree a -> Bool+elemPath [] _ = True+elemPath (x:xs) (HashTree y ys) =+  (x == y) && getAny (F.foldMap (Any . elemPath xs) ys)  size :: HashTree a -> Int size (HashTree _ xs) = 1 + getSum (F.foldMap (Sum . size) xs)
src/Data/Tree/Knuth.hs view
@@ -82,6 +82,10 @@ elem :: Eq a => a -> KnuthTree a -> Bool elem x (KnuthTree (y,ys)) = x == y || KF.elem x ys +elemPath :: Eq a => [a] -> KnuthTree a -> Bool+elemPath [] _ = True+elemPath (x:xs) (KnuthTree (y,ys)) = x == y && KF.elemPath xs ys+ isSubtreeOf :: Eq a => KnuthTree a -> KnuthTree a -> Bool isSubtreeOf xss yss@(KnuthTree (_,ys)) = xss == yss || go ys   where
src/Data/Tree/Knuth/Forest.hs view
@@ -123,6 +123,11 @@ elem _ Nil = False elem x (Fork y yc ys) = x == y || elem x ys || elem x yc +elemPath :: Eq a => [a] -> KnuthForest a -> Bool+elemPath [] _ = True+elemPath (x:xs) (Fork y yc ys) = (x == y && elemPath xs ys) || elemPath (x:xs) yc+elemPath _ Nil = False+ -- Top-down, breadth-first isSubforestOf :: Eq a => KnuthForest a -> KnuthForest a -> Bool isSubforestOf Nil _ = True
src/Data/Tree/Rose.hs view
@@ -12,7 +12,9 @@ import Data.Tree.Knuth import Data.Tree.Knuth.Forest as KF import Data.Tree.Set+import Data.Tree.Hash import qualified Data.Set as Set+import qualified Data.HashSet as HS   type family Head (x :: *) :: *@@ -54,3 +56,11 @@  instance RoseTree SetTree where   (@->) = SetTree+++-- Data.Tree.Hash+type instance Head (HashTree a) = a+type instance Tail (HashTree a) = HS.HashSet (HashTree a)++instance RoseTree HashTree where+  (@->) = HashTree
src/Data/Tree/Set.hs view
@@ -15,7 +15,6 @@ import Data.Semigroup import Data.Semigroup.Foldable import qualified Data.Set.Class as Sets-import Control.Applicative import Control.Monad  import Data.Data@@ -33,7 +32,7 @@ instance NFData a => NFData (SetTree a)  instance (Ord a, Arbitrary a) => Arbitrary (SetTree a) where-  arbitrary = liftA2 SetTree arbitrary arbitrary+  arbitrary = SetTree <$> arbitrary <*> arbitrary  instance Foldable1 SetTree where   fold1 (SetTree x xs) = F.foldr (\a acc -> sNode a <> acc) x xs@@ -53,6 +52,11 @@ -- | set-like alias for @isDescendantOf@. elem :: Eq a => a -> SetTree a -> Bool elem = isDescendantOf++elemPath :: Eq a => [a] -> SetTree a -> Bool+elemPath [] _ = True+elemPath (x:xs) (SetTree y ys) =+  (x == y) && getAny (F.foldMap (Any . elemPath xs) ys)  size :: SetTree a -> Int size (SetTree _ xs) = 1 + getSum (F.foldMap (Sum . size) xs)