-
Notifications
You must be signed in to change notification settings - Fork 37
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
Add evalState(T)
#411
Add evalState(T)
#411
Conversation
The CI doesn't run for 12 minutes, fortunately (that would be more than a little bug). It was just waiting for someone with push rights to approve the CI. This is a Github thing, to prevent people from using pull requests as a free computing resource (typically to mine bitcoin or the like). |
tasty-hedgehog, | ||
tasty-hedgehog < 1.2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a little concerning. I assume you've needed that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, otherwise cabal build
would fail. I am using GHC 9.2.2.
I think this restriction can be lifted if the underlying problem is fixed:
Building test suite 'test' for linear-base-0.2.0..
[1 of 9] Compiling Test.Data.Destination ...
test/Test/Data/Destination.hs:22:7: error: [-Wdeprecations, -Werror=deprecations]
In the use of ‘testProperty’ (imported from Test.Tasty.Hedgehog):
Deprecated: "testProperty will cause Hedgehog to provide incorrect instructions for re-checking properties"
|
22 | [ testProperty "alloc . mirror = id" roundTrip,
| ^^^^^^^^^^^^
This deprecation was introduced in tasty-hedgehog-1.2
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment to the .cabal file to explain why this bound is needed.
-- | Use with care! | ||
-- This consumes the final state, so might be costly at runtime. | ||
evalStateT :: (Functor m, Consumable s) => StateT s m a %1 -> s %1 -> m a | ||
evalStateT f = fmap Linear.fst . runStateT f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah now I see the problem with #405 . I didn't remember we had this version of fst
available as well.
Ah yes… we've been needing to provide Ormolu via stack, so it needs to be built once which probably takes a little bit of time. I wonder how the cache logic works on forks… maybe that's the rub… Please let me know if it happens again next time you make a PR. |
How does this help the |
@treeowl wrote:
Er, I cannot follow. Maybe you had some prior discussion of this issue? Do you have a pointer to it? Atm, the continuation of |
`fst` is the name of the first projection, `first` is the name of a bifunctor action.
Use case: stateful interpreter (`eval`) for C-like expressions `e`: ```haskell let Ur value = HashMap.empty capacity (\ env -> move (evalState (eval e) env)) ``` This pattern breaks the "jail" set by the type signature of `HashMap`-allocation: ```haskell empty :: Int -> (HashMap k v %1 -> Ur b) %1 -> Ur b ``` `HashMap` is not `Movable` but `Consumable`, so we can get rid of it before `move`ing the result to `Ur`.
(I'll get to merging this soon, I haven't had time so far, but it will be merged, sorry about the delay) |
Thanks @andreasabel . Let me merge. |
Fix #404: add
evalState
andevalStateT
.Use case: stateful interpreter (
eval
) for C-like expressionse
:This pattern breaks the "jail" set by the type signature of
HashMap
-allocation:HashMap
is notMovable
butConsumable
, so we can get rid of it beforemove
ing the result toUr
.PS: Your ormolu CI workflow is quite a gatekeeper, running for 12min... I tried to run it locally after
stack install ormolu
, but this didn't produce the same formatting.