Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Remove state cwd #47

Merged
merged 1 commit into from
Nov 12, 2015
Merged

Remove state cwd #47

merged 1 commit into from
Nov 12, 2015

Conversation

gracjan
Copy link
Contributor

@gracjan gracjan commented Nov 8, 2015

Do not suggest or encourage using state in plugins, not in the form of current working directory.

Reference #45.

@@ -67,26 +65,6 @@ baseDescriptor = PluginDescriptor
}
, cmdFunc = commandDetailCmd
}
, Command
{ cmdDesc = CommandDesc
{ cmdName = "pwd"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it may be worthwhile keeping this one, but removing "cwd"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why? pwd is a constant in this case.

@gracjan
Copy link
Contributor Author

gracjan commented Nov 11, 2015

@cocreature: Refactored it out to a function.

@alanz
Copy link
Collaborator

alanz commented Nov 11, 2015

There is some logic in setting the initial directory, with a "give up leave it unchanged" option.

I do not believe there is any harm in being able to request the current working directory. It is not a stateful operation.

@alanz
Copy link
Collaborator

alanz commented Nov 11, 2015

BTW, I am just working through some ghc-mod commands, in particular the "find" command, which works in the context of the current project, which it detects using the find cradle process.

The cradle is defined as the point where the cabal file is found, and the search starts at the current directory.

So in the normal (non-HIE) case, ghc-mod is started up in the project directory and can then find the cradle by looking in the current directory or moving up.

In the stateless mode, we can work around this by setting the CtxProject to require a directory name, and then doing an explicit cd in the ghc-mod plugin, or modifying ghc-mod to take a directory as its root.

We also need to consider the case where there is more than one HIE instance running at a time, attached to different projects.

@gracjan
Copy link
Contributor Author

gracjan commented Nov 11, 2015

Yes, find command should get an explicit ctxProject, an absolute path to where to begin searching.

@gracjan
Copy link
Contributor Author

gracjan commented Nov 11, 2015

And about having a pwd without a cwd: somebody will come along and contribute the obvious missing part, that is cwd. I would not want to give people suggestions for that path.

@alanz
Copy link
Collaborator

alanz commented Nov 11, 2015

OK, you've worn me down. I'll have to sneak it into a private plugin if I want to debug.

Maybe we should just log the directory chosen on startup. Then we are both happy.

@alanz
Copy link
Collaborator

alanz commented Nov 12, 2015

Can you rebase this, then merge?

Do not suggest or encourage using state in plugins, not in the form of
current working directory.
gracjan added a commit that referenced this pull request Nov 12, 2015
@gracjan gracjan merged commit 15a4b91 into haskell:master Nov 12, 2015
@alanz alanz added this to the prehistory milestone Feb 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants