ForestStructures 0.0.0.2 → 0.0.1.0
raw patch · 3 files changed
+98/−4 lines, 3 filesdep +bifunctorsdep +lensPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: bifunctors, lens
API changes (from Hackage documentation)
+ Data.Forest.StructuredPaired: SPE :: SPForest r t
+ Data.Forest.StructuredPaired: SPJ :: [SPForest r t] -> SPForest r t
+ Data.Forest.StructuredPaired: SPR :: r -> SPForest r t
+ Data.Forest.StructuredPaired: SPT :: t -> SPForest r t -> t -> SPForest r t
+ Data.Forest.StructuredPaired: _SPE :: forall r_anax t_anay. Prism' (SPForest r_anax t_anay) ()
+ Data.Forest.StructuredPaired: _SPJ :: forall r_anax t_anay. Prism' (SPForest r_anax t_anay) [SPForest r_anax t_anay]
+ Data.Forest.StructuredPaired: _SPR :: forall r_anax t_anay. Prism' (SPForest r_anax t_anay) r_anax
+ Data.Forest.StructuredPaired: _SPT :: forall r_anax t_anay. Prism' (SPForest r_anax t_anay) (t_anay, SPForest r_anax t_anay, t_anay)
+ Data.Forest.StructuredPaired: data SPForest r t
+ Data.Forest.StructuredPaired: instance (GHC.Classes.Eq r, GHC.Classes.Eq t) => GHC.Classes.Eq (Data.Forest.StructuredPaired.SPForest r t)
+ Data.Forest.StructuredPaired: instance (GHC.Classes.Ord r, GHC.Classes.Ord t) => GHC.Classes.Ord (Data.Forest.StructuredPaired.SPForest r t)
+ Data.Forest.StructuredPaired: instance (GHC.Read.Read r, GHC.Read.Read t) => GHC.Read.Read (Data.Forest.StructuredPaired.SPForest r t)
+ Data.Forest.StructuredPaired: instance (GHC.Show.Show r, GHC.Show.Show t) => GHC.Show.Show (Data.Forest.StructuredPaired.SPForest r t)
+ Data.Forest.StructuredPaired: instance Data.Bifoldable.Bifoldable Data.Forest.StructuredPaired.SPForest
+ Data.Forest.StructuredPaired: instance Data.Bifunctor.Bifunctor Data.Forest.StructuredPaired.SPForest
+ Data.Forest.StructuredPaired: instance Data.Bitraversable.Bitraversable Data.Forest.StructuredPaired.SPForest
+ Data.Forest.StructuredPaired: instance GHC.Generics.Generic (Data.Forest.StructuredPaired.SPForest r t)
+ Data.Forest.StructuredPaired: toStaticForest :: SPForest r t -> Forest p v a
- Data.Forest.Static: [Forest] :: (Vector v a) => {label :: v a Each node @k@ in @[0..n-1]@ has a label at @label ! k@., parent :: Vector Int Each node @k@ has a parent node, or @-1@ if there is no such parent., children :: Vector (Vector Int) Each node @k@ has a vector of indices for its children. For leaf nodes, the vector is empty., lsib :: Vector Int The left sibling for a node @k@. Will *not* cross subtrees. I.e. if @k@ is @lsib@ of @l@, then @k@ and @l@ have the same parent., rsib :: Vector Int The right sibling for a node @k@., roots :: Vector Int The roots of the individual trees, the forest was constructed from.} -> Forest p v a
+ Data.Forest.Static: [Forest] :: Vector v a => {label :: v a " Each node @k@ in @[0..n-1]@ has a label at @label ! k@.", parent :: Vector Int " Each node @k@ has a parent node, or @-1@ if there is no such parent.", children :: Vector (Vector Int) " Each node @k@ has a vector of indices for its children. For leaf nodes, the vector is empty.", lsib :: Vector Int " The left sibling for a node @k@. Will *not* cross subtrees. I.e. if @k@ is @lsib@ of @l@, then @k@ and @l@ have the same parent.", rsib :: Vector Int " The right sibling for a node @k@.", roots :: Vector Int " The roots of the individual trees, the forest was constructed from."} -> Forest p v a
- Data.Forest.Static: forestPost :: (Vector v a) => [Tree a] -> Forest Post v a
+ Data.Forest.Static: forestPost :: Vector v a => [Tree a] -> Forest Post v a
- Data.Forest.Static: forestPre :: (Vector v a) => [Tree a] -> Forest Pre v a
+ Data.Forest.Static: forestPre :: Vector v a => [Tree a] -> Forest Pre v a
- Data.Forest.Static: forestWith :: (Vector v a) => (forall a. [Tree a] -> [a]) -> [Tree a] -> Forest (p :: TreeOrder) v a
+ Data.Forest.Static: forestWith :: Vector v a => (forall a. [Tree a] -> [a]) -> [Tree a] -> Forest (p :: TreeOrder) v a
Files
- Data/Forest/StructuredPaired.hs +82/−0
- ForestStructures.cabal +11/−4
- changelog.md +5/−0
+ Data/Forest/StructuredPaired.hs view
@@ -0,0 +1,82 @@++-- | A semi-specialized forest structure with the following atomic elements:+-- (i) unstructured regions of type @a@, (ii) binary paired regions of type+-- @(b,b)@ with a recursing tree (or insertion between the two @b@'s), (iii)+-- juxtaposition of two elements, and (iv) an empty structure.++module Data.Forest.StructuredPaired where++import Control.Lens+import Data.Bifoldable+import Data.Bifunctor+import Data.Bitraversable+import Data.Monoid+import GHC.Generics (Generic)++import Data.Forest.Static++++-- | A structured forest.++data SPForest r t+ -- | An (unstructured) region with the structured forest. In case @r@ forms a+ -- monoid @SPJ (SPR a) (SPR b) `equiv` SPR (a<>b)@ should hold.+ = SPR r+ -- | A tree within the forest brackets the forest on the left and right side+ -- with elements of type @t@.+ | SPT t (SPForest r t) t+ -- | Juxtaposition of two forests. This allows for simple concatenation of+ -- forests. In particular, there is no particular position, while lists+ -- prefer @x:xs@ vs @xs++[x]@.+ | SPJ [SPForest r t]+ -- | An empty forest. @SPJ SPE SPE `equiv` SPE@ should hold.+ | SPE+ deriving (Read,Show,Eq,Ord,Generic)+makePrisms ''SPForest++instance Bifunctor SPForest where+ first f = \case+ SPR r → SPR (f r)+ SPT l t r → SPT l (first f t) r+ SPJ xs → SPJ (map (first f) xs)+ SPE → SPE+ {-# Inlinable first #-}+ second g = \case+ SPR r → SPR r+ SPT l t r → SPT (g l) (second g t) (g r)+ SPJ xs → SPJ (map (second g) xs)+ SPE → SPE+ {-# Inlinable second #-}+ bimap f g = \case+ SPR r → SPR (f r)+ SPT l t r → SPT (g l) (bimap f g t) (g r)+ SPJ xs → SPJ (map (bimap f g) xs)+ SPE → SPE+ {-# Inlinable bimap #-}++instance Bifoldable SPForest where+ bifoldMap f g = \case+ SPR r → f r+ SPT l t r → g l <> bifoldMap f g t <> g r+ SPJ xs → error "Bifoldable" -- mconcatMap (bifoldMap f g) xs+ SPE → mempty+ {-# Inlinable bifoldMap #-}++instance Bitraversable SPForest where+ bitraverse f g = \case+ SPR r → SPR <$> f r+ SPT l t r → SPT <$> g l <*> bitraverse f g t <*> g r+ SPJ xs → error "Bitraversable" -- SPJ <$> bitraverse f g l <*> bitraverse f g r+ SPE → pure SPE+ {-# Inlinable bitraverse #-}++++-- | Structured Forests can be transformed into static forests.+--+-- TODO types involved!++toStaticForest ∷ SPForest r t → Forest p v a+toStaticForest = undefined+
ForestStructures.cabal view
@@ -1,7 +1,7 @@ name: ForestStructures-version: 0.0.0.2-author: Christian Hoener zu Siederdissen, Sarah Berkemer, 2015-2017-copyright: Christian Hoener zu Siederdissen, 2015-2017+version: 0.0.1.0+author: Christian Hoener zu Siederdissen 2015-2018, Sarah Berkemer, 2015-2017+copyright: Christian Hoener zu Siederdissen, 2015-2018 homepage: https://github.com/choener/ForestStructures bug-reports: https://github.com/choener/ForestStructures/issues maintainer: choener@bioinf.uni-leipzig.de@@ -11,7 +11,7 @@ build-type: Simple stability: experimental cabal-version: >= 1.10.0-tested-with: GHC == 7.10.3, GHC == 8.0.2+tested-with: GHC == 8.4.4 synopsis: Tree- and forest structures description: This library provides both static and dynamic tree and forest@@ -31,27 +31,34 @@ library build-depends: base >= 4.7 && < 5.0+ , bifunctors >= 5.0 , containers >= 0.5 , fgl >= 5.5+ , lens >= 4.0 , QuickCheck >= 2.0 , unordered-containers >= 0.2 , vector >= 0.10 , vector-th-unbox >= 0.2 exposed-modules: Data.Forest.Static+ Data.Forest.StructuredPaired default-language: Haskell2010 default-extensions: BangPatterns , AllowAmbiguousTypes , DataKinds+ , DeriveGeneric , FlexibleContexts , GADTs , KindSignatures+ , LambdaCase , OverloadedStrings , RankNTypes , RecordWildCards , StandaloneDeriving+ , TemplateHaskell , UndecidableInstances+ , UnicodeSyntax ghc-options: -O2
changelog.md view
@@ -1,3 +1,8 @@+0.0.1.0+-------++- structured forests, mostly for secondary structures of RNA+ 0.0.0.2 -------