lichess-org/scalachess

Expose situationAfter via MoveOrDrop

greg-finley opened this issue · 5 comments

Love the refactor to a union type in #368

However, I think I can't get situationAfter anymore like I could when folding the Either: https://github.com/greg-finley/lichess-bigquery/blob/4319f5ab3b4a62523fe91fd8df9d3e097dcefad5/src/main/scala/Main.scala#L126

I tried to fix it myself but I am forgetting my Scala

cc @lenguyenthanh

Hi @greg-finley, it's so great to know someone else is using scalachess! Please give us more feedback as you use it. I'd love to make scalachess more accessible.

I think you still can use situationAfter in fold as before, because we still have situationAfter: https://github.com/lichess-org/scalachess/blob/master/src/main/scala/Drop.scala#L18

I also looked briefly at your code, I don't know why it is not compiled. Can you past the error here?

Oh sorry! I was linking to main which was still on the old version.

Here is the broken code now: greg-finley/lichess-bigquery#2

[error] -- [E008] Not Found Error: /Users/gregoryfinley/git-repos/lichess-bigquery/src/main/scala/Main.scala:113:37 
[error] 113 |                          moveOrDrop.situationAfter,
[error]     |                          ^^^^^^^^^^^^^^^^^^^^^^^^^
[error]     |              value situationAfter is not a member of chess.MoveOrDrop
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 3 s, completed Feb 19, 2023, 11:53:35 PM

I think this file src/main/scala/MoveOrDrop.scala would need to define situationAfter, like how it defines toUci.

If I bump without changing the Scala code, I will hit:

error] -- [E008] Not Found Error: /Users/gregoryfinley/git-repos/lichess-bigquery/src/main/scala/Main.scala:106:20 
[error] 106 |                  x.fold(
[error]     |                  ^^^^^^
[error]     |                  value fold is not a member of chess.MoveOrDrop
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 3 s, completed Feb 19, 2023, 11:58:31 PM

I see you gave me fold again, so not sure why I can't use it. Though I prefer not to fold if enough methods are exposed on MoveOrDrop. What do you think?

Ah, sorry, if I bump and add the new import (like you did in your tests in your PR), then it works! greg-finley/lichess-bigquery@30043dd

Sorry for the noise :) I'm trying to learn Scala again haha

And thanks for your help!

no worries, glad you solved it. Hope the best for your scala journey.