Skip to content
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

ghcide - enable ApplicativeDo everywhere #1667

Merged
merged 13 commits into from Apr 6, 2021
Merged

ghcide - enable ApplicativeDo everywhere #1667

merged 13 commits into from Apr 6, 2021

Conversation

pepeiborra
Copy link
Collaborator

Shake has applicative parallelism for rules, meaning that all "contiguous" (that is, not separated by join or bind) calls to apply will evaluate in parallel (but note that the rest of the Action logic still evaluated sequentially, so this doesn't replace parallel).

ApplicativeDo created type errors in some modules, disabled locally with NoApplicativeDo

@wz1000
Copy link
Collaborator

wz1000 commented Apr 4, 2021

What sort of errors does ApplicativeDo lead to? Why is NoApplicativeDo every necessary?

@pepeiborra
Copy link
Collaborator Author


src/Development/IDE/Core/Actions.hs:92:6: error:
    • Couldn't match expected type ‘a1’
                  with actual type ‘(HieASTs a2, HieDb,
                                     Data.Map.Internal.Map ModuleName NormalizedFilePath,
                                     PositionMapping, Position)’
        because type variable ‘a2’ would escape its scope
      This (rigid, skolem) type variable is bound by
        a pattern with constructor:
          HAR :: forall a.
                 Module
                 -> HieASTs a
                 -> RefMap a
                 -> Data.Map.Internal.Map Name [RealSrcSpan]
                 -> HieKind a
                 -> HieAstResult,
        in a pattern binding in
             a 'do' block
        at src/Development/IDE/Core/Actions.hs:90:6-19
    • In the second argument of ‘($)’, namely
        ‘do ide <- ask
            opts <- liftIO $ getIdeOptionsIO ide
            (HAR _ hf _ _ _, mapping) <- useE GetHieAst file
            (ImportMap imports, _) <- useE GetImportMap file
            !pos' <- MaybeT (pure $ fromCurrentPosition mapping pos)
            hiedb <- lift $ asks hiedb
            dbWriter <- lift $ asks hiedbWriter
            toCurrentLocations mapping
              <$>
                AtPoint.gotoDefinition
                  hiedb (lookupMod dbWriter) opts imports hf pos'’
      In the expression:
        runMaybeT
          $ do ide <- ask
               opts <- liftIO $ getIdeOptionsIO ide
               (HAR _ hf _ _ _, mapping) <- useE GetHieAst file
               (ImportMap imports, _) <- useE GetImportMap file
               !pos' <- MaybeT (pure $ fromCurrentPosition mapping pos)
               hiedb <- lift $ asks hiedb
               dbWriter <- lift $ asks hiedbWriter
               toCurrentLocations mapping
                 <$>
                   AtPoint.gotoDefinition
                     hiedb (lookupMod dbWriter) opts imports hf pos'
      In an equation for ‘getDefinition’:
          getDefinition file pos
            = runMaybeT
                $ do ide <- ask
                     opts <- liftIO $ getIdeOptionsIO ide
                     (HAR _ hf _ _ _, mapping) <- useE GetHieAst file
                     (ImportMap imports, _) <- useE GetImportMap file
                     !pos' <- MaybeT (pure $ fromCurrentPosition mapping pos)
                     hiedb <- lift $ asks hiedb
                     dbWriter <- lift $ asks hiedbWriter
                     toCurrentLocations mapping
                       <$>
                         AtPoint.gotoDefinition
                           hiedb (lookupMod dbWriter) opts imports hf pos'
    • Relevant bindings include
        hf :: HieASTs a2
          (bound at src/Development/IDE/Core/Actions.hs:90:12)
   |
92 |     !pos' <- MaybeT (pure $ fromCurrentPosition mapping pos)
   |      ^^^^

src/Development/IDE/Core/Actions.hs:95:24: error:
    • Couldn't match expected type ‘PositionMapping’
                  with actual type ‘PositionMapping’
    • In the first argument of ‘toCurrentLocations’, namely ‘mapping’
      In the first argument of ‘(<$>)’, namely
        ‘toCurrentLocations mapping’
      In a stmt of a 'do' block:
        toCurrentLocations mapping
          <$>
            AtPoint.gotoDefinition
              hiedb (lookupMod dbWriter) opts imports hf pos'
   |
95 |     toCurrentLocations mapping <$> AtPoint.gotoDefinition hiedb (lookupMod dbWriter) opts imports hf pos'
   |                        ^^^^^^^

src/Development/IDE/Core/Actions.hs:95:59: error:
    • Couldn't match expected type ‘HieDb’ with actual type ‘HieDb’
    • In the first argument of ‘AtPoint.gotoDefinition’, namely ‘hiedb’
      In the second argument of ‘(<$>)’, namely
        ‘AtPoint.gotoDefinition
           hiedb (lookupMod dbWriter) opts imports hf pos'’
      In a stmt of a 'do' block:
        toCurrentLocations mapping
          <$>
            AtPoint.gotoDefinition
              hiedb (lookupMod dbWriter) opts imports hf pos'
   |
95 |     toCurrentLocations mapping <$> AtPoint.gotoDefinition hiedb (lookupMod dbWriter) opts imports hf pos'
   |                                                           ^^^^^

src/Development/IDE/Core/Actions.hs:95:91: error:
    • Couldn't match expected type ‘Data.Map.Internal.Map
                                      ModuleName NormalizedFilePath’
                  with actual type ‘Data.Map.Internal.Map
                                      ModuleName NormalizedFilePath’
    • In the fourth argument of ‘AtPoint.gotoDefinition’, namely
        ‘imports’
      In the second argument of ‘(<$>)’, namely
        ‘AtPoint.gotoDefinition
           hiedb (lookupMod dbWriter) opts imports hf pos'’
      In a stmt of a 'do' block:
        toCurrentLocations mapping
          <$>
            AtPoint.gotoDefinition
              hiedb (lookupMod dbWriter) opts imports hf pos'
   |
95 |     toCurrentLocations mapping <$> AtPoint.gotoDefinition hiedb (lookupMod dbWriter) opts imports hf pos'
   |                                                                                           ^^^^^^^

src/Development/IDE/Core/Actions.hs:95:99: error:
    • Couldn't match expected type ‘HieASTs a0’
                  with actual type ‘HieASTs a’
    • In the fifth argument of ‘AtPoint.gotoDefinition’, namely ‘hf’
      In the second argument of ‘(<$>)’, namely
        ‘AtPoint.gotoDefinition
           hiedb (lookupMod dbWriter) opts imports hf pos'’
      In a stmt of a 'do' block:
        toCurrentLocations mapping
          <$>
            AtPoint.gotoDefinition
              hiedb (lookupMod dbWriter) opts imports hf pos'
    • Relevant bindings include
        hf :: HieASTs a
          (bound at src/Development/IDE/Core/Actions.hs:90:12)
   |
95 |     toCurrentLocations mapping <$> AtPoint.gotoDefinition hiedb (lookupMod dbWriter) opts imports hf pos'
   |                                                                                                   ^^

src/Development/IDE/Core/Actions.hs:95:102: error:
    • Couldn't match expected type ‘Position’
                  with actual type ‘Position’
    • In the sixth argument of ‘AtPoint.gotoDefinition’, namely ‘pos'’
      In the second argument of ‘(<$>)’, namely
        ‘AtPoint.gotoDefinition
           hiedb (lookupMod dbWriter) opts imports hf pos'’
      In a stmt of a 'do' block:
        toCurrentLocations mapping
          <$>
            AtPoint.gotoDefinition
              hiedb (lookupMod dbWriter) opts imports hf pos'
   |
95 |     toCurrentLocations mapping <$> AtPoint.gotoDefinition hiedb (lookupMod dbWriter) opts imports hf pos'
   |                                                                                                      ^^^^
cabal: Failed to build ghcide-1.1.0.0 (which is required by

@wz1000
Copy link
Collaborator

wz1000 commented Apr 4, 2021

The "could not match "Position" with "Position"` style errors seem very suspicious. Do you know why they happen? Is there a GHC bug report?

@pepeiborra
Copy link
Collaborator Author

I have no idea. I have filled ApplicativeDo bugs in the past. Didn't work out.

@pepeiborra pepeiborra added the merge me Label to trigger pull request merge label Apr 5, 2021
@mergify mergify bot merged commit 54afb31 into master Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Label to trigger pull request merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants