FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

New PSCi command: reload by hatashiro · Pull Request #2721 · purescript/purescript · GitHub

New PSCi command: reload - #2721

Merged
paf31 merged 8 commits into
purescript:masterfrom
hatashiro:repl-module-import
Mar 9, 2017
Merged

New PSCi command: reload#2721
paf31 merged 8 commits into
purescript:masterfrom
hatashiro:repl-module-import

Conversation

Copy link
Copy Markdown
Contributor

Regarding #2713

This PR update the list of commands in PSCi. The current :reset command is renamed to :clear, and a new command :reload is added. :reload is expected to work the same as :reload in GHCi.

Hyunje Jun added 4 commits March 8, 2017 18:46
Remove duplication beforing cons'ing a module.
The shortcut ':r' will be used for ':reload' later.
The :reload command will keep the current list of modules, just try to
rebuild them.
Comment thread src/Language/PureScript/Interactive.hs Outdated
Left errs -> printErrors errs
Right _ -> put st
where
renew :: ImportedModule -> [ImportedModule] -> [ImportedModule]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

What is this function for?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

It's to prevent import duplication. Previously, when a module was imported twice, it was listed in the imported modules twice. Maybe the name renew is somewhat confusing?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Previously, when a module was imported twice, it was listed in the imported modules twice.

Is that necessary? Maybe that's what we need to fix?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yes, that's what I fixed with the patch cd13ee4 included in this PR.

Before:

> import Data.Functor
> import Data.Functor
> import Data.Functor
> import Data.Functor
> :show import
import Data.Functor
import Data.Functor
import Data.Functor
import Data.Functor

>

After:

> import Data.Functor
> import Data.Functor
> import Data.Functor
> import Data.Functor
> :show import
import Data.Functor

>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think we want to allow multiple imports with the same name though. Otherwise you can't do something like import something qualified and with selective imports at the same time.

hatashiro Mar 9, 2017
edited
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I understand users can add duplicate imports and PSCi works without any problem. However, according to my understanding, duplicate imports mean nothing, but they are all listed in :show import. I still think we do not need to keep the identical imports in the import list of PSCi.

It's actually not about :r, but import X in PSCi. May I revert it from this PR and open a discussion?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

However, according to my understanding, duplicate imports mean nothing

No, they are useful:

> import Prelude ((+))
> import Prelude as P

This means that I want to use + globally but qualify everything else. If the user typed that, we should preserve both.

hatashiro Mar 9, 2017
edited
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yes, but my update was removing only the identical ones, where identical means identical at everything including qualification, listed imports, listed hidings.

> import Prelude ((+))
> import Prelude as P
> :show import
import Prelude ((+))
import Prelude as P

> import Prelude
> import Prelude
> import Prelude ((+))
> import Prelude as P
> :show import
import Prelude
import Prelude ((+))
import Prelude as P

paf31 Mar 9, 2017
edited
Loading

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think if we were going to do that, we should consolidate any imports under the same namespace. So for example

import Prelude ((+))
import Prelude (bind)
import Prelude as P ((*))
import Prelude as P (show)

should give

> :show import
import Prelude ((+), (*))
import Prelude as P (bind, show)

Without that, I'm not sure it's worth it to be honest. Also, we could do this once when the user types :show import, rather than doing it on every import.

hatashiro Mar 9, 2017
edited
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Your suggestion looks better. I may upload an issue for the consolidation, and revert the renew from PR. Thanks for your review 👍

paf31 commented Mar 8, 2017

Copy link
Copy Markdown
Contributor

Looks great! Could you please add a test to tests/TestPsci.hs as well?

Copy link
Copy Markdown
Contributor Author

Will add a test.

Hyunje Jun added 2 commits March 9, 2017 12:37
Currently :clear and :reload are tested.
Even though module names are the same, an import can be allowed if they
have different declaration types or qualifications.

hatashiro commented Mar 9, 2017
edited
Loading

Copy link
Copy Markdown
Contributor Author

Updated the renew to check not only the name, but the ImportedModule tuple itself. By this change, multiple imports with different forms work as expected:

> import Prelude
> import Prelude ((+))
> import Prelude
> import Prelude
> import Prelude as P
> import Prelude
> import Prelude ((+))
> import Prelude
> :show import
import Prelude
import Prelude ((+))
import Prelude as P

>

Copy link
Copy Markdown
Contributor Author

There have been some errors about compiling Eq1 and Ord1 but they are fixed by bower cache clean.

Copy link
Copy Markdown
Contributor Author

Reverted duplication removal for PSCi imports.

paf31 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks!

paf31 merged commit 52668d8 into purescript:master Mar 9, 2017
hatashiro deleted the repl-module-import branch March 10, 2017 01:05
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

2 participants


Back | FazBrowse Home | New Git URL