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

abstract "[state]" to "t state" #16

Open
arnemileswinter opened this issue Jan 8, 2022 · 3 comments
Open

abstract "[state]" to "t state" #16

arnemileswinter opened this issue Jan 8, 2022 · 3 comments

Comments

@arnemileswinter
Copy link

arnemileswinter commented Jan 8, 2022

Hello thanks for this library :)

Do you think we could somehow abstract the [state] type for result paths?

If I'm not mistaken it could be a Monoid, Foldable instance, or possibly a custom Path typeclass with a predefined instance for [].

I'm thinking it might be helpful if the found path is to be reversed after it was found (and therefore couldve been constructed in a different order using for example :<| :|> from Data.Sequence), or within a monadic context some specialized type other than [state].

-> Maybe [state]

@arnemileswinter arnemileswinter changed the title parameterize "[state]" to "t state" abstract "[state]" to "t state" Jan 8, 2022
@devonhollowood
Copy link
Owner

I'm not opposed to this, but I don't have the time to implement it at the moment. I'd happily accept a PR, otherwise I will give it a shot when I have a chance. My preference would be to abstract it to Foldable -- what are your thoughts on that option vs. others?

My concerns are:

  1. I'm not sure how invasive a change this will be. I suspect it won't be too bad, though.
  2. I don't want this to be a breaking change for most users. My understanding is that this is only a breaking change for edge cases, but I would like to better understand that before implementing.

@arnemileswinter
Copy link
Author

a Foldable instance definitely makes sense on the consumer side, whereas library-wise we'd need to somehow abstract over cons'ing path elements - i dont think Foldable has functions for this - maybe a Monoid makes sense but it might have overhead i think, because from what i know <> is more involved than :...

I see there's a benchmarking test-bed so that will be helpful.

Having written the issue i noticed a common pattern to skip reversing the found path is to simply swap the goal-state with the initial-state.
While this might work, I'm concerned that's mostly for textbook path finding problems such as maze solving and less where the goal state is an exploratory/pruned estimate such as in chess.

I'm considering writing a PR once my semester gets less cluttered, should be around february. :)

@devonhollowood
Copy link
Owner

Sounds good! Let me know if you start working on it, so that we don't duplicate our work.

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

No branches or pull requests

2 participants