-
Notifications
You must be signed in to change notification settings - Fork 20
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
Different preludes for different folders #56
Comments
I also think the user should be able to use different preludes for different purposes. I see only one small drawback in your idea: the user can use only one prelude for each directory (the fall back or the one inside ./.hawk/prelude.hs). I don't know if this can be a problem. Another approach would be to have an option to specify the prelude directory (hawk -p ./.hawk does exactly what you were saying). In this case the user could select the right prelude in any moment. This idea is more verbose than yours. |
Maybe there could be a flag to explicitly specify the prelude to use (hmm, I thought we already had that, apparently not), and if nothing is specified it would default to searching parent directories? Another idea: instead of defaulting to ~/.hawk/prelude.hs, maybe we could combine it with the one specified on the command-line or found in a parent directory? |
I'm don't understand the second idea, can you elaborate it (in particular the idea of combine)? The first one is ok for me. |
By "combining" prelude files, I mean that the user expression would have access to function definitions from both files. This way, users can put frequently used custom functions in their ~/.hawk/prelude.hs, and their project-specific custom functions in their project-specific prelude files. |
For this I need a new option. Before I code it I have two questions: 1 - do you mind if I call the directory
in all the other cases Hawk should give error. That means that we need
file :: OptionType
file = Setting "file"
consumeFile :: MonadIO m => (String -> ErrorT String m Bool) -> OptionConsumer m String
consumeFile checker (Just f) = ...
consumeFile checker Nothing = error "please use consumeNullable to consume nullable options"
... and that's it, right? Is it correct? I have to admit that your library for working with arg/option/spec is still new to me :-). |
Created the branch different_preludes to add this feature. |
Sure, call it whatever you want.
Since the option is called
That's a good idea! When I implemented OptionParserT, I was thinking that there should be a
Why
Yes, you will need to change a few type constraints from
Actually, I think this is the part at which it starts to become complicated :) There are probably many places which use
It's new for everyone :) But from what you wrote, you seem to understand all of it already. |
I have implemented this in the different_preludes branch with the commit 5d52e86. It's working and all the tests are passing. I would like to continue to work on this because I need to add the support for projects configurations and I also would like to clean the I also have doubts on which module should handle the creation of a default config directory if this doesn't exist. Currently there is a function By the way, it's nice to be able to write: > hawk -c /tmp/fakehawkconf 1
warning: directory '/tmp/hawk2' doesn't exist, creating a default one
1 |
Yes, I think Meanwhile, I am working on spreading the use of Uncertain instead of Either. |
Should we create migration code which removes the |
We should have a |
The logic for versioning could be quite simple: if there is no |
I have implemented the projects custom context in the commit a5ff205. Now if the I added a few functions to I don't use I'm not closing this because I can't make tests working..the problem is that I should create temporary directories and remove them. I will do it. One last point: I've added the liftUncertain = OptionParserT . lift . lift I think it is ok but can you confirm it for me? I just noticed that the time to run |
Looks good!
It's slower than before? By how much? I think that since the refactoring is incomplete, we are probably doing a lot of work twice, so if it was taking 0.2s before, that gives us a good idea why. |
I measure 0.24s on So if it's a regression, it's been there since before 1.0. |
As requested in #86 I merged different_preludes in develop. |
I have removed the different_preludes branch and I'm closing this. For future work on this we will open another issue. |
What is the purpose of the user prelude? Is it meant to accumulate the multitude of helper functions which our users have built over the years, or to help users cope with commands which would otherwise take more than one line?
I like to use it for the latter, and as a consequence I have many versions of my user prelude, because I don't like when it becomes too big and because the functions I write for one project are rarely useful in the next project.
To cater to this use case, I propose to follow git's model of user preferences: look into the parent directories for a .git/config file (in our case .hawk/prelude.hs), and fall back to ~/.gitconfig (in our case ~/.hawk/prelude.hs) if none is found.
What do you think?
The text was updated successfully, but these errors were encountered: