packages feed

rose-trees 0.0.1 → 0.0.1.1

raw patch · 2 files changed

+38/−1 lines, 2 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

Files

rose-trees.cabal view
@@ -1,5 +1,5 @@ Name:                   rose-trees-Version:                0.0.1+Version:                0.0.1.1 Author:                 Athan Clark <athan.clark@gmail.com> Maintainer:             Athan Clark <athan.clark@gmail.com> License:                BSD3@@ -14,6 +14,7 @@   HS-Source-Dirs:       src   GHC-Options:          -Wall   Exposed-Modules:      Data.Tree.Rose+                        Data.Tree.Knuth   Other-Modules:        Data.Tree.Rose.Internal   Build-Depends:        base >= 4 && < 5                       , containers
+ src/Data/Tree/Knuth.hs view
@@ -0,0 +1,36 @@+{-# LANGUAGE KindSignatures #-}+{-# LANGUAGE DeriveFunctor #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}++module Data.Tree.Knuth where++import Prelude hiding (foldr)+import Data.Monoid+import Data.Foldable++data KnuthForest a = Fork { node :: a+                          , children :: (KnuthForest a)+                          , siblings :: (KnuthForest a) }+                   | Nil+  deriving (Show, Eq, Functor)++appendSibling :: KnuthForest a -> KnuthForest a -> KnuthForest a+appendSibling Nil _ = Nil+appendSibling (Fork x xc Nil) y = Fork x xc y+appendSibling (Fork x xc xs) y = Fork x xc $ appendSibling xs y++instance Monoid (KnuthForest a) where+  mempty = Nil+  mappend = appendSibling++instance Foldable KnuthForest where+  foldr f acc Nil = acc+  foldr f acc (Fork x xc xs) =+    foldr f (foldr f (f x acc) xs) xc++newtype KnuthTree a = KnuthTree { unKnuthTree :: (a, KnuthForest a) }+  deriving (Show, Eq, Functor)++-- | Breadth-first+instance Foldable KnuthTree where+  foldr f acc (KnuthTree (x, xs)) = foldr f (f x acc) xs