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

Remove IdeResponse, integrate it into IdeM as FreeT IdeDefer - #777

Merged
alanz merged 11 commits into
haskell:masterfrom
lukel97:cached-module-default
Aug 23, 2018
Merged

alanz merged 11 commits into
haskell:masterfrom
lukel97:cached-module-default

Conversation

@lukel97

@lukel97 lukel97 commented Aug 20, 2018

Copy link
Copy Markdown
Collaborator

This removes the whole IdeResponse/pluginGetFileResponse headache. Use IdeResult now instead.
It also removes the versions of withCachedModule that didn't take a default. Now they must provide a default fallback if there is no module (which most of them did anyway), removing the NoModuleAvailable error code.
The dispatcher now also handles all the logic for deferred responses now, whereas previously half of it was inModuleCache.hs as well.

@lukel97
lukel97 requested a review from alanz August 20, 2018 19:15

-- | A computation that is deferred until the module is cached.
-- Note that the module may not typecheck, in which case 'UriCacheFailed' is passed
data IdeDefer a = IdeDefer FilePath (UriCache -> a) deriving Functor

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is probably not the right time to do it, but at some point we should let the module cache be more lenient, in the sense that if we get anything out, we call the function.

Here anything is ParsedSource, RenamedSource, TypeCheckedSource.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I strongly agree with this! I think this would be a (hopefully) easy win to make more features available more often, and not just whenever the module typechecks. Mainly since a lot of features e.g. document symbols and goto definition don't depend on the type checked source, just the parsed source.

I can imagine some sort of tiered system where you can request a module at the level of compilation needed:

data Source = Parsed | Renamed | TypeChecked
withCachedModule :: Uri -> Source -> (CachedModule -> IdeM a) -> IdeM a

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I wrote this review 5 days ago, but didn't realise you had to submit it for you to see it...

Comment thread src/Haskell/Ide/Engine/Dispatcher.hs Outdated
ideDispatcher :: forall void m. DispatcherEnv -> ErrorHandler -> CallbackHandler m -> TChan (IdeRequest m) -> IdeM void
ideDispatcher env errorHandler callbackHandler pin = forever $ do
ideDispatcher :: forall void m. TVar IdeState -> J.ClientCapabilities -> DispatcherEnv -> ErrorHandler -> CallbackHandler m -> TChan (IdeRequest m) -> IO void
ideDispatcher stateVar caps env errorHandler callbackHandler pin = flip runReaderT stateVar $ flip runReaderT caps $ forever $ do

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Long lines again, difficult to review

@alanz

alanz commented Aug 20, 2018

Copy link
Copy Markdown
Collaborator

Nothing obvious jumps out at me.

Shouldn't be necessary anymore since its caught at the dispatcher level
@alanz

alanz commented Aug 21, 2018

Copy link
Copy Markdown
Collaborator

@Gurkenglas, @bubba

Are we ok with this? Should I merge?

@wz1000 any comment?

@wz1000

wz1000 commented Aug 21, 2018

Copy link
Copy Markdown
Collaborator

@alanz Seems reasonable to me.

@Gurkenglas Gurkenglas 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.

Afaik PluginsIdeMonads.hs:229 never triggers up to now. We should reflect this. For example, 229 could use error. I think a better solution will be rendered unnecessary if we proceed to replace FreeT with making threads wait.

@alanz

alanz commented Aug 21, 2018

Copy link
Copy Markdown
Collaborator

@Gurkenglas 229?

@Gurkenglas

Copy link
Copy Markdown
Contributor

Inserted a link. I thought writing the review while that line is marked would attach it to there, but apparently that needs another button or something ahhhhh interfaces

-- ---------------------------------------------------------------------

type IdeGhcM = GM.GhcModT IdeM
type IdeGhcM = GM.GhcModT IdeBase

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This definition should be grouped with the other three, just below.

@lukel97 lukel97 changed the title Remove IdeResponse, integrate it into IdeM which as FreeT IdeDefer Remove IdeResponse, integrate it into IdeM as FreeT IdeDefer Aug 22, 2018
@lukel97

lukel97 commented Aug 22, 2018 •

Copy link
Copy Markdown
Collaborator Author

@Gurkenglas @alanz Instead of throwing an error/having an invariant, how would you feel about making IdeM IdeDefer and making IdeBase IdeM? This way we can be explicit in the type signatures of when and where you can defer, and not have IdeDefer an instance of LiftsToGhc. On the other hand, its added complexity

@alanz

alanz commented Aug 22, 2018

Copy link
Copy Markdown
Collaborator

@bubba I do not have strong feelings either way, except I prefer simplicity in general.

And we need to merge this thing some time.

@alanz
alanz merged commit dc96da0 into haskell:master Aug 23, 2018
@lukel97 lukel97 mentioned this pull request Aug 23, 2018
alanz added a commit to alanz/haskell-ide-engine that referenced this pull request Aug 25, 2018
alanz added a commit that referenced this pull request Aug 25, 2018
Revert #777 and #782, performance was awful

instance ExceptionMonad IdeM where
FreeT m `gcatch` f = FreeT $ fmap (fmap (`gcatch` f)) m `gcatch` (runFreeT . f)
gmask f = FreeT (runFreeT $ gmask f)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@Gurkenglas are there any better ways of implementing this?


-- | A computation that is deferred until the module is cached.
-- Note that the module may not typecheck, in which case 'UriCacheFailed' is passed
data IdeDefer a = IdeDefer FilePath (UriCache -> a) deriving Functor

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I strongly agree with this! I think this would be a (hopefully) easy win to make more features available more often, and not just whenever the module typechecks. Mainly since a lot of features e.g. document symbols and goto definition don't depend on the type checked source, just the parsed source.

I can imagine some sort of tiered system where you can request a module at the level of compilation needed:

data Source = Parsed | Renamed | TypeChecked
withCachedModule :: Uri -> Source -> (CachedModule -> IdeM a) -> IdeM a

lukel97 added a commit to lukel97/haskell-ide-engine that referenced this pull request Aug 27, 2018
@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.

4 participants