NickHu / homotopy-io

Rewritten homotopy-core
3 stars 2 forks source link

Decycling/deduplication. #12

Closed jamievicary closed 4 years ago

jamievicary commented 4 years ago

The data structure needs to be decycled and deduplicated after every interaction.

(Not necessary for the initial working version.)

NickHu commented 4 years ago

The hope is to just build diagrams in a way which reuses memory in a sensible way (à la memoization) rather than having to do this hack

jamievicary commented 4 years ago

I wouldn't call it a hack, I would call it an optimization. But anyway, I agree it's better to do this on object creation. This seems like a standard requirement for functional programs -- I wonder if there are any existing PureScript techniques for achieving this.

To be clear, I am assuming that currently, if you call a constructor twice with exactly the same arguments, you will get back two different instances of the type being constructed -- can you confirm that's the case.

jamievicary commented 4 years ago

I guess this is relevant: https://pursuit.purescript.org/packages/purescript-memoize/5.0.0/docs/Data.Function.Memoize