Skip to content
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

Properly handle node/edge metadata #13

Open
ggazzi opened this issue Mar 27, 2017 · 0 comments
Open

Properly handle node/edge metadata #13

ggazzi opened this issue Mar 27, 2017 · 0 comments

Comments

@ggazzi
Copy link
Member

ggazzi commented Mar 27, 2017

Rationale

Sometimes it would be useful to associate some metadata to nodes and edges, that is used e.g. for the GUI or documentation purposes, and have it properly handled and propagated to outputs.

A simple example are the positions of nodes. It could be useful for critical pairs to have a (preliminary) node layout that is based on the node layout of the rules. This layout would then be refined by some algorithm in the GUI.

In order to do this, we'd probably need to include this metadata into the payloads of nodes and edges. We'd also need to figure out how to properly handle these payloads in basic categorial operations such as pullbacks, pushouts, overlappings, etc. This would probably involve having a type class with the necessary operations.

Monoidal Metadata

A first suggestion would be to use the Monoid class, which describes types that have an "empty" value and can be arbitrarily combined. Then any elements created from scratch would have the "empty metadata, elements created from a single other element would have the metadata copied and elements created from multiple other elements (e.g. in an overlapping or pushout) would have the metadata combined.

In the example of using positions, the following type could be used as metadata:

type Position
  = Position Float Float
  | NoPosition
  
  
instance Monoid Position where
  mempty = NoPosition
  
  mappend NoPosition p = p
  mappend p NoPosition = p
  mappend (Position x1 y1) (Position x2 y2) = Position ((x1+x2)/2) ((y1+y2)/2)

We still have to check if Monoid is enough, and how exactly the metadata is propagated by the primitive operations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant