-
Notifications
You must be signed in to change notification settings - Fork 115
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
WIP: Improvements to make it easier to implement runners other than StandardT #804
base: master
Are you sure you want to change the base?
WIP: Improvements to make it easier to implement runners other than StandardT #804
Conversation
Thought the next release would be small. Seems like the next release would be quite a biggy ) |
Nice thing you showed up with the open PR process. If some parts would become MVP for merge - I am happy to do the multi-merge development process. Chokers are quite hard to merge from the both sides of the coin. |
Hi Anton. I'll have a look at the thunk issues you mentioned. There are probably some parts of this that can be separated: perhaps the Context/ScopeT change and the StableId change could be separate PRs. At the moment, I'm packaging up the example program I was testing these changes against. Hopefully that will help to clarify the reasoning behind some of these changes. I'm also happy to describe them in more detail than I have so far: I just wanted to get this up to get the process started. I also noticed that README-design.md needs to be updated as a result of these changes. |
741f43b
to
a474d77
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
Quite a lot of stuff, with interesting bits flooded into the mass removal of the t
parameter. The simplification of StandardT is a relief.
Now I am waiting for the next update :-)
ref <- defer $ flip nvSet M.empty <$> buildMap | ||
([("builtins", ref)] ++) <$> topLevelBuiltins | ||
let s = M.fromList lst | ||
pushScope s currentScopes |
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 not mere rewriting right. You just fixed the builtins.builtins == builtins issue here. I guess it should make it's way to the release notes ultimately.
@Anton-Latukha what do you think ?
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. Definitely, code looks like solves it.
Looked into the code and tried some. Would reserve giving any ideas or active code here, I need a couple of levels to my type programming game to be able to help or give meaningful ideas in the middle of such change.
From type, errors received it already looks pretty close to recurse on builtins in the type code. At this state it looks like Ali probably would just naturally arrive to replace builtinsBuiltin
with self-referencing builtins
.
Man, our code is terse. It needs or to understand it all togather with Nix internals, or much more documentation (I talk generally, not to Alis case).
|
||
instance MonadStore m => MonadStore (ReaderT r m) | ||
deriving instance MonadStore m => MonadStore (ScopeT binding r m) | ||
instance MonadStore m => MonadStore (StateT s m) |
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.
I may be missing something here, but why are these instances needed ?
Would there be a way to make ScopeT binding r
an instance of MonadTrans
?
None of the other monads in this file required this GeneralizedNewtypeDeriving
+ StandaloneDeriving
. What is special about MonadStore ?
src/Nix/Effects/Derivation.hs
Outdated
buildDerivationWithContext drvAttrs = do | ||
-- Parse name first, so we can add an informative frame | ||
drvName <- getAttr "name" $ extractNixString >=> assertDrvStoreName | ||
drvName <- getAttr "name" $ extractNixString >=> assertDrvStoreName |
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.
Nit: The indent was correct, as the whole line is indented less. Not that important :-).
=> Text -> m a -> (v -> WithStringContextT m a) -> WithStringContextT m a | ||
getAttrOr' n d f = case M.lookup n drvAttrs of | ||
Nothing -> lift d | ||
Just v -> withFrame' Info (ErrorCall $ "While evaluating attribute '" ++ show n ++ "'") $ | ||
fromValue' v >>= f | ||
|
||
getAttrOr :: forall v a. (MonadNix e f m, FromValue v m (NValue' f m (NValue f m))) | ||
=> Text -> a -> (v -> WithStringContextT m a) -> WithStringContextT m a |
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.
Poor you :-/. Having to write these hairy signatures is a pain.
{-# LANGUAGE TypeApplications #-} | ||
|
||
{-# LANGUAGE TypeFamilies #-} | ||
|
||
|
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.
Why are TypeFamilies suddenly required in a lot of places ? It there a simple explanation ?
I guess it is related to the t
parameter being hidden away in the m
one ?
instance MonadTransWrap (ReaderT s) where | ||
liftWrap f a = do | ||
env <- ask | ||
lift $ f $ runReaderT a env |
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.
Am I correct that MonadTransWrap is a simplified MonadBaseControl ? Look very simmilar, with a bit less hassle.
frames | ||
|
||
hnixEvalText :: Options -> Text -> IO (StdValue (StandardT (StdIdT IO))) | ||
hnixEvalText :: Options -> Text -> IO (NValue Identity (StandardT IO)) -- (StdValue (StandardT (FreshStableIdT IO))) |
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.
Reminder to drop the comments in the final iteration :-)
This comment has been minimized.
This comment has been minimized.
A note about rebasing
BTW. I now probably have proper access to the PR branch. Because when we first did it, I was trying to rebase before I seen the email with the agreement. If it needs time, please from time to time keep the thread posted. I see you mentioned it. If something - do not worry about desyncs, we are able to tackle that. The strategy of tacking depends on the main strategy: How do you estimate: PR "goes long", or "goes short? If it goes Big PRs need a lot of recursive rebasing. Learned it from epic PR of robust POSIX Nix installer that I kept in the most ideal for reading it like a guided tour when doing a review and ideal merge state for them for 2 years. I'm no longer salty about it. Just took a lot (a week or three) of git groom rebasing to prettify it into an ideal tour guide to merge. It is Nix If PR goes long
Again, it is because the PRs of this size need frequent rebases, otherwise the complexity of the Git rebase increases. Anyway, the any way you decide it would satisfy me. |
This comment has been minimized.
This comment has been minimized.
aa1b5b1
to
f9f909e
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
f9f909e
to
44708b2
Compare
This comment has been minimized.
This comment has been minimized.
44708b2
to
dcf722d
Compare
This comment has been minimized.
This comment has been minimized.
dcf722d
to
3aa4a1c
Compare
This comment has been minimized.
This comment has been minimized.
* Refactor MonadThunk * Refactor Nix.Thunk.Basic * Add Nix.Thunk.Separate * Add Nix.Fresh.Stable * Add StableId * Remove Scopes from Context and replace with ScopeT * Remove the `t` parameter formerly representing thunks. It can now be inferred from `m` TODO: * [ ] Provide implementations for citations class * [ ] Restore Nix.Lint * [ ] Fix 3 broken tests
3aa4a1c
to
b603325
Compare
Another one. The previous version is at: https://github.com/haskell-nix/hnix/tree/2021-02-18-2-backup-aa/monadthunk-experiment |
Well. I can not stop the work in the project, because of this PR. I do treewide pretty trivial refactors to the source code, doing clean-up, organization, optimization & other stuff. If to rebase - the After the work done in the PR, it would be easier to take the resulting PR diff, and submit it over the new Also after refactors in Thank you also very much, HNix definitely needs this work allowing multithreading. |
News: Think you would find the updated implementation of Standart easier to work with. Over the project, the code complexity that relates to your work was reduced a bit and received help. Code now allows equivalently using both normal and old Kleisli-aware implementations that are now Also new Also in the shortest time, the After that work, renewing, troubleshooting, and merging of the patch should be a relative breeze. Sorry for breaking backward compatibility with the current patch code by giving more convenience. |
Currently, meanwhile from the last post, HNix went through a pretty big refactoring phase. Сode is cleaned-up & better organized, & more documented, which should simplify the work & understanding of things during work. The refactoring phase I was doing is done. Currently, I can stop making changes for a month or two, especially to make things happen or merge something like this, we are also precisely at a phase that: what API breakages are needed - they can be merged without remorse. I am also personally interested in this work. Please, if you want to finish - you can, but write to me so we coordinate efforts. Or would ask at least to supply comprehensive information collected, the idea of it & implementation, on the |
t
parameter formerly representing thunks. It can now be inferred fromm
TODO: