Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Play nice with ghcide #369

Merged
merged 25 commits into from
Oct 31, 2019
Merged

Play nice with ghcide #369

merged 25 commits into from
Oct 31, 2019

Conversation

robrix
Copy link
Contributor

@robrix robrix commented Oct 30, 2019

This PR makes semantic play a little more nicely with ghcide, especially when configuring it to load all of the components.

It does this by:

  1. Eliminating the project-wide language extensions in favour of per-file ones. Given the choice between enabling these globally for all of our packages and configuring ghcide to do the same or enabling them on a file-by-file basis, I strongly prefer to enable them file-by-file, as it makes reasoning locally about what’s going on in the file much easier. (Note that this also makes integration with tools such as hlint easier.)

  2. Enabling more warnings across semantic (and fixing them). Unlike language extensions which are usually conveniences, these are generally very good ideas to have globally enabled.

I’m not quite ready to commit a hie.yaml file because at the present time these require absolute paths to the source directories when used with VS Code, but it is also possible to write a script to provide these, and that should be simple enough for us to integrate in a follow-up PR.

@@ -23,7 +23,7 @@
- warn: {group: {name: default}}

# Ignore the highly noisy module export list hint
- ignore: {name: Use module export list}
- ignore: {name: Use explicit module export list}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one apparently changed.

@@ -1,7 +1,7 @@
# HLint configuration file
# https://github.com/ndmitchell/hlint

- arguments: [--color=auto, -XDataKinds, -XDeriveFoldable, -XDeriveFunctor, -XDeriveGeneric, -XDeriveTraversable, -XFlexibleContexts, -XFlexibleInstances, -XMultiParamTypeClasses, -XOverloadedStrings, -XRecordWildCards, -XStandaloneDeriving, -XStrictData, -XTypeApplications, -XDerivingVia]
- arguments: [--color=auto, -XStrictData]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

yay!

Comment on lines -5 to -6
import Algebra.Graph
import Control.Monad
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did you know we didn’t have warnings enabled in the benchmarks?

Copy link
Contributor

Choose a reason for hiding this comment

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

😮

Comment on lines -28 to -41
default-extensions: DataKinds
, DeriveFoldable
, DeriveFunctor
, DeriveGeneric
, DeriveTraversable
, FlexibleContexts
, FlexibleInstances
, MonadFailDesugaring
, MultiParamTypeClasses
, OverloadedStrings
, RecordWildCards
, StandaloneDeriving
, StrictData
, TypeApplications
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All of these have been moved to the .hs files, except StrictData, which does not affect parsing/typechecking, and MonadFailDesugaring, which is obsolete in 8.6+.

, TypeApplications
default-extensions: StrictData
ghc-options:
-Weverything
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hard mode.

@@ -1,4 +1,4 @@
{-# LANGUAGE GeneralizedNewtypeDeriving, TypeOperators #-}
{-# LANGUAGE DeriveFunctor, FlexibleContexts, GeneralizedNewtypeDeriving, TypeApplications, TypeOperators #-}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A lot of these FlexibleContexts additions are going to go away with fused-effects 1.0.

vertexAttributes UnknownModule{} = [ "style" := "dotted, rounded", "shape" := "box", "color" := "red", "fontcolor" := "red" ]
vertexAttributes (Variable n _ s) = [ "label" := T.encodeUtf8Builder (n <> " (Variable)"), "tooltip" := T.encodeUtf8Builder (showSpan s), "style" := "rounded", "shape" := "box" ]
vertexAttributes (Method n _ s) = [ "label" := T.encodeUtf8Builder (n <> " (Method)"), "tooltip" := T.encodeUtf8Builder (showSpan s) , "style" := "rounded", "shape" := "box" ]
vertexAttributes (Function n _ s) = [ "label" := T.encodeUtf8Builder (n <> " (Function)"), "tooltip" := T.encodeUtf8Builder (showSpan s), "style" := "rounded", "shape" := "box" ]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fallout from the changes to ControlFlowVertex.

@@ -15,7 +15,7 @@ import Prologue
import Source.Loc

newtype PackageDef = PackageDef { moduleDefIdentifier :: T.Text }
deriving (Eq, Generic, Show)
deriving (Eq, Show)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also took the opportunity to 🔥 a few Generic instances we weren’t using.

Comment on lines -113 to -125
-- | Match a branch node, matching its children with the supplied 'Assignment' & returning the result.
branchNode :: (Enum grammar, Ix grammar) => grammar -> Assignment ast grammar a -> Assignment ast grammar a
branchNode sym child = symbol sym *> children child

-- | Match a leaf node, returning the corresponding 'Text'.
leafNode :: (Enum grammar, Ix grammar) => grammar -> Assignment ast grammar Text
leafNode sym = symbol sym *> source

-- | Wrap an 'Assignment' producing @syntax@ up into an 'Assignment' producing 'Term's.
toTerm :: Element syntax syntaxes
=> Assignment ast grammar (syntax (Term (Sum syntaxes) L.Loc))
-> Assignment ast grammar (Term (Sum syntaxes) L.Loc)
toTerm syntax = termIn <$> location <*> (inject <$> syntax)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These were unused.

Comment on lines +84 to +88
unLoopControl :: LoopControl value -> value
unLoopControl = \case
Break v -> v
Continue v -> v
Abort -> error "unLoopControl: Abort"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Silencing partial selector warnings.

@robrix robrix requested a review from a team October 30, 2019 18:56
Copy link
Contributor

@patrickt patrickt left a comment

Choose a reason for hiding this comment

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

A couple questions, but this is a major improvement. The default-extensions field is a prime example of false economy, I think, so kudos for ditching it (even if we are married to StrictData).

Comment on lines -5 to -6
import Algebra.Graph
import Control.Monad
Copy link
Contributor

Choose a reason for hiding this comment

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

😮

@@ -361,20 +342,18 @@ instance (Enum grammar, Eq1 ast, Ix grammar, Show grammar) => Parsing (Assignmen
(<?>) :: HasCallStack => Assignment ast grammar a -> String -> Assignment ast grammar a
a <?> s = tracing (Label a s) `Then` pure

unexpected :: HasCallStack => String -> Assignment ast grammar a
unexpected :: String -> Assignment ast grammar a
Copy link
Contributor

Choose a reason for hiding this comment

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

Thought: instead of just ditching this constraint, can we glom it on to the passed String? I feel like call stacks are good and we shouldn’t lose these constraints, but maybe I’m bugging.

Copy link
Contributor Author

@robrix robrix Oct 30, 2019

Choose a reason for hiding this comment

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

I’ve only removed redundant constraints. This call stack was never used, so we haven’t lost anything.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough. I guess it would still be preserved if we called error here? But we don’t, so no matter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it wouldn’t have been redundant in that case, and I wouldn’t have removed it 😁

@@ -133,17 +133,18 @@ data Function term address value (m :: * -> *) k
| BuiltIn address BuiltIn (value -> m k) -- ^ A built-in is parameterized by its parent scope, BuiltIn type, and returns a value.
| Call value [value] (value -> m k) -- ^ A Call takes a set of values as parameters and returns a ValueRef.
| Bind value value (value -> m k)
deriving stock (Functor, Generic1)
deriving anyclass (HFunctor, Effect)
Copy link
Contributor

Choose a reason for hiding this comment

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

my beautiful deriving strategies nooooo

(just kidding this is fine)

@robrix robrix requested a review from patrickt October 30, 2019 20:29
@robrix robrix mentioned this pull request Oct 30, 2019
1 task
@patrickt patrickt merged commit 1f796bd into master Oct 31, 2019
@robrix robrix deleted the play-nice-with-ghcide branch November 1, 2019 14:18
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