Skip to content

Conversation

@jorisdral
Copy link
Collaborator

No description provided.

@jorisdral jorisdral self-assigned this Aug 13, 2024
As a result, quite a few types are now parameterised over a state parameter `s`
(e.g., `RealWorld` for `IO`). This change causes quite a bit of noise, but it's
necessary for generalising all our code away from just `IO`.

I have also considered whether it would be better to parameterise these types by
a monad `m` instead of the state type `s`. An `m` parameter is slightly more
general, since we can use `PrimState m` whenever `s` would be required. In the
spirit of the YAGNI principle, I decided not to do that (for now). We can make
that change later if turns out to be necessary.
@jorisdral jorisdral force-pushed the jdral/mutvar-for-ioref branch from 07d83f2 to 3a93441 Compare August 14, 2024 09:42
@jorisdral
Copy link
Collaborator Author

BTW, I'm running the micro-benchmarks locally to see if the changes lead to a regression

@jorisdral
Copy link
Collaborator Author

BTW, I'm running the micro-benchmarks locally to see if the changes lead to a regression

Okay, as far as I can see there is no noticeable regression.

Copy link
Collaborator

@mheinzel mheinzel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type parameter spreads into quite a lot of types, but we will need this for io-sim, right?

Comment on lines +878 to +881
#ifdef NO_IGNORE_ASSERTS
void $ stToIO $ _levelsInvariant conf ls'
#endif
return ls'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, what is the advantage of using CPP here?

Is it because the invariant is not really a predicate (always returning True), so it would be weird to use assert? In that case, we could also change it to return () now and get rid of the void.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current levelsInvariant doesn't actually read mutable variables, so we can run it purely, but once we add ongoing merges we'll have to read mutable variables to inspect the state of an ongoing merge. As such, we can't use runST anymore, and we have to instead embed the invariant check into IO

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And reading the variable won't be possible in ST, like with MutVar? Okay, we'll see what it looks like then.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that runST is polymorphic over s, while in this addRunToLevels function we have s ~ RealWorld (or more precisely, s ~ PrimState m), so we have to embed using stToIO

@jorisdral
Copy link
Collaborator Author

The type parameter spreads into quite a lot of types, but we will need this for io-sim, right?

Yes, we'll need either a state parameter s or a monad parameter m. For now, we're sticking with s

@jorisdral jorisdral added this pull request to the merge queue Aug 20, 2024
Merged via the queue into main with commit dd8aac1 Aug 20, 2024
@jorisdral jorisdral deleted the jdral/mutvar-for-ioref branch August 20, 2024 12:17
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

Successfully merging this pull request may close these issues.

4 participants