Skip to content

Add Distribution.Compat.Graph, fixes #3521. - #3523

Closed
ezyang wants to merge 2 commits into
haskell:masterfrom
ezyang:pr/graph
Closed

ezyang wants to merge 2 commits into
haskell:masterfrom
ezyang:pr/graph

Conversation

@ezyang

@ezyang ezyang commented Jul 6, 2016

Copy link
Copy Markdown
Contributor

The intent is for this to be used to replace most of
the current PackageIndex and InstallPlan implementations.

Signed-off-by: Edward Z. Yang [email protected]

CC @dcoutts @23Skidoo

@23Skidoo

23Skidoo commented Jul 6, 2016

Copy link
Copy Markdown
Member

Fails on AppVeyor due to -Werror.

@ezyang

ezyang commented Jul 6, 2016

Copy link
Copy Markdown
Contributor Author

Huh, I wonder why that didn't light up Travis.

return (N a k (ordNub neighbors))
return (fromList ns)

ordNub :: Ord a => [a] -> [a]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the one in D.S.Utils.

@ezyang

ezyang commented Jul 6, 2016

Copy link
Copy Markdown
Contributor Author

Addressed comments and force-pushed. Also a few more functions for interface.

Comment thread Cabal/Distribution/Compat/Graph.hs Outdated
nodeKey (N _ k _) = k
nodeNeighbors (N _ _ ks) = ks

-- TODO: Maybe split this type class into two

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which type, into what?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thought is that IsNode can be decomposed into two typeclasses: one with Key and nodeKey (representing data types that have "keys") and the one that adds nodeNeighbors. The former typeclass is independently useful; e.g., you can provide an alternate Map with insert :: HasKey a => a -> Map a -> Map a (no need to specify key; it's embedded in the item.) But it's not useful for what I needed this for...

@ezyang
ezyang force-pushed the pr/graph branch 2 times, most recently from b247549 to 3832e45 Compare July 6, 2016 23:17
The intent is for this to be used to replace most of
the current PackageIndex and InstallPlan implementations.

Signed-off-by: Edward Z. Yang <[email protected]>
Comment thread Cabal/Distribution/Compat/Graph.hs Outdated
-- | /O(log V)/. Lookup and update. This function returns the changed
-- value if updated, and the original value if it was deleted.
updateLookup :: IsNode a => (a -> Maybe a) -> Key a -> Graph a -> (Maybe a, Graph a)
updateLookup f k g =

@phadej phadej Jul 7, 2016 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should f preserve the nodeKey of the argument, if it returns Just ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I don't need the full generality; I'm going to replace it with deleteLookup.

nodeKey (N _ k _) = k
nodeNeighbors (N _ _ ks) = ks

-- TODO: Maybe introduce a typeclass for items which just

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/which/with/

@ezyang

ezyang commented Jul 11, 2016

Copy link
Copy Markdown
Contributor Author

Typofixed, and merged.

@ezyang ezyang closed this Jul 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants