-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify dual #7
Open
cchalmers
wants to merge
15
commits into
master
Choose a base branch
from
simplify-dual
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
8056607
Rewrite DUALTree internal representation
cchalmers dd038f3
Fixes
cchalmers 47d0d7d
Comments
cchalmers 993099d
Hide Control.Applicative for ghc<7.10
cchalmers 4b5ae70
Act on static a annotations
cchalmers 9b98b65
Add Foldable and Traversable instances
cchalmers ea340ae
Add foldDUAL' variant
cchalmers 7af3f28
Remove foldable and traversable instances
cchalmers febc175
Comment typos
cchalmers 10cdcbe
Add back other-extensions to cabal file
cchalmers 3551808
Fix pre/post applyU function
cchalmers ba3103a
DALTrees are not non-empty
cchalmers a0ffb46
Document that a annotations are acted on
cchalmers 91927d6
Update license
cchalmers 081669a
update some Haddock comments
byorgey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Copyright (c) 2011-2013, dual-tree team: | ||
Copyright (c) 2011-2015, dual-tree team: | ||
|
||
Christopher Chalmers <[email protected]> | ||
Jeffrey Rosenbluth <[email protected]> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
----------------------------------------------------------------------------- | ||
-- | | ||
-- Module : Data.Tree.DUAL | ||
-- Copyright : (c) 2011-2012 Brent Yorgey | ||
-- Copyright : (c) 2011-2015 dual-tree team (see LICENSE) | ||
-- License : BSD-style (see LICENSE) | ||
-- Maintainer : [email protected] | ||
-- | ||
|
@@ -17,24 +17,13 @@ | |
-- of monoidal annotations, one (of type @u@) travelling \"up\" the | ||
-- tree and one (of type @d@) traveling \"down\". | ||
-- | ||
-- Specifically, there are five types of nodes: | ||
-- Specifically, there are three types of nodes: | ||
-- | ||
-- * Leaf nodes which contain a data value of type @l@ and an | ||
-- annotation of type @u@. The annotation represents information | ||
-- about a tree that should be accumulated (/e.g./ number of | ||
-- leaves, some sort of \"weight\", /etc./). If you are familiar | ||
-- with finger trees | ||
-- (<http://www.soi.city.ac.uk/~ross/papers/FingerTree.html>, | ||
-- <http://hackage.haskell.org/package/fingertree>), it is the | ||
-- same idea. | ||
-- | ||
-- * There is also a special type of leaf node which contains only a | ||
-- @u@ value, and no data. This allows cached @u@ values to be | ||
-- \"modified\" by inserting extra annotations. | ||
-- * Leaf nodes which contain a data value of type @l@. | ||
-- | ||
-- * Branch nodes, containing a list of subtrees. | ||
-- | ||
-- * Internal nodes with a value of type @d@. @d@ may have an | ||
-- * Internal nodes with a value of type @d@. @d@ may have an | ||
-- /action/ on @u@ (see the 'Action' type class, defined in | ||
-- "Data.Monoid.Action" from the @monoid-extras@ package). | ||
-- Semantically speaking, applying a @d@ annotation to a tree | ||
|
@@ -44,45 +33,51 @@ | |
-- constant time. | ||
-- | ||
-- * Internal nodes with data values of type @a@, possibly of a | ||
-- different type than those in the leaves. These are just \"along | ||
-- for the ride\" and are unaffected by @u@ and @d@ annotations. | ||
-- different type than those in the leaves. These annotations are | ||
-- acted on by any @d@ annotations above it. | ||
-- | ||
-- The @u@ annotation represents information about a tree that should | ||
-- be accumulated (/e.g./ number of leaves, some sort of \"weight\", | ||
-- /etc./). If you are familiar with finger trees | ||
-- (<http://www.soi.city.ac.uk/~ross/papers/FingerTree.html>, | ||
-- <http://hackage.haskell.org/package/fingertree>), it is the same | ||
-- idea. | ||
-- | ||
-- There are two critical points to note about @u@ and @d@ annotations: | ||
-- | ||
-- * The combined @u@ annotation for an entire tree is always cached | ||
-- at the root and available in constant (amortized) time. | ||
-- at the root and available in constant time. | ||
-- | ||
-- * The 'mconcat' of all the @d@ annotations along the path from | ||
-- the root to each leaf is available along with the leaf during a | ||
-- fold operation. | ||
-- | ||
-- A fold over a @DUALTree@ is given access to the internal and leaf | ||
-- data, and the accumulated @d@ values at each leaf. It is also | ||
-- allowed to replace \"@u@-only\" leaves with a constant value. In | ||
-- particular, however, it is /not/ given access to any of the @u@ | ||
-- annotations, the idea being that those are used only for | ||
-- /constructing/ trees. It is also not given access to @d@ values as | ||
-- they occur in the tree, only as they accumulate at leaves. If you | ||
-- do need access to @u@ or @d@ values, you can duplicate the values | ||
-- you need in the internal data nodes. | ||
-- data, and the accumulated @d@ values at each leaf. In particular, | ||
-- however, it is /not/ given access to any of the @u@ annotations, the | ||
-- idea being that those are used only for /constructing/ trees. It is | ||
-- also not given access to @d@ values as they occur in the tree, only | ||
-- as they accumulate at leaves. If you do need access to @u@ or @d@ | ||
-- values, you can duplicate the values you need in the internal data | ||
-- nodes. | ||
-- | ||
----------------------------------------------------------------------------- | ||
|
||
module Data.Tree.DUAL | ||
( | ||
-- * DUAL-trees | ||
DUALTree | ||
( | ||
-- * DUAL-trees | ||
DUALTree | ||
|
||
-- * Constructing DUAL-trees | ||
, empty, leaf, leafU, annot, applyD | ||
-- * Constructing DUAL-trees | ||
, leaf, leafU, annot, down | ||
|
||
-- * Modifying DUAL-trees | ||
, applyUpre, applyUpost | ||
, mapU | ||
-- * Modifying DUAL-trees | ||
, _u, mapU, preapplyU, postapplyU | ||
|
||
-- * Accessors and eliminators | ||
, getU, foldDUAL, flatten | ||
-- * Accessors and eliminators | ||
, getU, foldDUAL, foldDUAL', flatten | ||
|
||
) where | ||
) where | ||
|
||
import Data.Tree.DUAL.Internal | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove the
other-extensions
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't actually remember. I'll add it back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Of course the specific list of extensions used has probably changed.