Skip to content

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

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

Closed
wants to merge 2 commits into from

Conversation

ezyang
Copy link
Contributor

@ezyang ezyang commented Jul 6, 2016

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

Signed-off-by: Edward Z. Yang ezyang@cs.stanford.edu

CC @dcoutts @23Skidoo

@23Skidoo
Copy link
Member

23Skidoo commented Jul 6, 2016

Fails on AppVeyor due to -Werror.

@ezyang
Copy link
Contributor Author

ezyang commented Jul 6, 2016

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
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
Copy link
Contributor Author

ezyang commented Jul 6, 2016

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

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

-- TODO: Maybe split this type class into two
Copy link
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
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 <ezyang@cs.stanford.edu>
-- | /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 =
Copy link
Collaborator

@phadej phadej Jul 7, 2016

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
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.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
nodeKey (N _ k _) = k
nodeNeighbors (N _ _ ks) = ks

-- TODO: Maybe introduce a typeclass for items which just
Copy link
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
Copy link
Contributor Author

ezyang commented Jul 11, 2016

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