1
1
mirror of https://github.com/github/semantic.git synced 2024-12-20 13:21:59 +03:00
Commit Graph

428 Commits

Author SHA1 Message Date
Rick Winfrey
439e9ff9ae Update remaining 2019-01-15 12:27:09 -08:00
Rick Winfrey
136af86301 Merge branch 'master' into visibility-resolution 2019-01-08 17:32:14 -08:00
Patrick Thomson
1302fe4ac8 Use -XDerivingVia to clean up our Semigroup/Monoid instances.
Now that we're on GHC 8.6, we can use `-XDerivingVia` in many cases
where we previously had to write instances by hand. If you're not
familiar with `-XDerivingVia`, the [GHC proposal][ghc] is a good place
to start.

[ghc]: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0023-deriving-via.rst

Thanks to the `generic-monoid` package, we can derive a `Semigroup`
instance for any product type whose members are `Semigroups`, and the
same goes for `Monoid`. This entails an extra dependency, but it is
better than the `generic-deriving` package, which is way too much overhead.
I've also switched some trivial definitions to newtype-deriving.

Please be aware that this bumps `hlint` and `haskell-src-exts` so that
`hlint` doesn't choke on the `DerivingVia` extension. You'll need to
`stack install hlint` to get it on your `PATH`. Apologies!
2019-01-07 11:23:11 -05:00
Patrick Thomson
955f30617c Depend on hostname instead of Network.BSD. 2018-12-29 15:02:42 -05:00
Patrick Thomson
d32f5cd5ca Merge branch 'master' into lts-13.0 2018-12-29 14:17:48 -05:00
Patrick Thomson
9852155a77 Upgrade to LTS 13.0 and GHC 8.6.3.
Bumps most of our dependencies.

Code changes:
* algebraic-graphs-0.3 no longer provides a Foldable or Traversable
  implementation for `Graph`, so now neither does our `Graph` type.
* CMark parsing now uses safe rendering of raw HTML/URLs by default,
  so there is no reason to pass an `optSafe` anymore.
* algebraic-graphs now no longer requires an Eq constraint on the
  output type it generates, so we can ditch our Serializing.DOT
  module. (Andrey fixed this for us specifically!)
2018-12-29 14:02:24 -05:00
Rick Winfrey
960d56fdcf Add Visibilities instances 2018-12-19 19:11:02 -08:00
Rick Winfrey
3adaf47a4f Define a Visibilities type class 2018-12-19 19:10:49 -08:00
Patrick Thomson
5d46cb211e Split up typescript grammar even more 2018-12-18 16:25:32 -05:00
Rob Rix
594979543c 🔥 Located. 2018-12-13 12:04:24 -05:00
Rob Rix
595f0fa2a3 Whitespace error. 2018-12-13 12:04:06 -05:00
Patrick Thomson
684a752773 remove Semantic.Util.Rewriting 2018-12-11 17:47:13 -05:00
Patrick Thomson
e329cbe89a unify the last spec 2018-12-11 17:36:42 -05:00
Patrick Thomson
1de0e9ef09 move specs around 2018-12-11 17:21:39 -05:00
Patrick Thomson
1f44f81acc Unify Control.Rewriting and Control.Matching. 2018-12-11 17:12:24 -05:00
Rob Rix
fa950f3239 🔥 Data.Abstract.Ref. 2018-12-10 11:37:00 -05:00
joshvera
1914a94500 Add -dynamic in test debug builds as well 2018-12-05 11:28:21 -05:00
joshvera
9b8a93bc04 Replace -static with -dynamic in non-release builds
Improves performance in the repl since we don't have to link statically.
2018-12-05 11:25:12 -05:00
joshvera
03e5546ec1 Add -O0 to tests to reduce compilation times 2018-12-05 10:25:21 -05:00
joshvera
49e8a7004c Remove Exports 2018-12-05 10:23:42 -05:00
joshvera
26d3e5e449 Remove Environment 2018-12-05 09:42:00 -05:00
joshvera
70fa31f11e Fix expectation of sequence expression test 2018-11-29 18:38:32 -05:00
joshvera
f39da9578a Move ImportPath to Data.ImportPath 2018-11-16 16:09:11 -05:00
Timothy Clem
57f284f847 Streamline the declarations for toc summaries 2018-11-08 08:33:26 -08:00
Timothy Clem
343289f1c5 Merge remote-tracking branch 'origin/master' into docstrings-round2 2018-11-06 09:17:49 -08:00
Patrick Thomson
7ea52dbfe3 Give Control.Matching API better ergonomics.
Given that @tclem and I have found the matcher API frustrating, I've
taken a stab at improving its ergonomics, and I've found some success
in separating composition of matchers from predicate-based narrowing
thereof.

The biggest change here is the elimination of the old `match`
combinator, which proved to be clumsy in that it complected narrowing
and composition. Top-down matching combinators are now written with
the `need` combinator and the `>>>` combinator, which is more readable
and more versatile. Here's a matcher that accepts functions with
Python docstrings:

```haskell
docstringMatcher :: ( Decl.Function :< fs
                    , [] :< fs
                    , Lit.TextElement :< fs
                    , term ~ Term (Sum fs) ann
                    ) => Matcher term term
docstringMatcher = target <*
               (need Decl.functionBody
                >>> narrow @[]
                >>> mhead
                >>> narrow @Lit.TextElement
                >>> ensure Lit.isTripleQuoted))
```

Pretty readable, right? Each step of the tree regular expression -
choosing function bodies, ensuring said bodies are lists, examining
the first element, and choosing only TextElements containing
triple-quoted strings - is made implicit. The old way would have
looked something like this:

```haskell
docstringMatcher = target <* match Decl.functionBody
                           $ narrow
                           $ matchM listToMaybe
                           $ target <* ensure Lit.isTripleQuoted
```
which is a good deal more disorganized and less flexible
in the quite-common case of applying functions during a
matching pass. Separating the act of composition from
function application is a big win here.

Further comments are inline.
2018-11-02 19:25:29 -04:00
Timothy Clem
0f56f33f24 Introduce some symbol/tags tests 2018-11-02 13:55:30 -07:00
Timothy Clem
63e13ee20c Merge remote-tracking branch 'origin/master' into docstrings-round2 2018-11-01 16:04:15 -07:00
Timothy Clem
1f6a7b9e48 Move HasTextElement 2018-11-01 14:49:35 -07:00
Patrick Thomson
b9cf8f73c6 Environment and App. 2018-10-31 15:47:30 -04:00
Timothy Clem
d4d19ea21f Some renaming, split out into two modules 2018-10-31 10:58:00 -07:00
Patrick Thomson
d473b9e1af add Data/Abstract/Name/Spec 2018-10-31 13:19:43 -04:00
Patrick Thomson
b0e6190dbf add Data/Range/Spec 2018-10-31 12:46:52 -04:00
Patrick Thomson
cd05aaa7a5 add Data/Graph/Spec 2018-10-31 12:30:56 -04:00
Timothy Clem
945ab01275 Introduce Taggable 2018-10-31 08:34:58 -07:00
Patrick Thomson
cb54dd7aed Merge remote-tracking branch 'origin/master' into repl-effect 2018-10-30 15:58:00 -04:00
Patrick Thomson
3cb8608703 Merge remote-tracking branch 'origin/master' into add-purely-to-matching 2018-10-30 15:00:37 -04:00
Patrick Thomson
da1704af56 Extract the REPL effect into its own module.
I need this for the refactoring OKR.
2018-10-30 14:55:23 -04:00
Patrick Thomson
6b476d0eb7 Add 'purely' combinator to Matching and rename it.
@tclem and I found ourselves wanting an arrow-like combinator that
promotes a given function to a Matcher. While I think an Arrow
instance is going a little overboard, there's no harm in adding a
'purely' function, the naming of which is commensurate with the
rewriting DSL.

This also renames the module, since there's not anything really
abstract about matching (indeed, it is quite concrete).
2018-10-30 11:04:11 -04:00
Rob Rix
636eec364e Update to fused-effects, replace \/ with handleSum and bundle Interpose. 2018-10-29 09:52:48 -04:00
Rob Rix
1414df368d Define a high-level Semantic.Analysis module. 2018-10-25 21:31:38 -04:00
Rob Rix
131cae4d7b Merge branch 'master' into higher-order-effects 2018-10-24 14:04:13 -04:00
Patrick Thomson
ef696d3c41 Split up Semantic.IO.
This looks like a big patch, but it's very straightforward: no
behavior has changed.

After the umpteenth time spent hitting a compile error because I
passed a `FilePath` rather than a `File` to `readBlobFromPath`, I
decided to finally make the needed refactors to Semantic.IO, and to
split off the `File` type and `Files` effect. This patch:

* adds the `MonadIO` class to `Prologue`'s export list
* moves `File` into `Data.File`
* moves `Handle` into `Data.Handle`
* moves `Files` into `Semantic.Task.Files`
* moves functions for reading blobs into `Data.Blob`
* keeps general IO helpers in Semantic.IO
* renames `readFile` to `readBlobFromFile`
* renames `readBlobFromPath` to `readBlobFromFile'`

This should have a positive effect on compile times and ease of
navigation throughout the codebase.
2018-10-23 15:37:49 -04:00
Rob Rix
314aff5d56 Bump higher-order-effects for Resource & some handler helpers. 2018-10-22 20:18:36 -04:00
Patrick Thomson
8800f7072e Turn on -XMonadFailDesugaring globally.
In the past few years, GHC has been moving to remove the `fail` method
from the definition of `Monad`, a longtime wart, and requiring monads
that fail due to an incomplete pattern match to implement `MonadFail`.
You can read about it[here](https://wiki.haskell.org/MonadFail_Proposal).
Though this move is still in progress, we can opt into it by turning
on the `-XMonadFailDesugaring` extension.

The matching and rewriting systems will both benefit from this, as the
incomplete pattern match in following rewrite rule will crash without
`-XMonadFailDesugaring`, even though the sensible and correct thing
for the rule to do is call out to its `MonadFail` instance:

```haskell
-- crashes the program without -XMonadFailDesugaring
getReceiver :: Rule a (Ruby.Send term) term
getReceiver = do
  (Ruby.Send (Just rec) _ _ _) <- target
  pure rec
```

In addition, turning on `MonadFailDesugaring` will warn you if you put
an incomplete pattern match in a monad that doesn't implement `MonadFail`.
This setting will become implicit in GHC 8.6, so this is a good chance
to make sure that we don't introduce any incomplete patterns going forward.
2018-10-22 14:07:48 -04:00
Rob Rix
3ef2efa73a Merge branch 'master' into higher-order-effects 2018-10-22 09:45:57 -04:00
Patrick Thomson
7c8e8c5bf5 Merge remote-tracking branch 'origin/master' into avoid-recompiling-git 2018-10-18 17:22:18 -04:00
Josh Vera
efde121720 Merge branch 'master' into avoid-recompiling-git 2018-10-18 11:28:18 -04:00
Patrick Thomson
f4b5f0d44e [Experiment] Improve compile speed with larger GHC allocation area 2018-10-17 21:27:22 -04:00
Patrick Thomson
379d75f284 Split up Language.Haskell.Syntax into child modules.
This was the longest (in terms of line count) file in the project.
Splitting it up will save on compile time, as it did for TypeScript.
I observe a ~20sec speedup from `stack clean semantic && stack build semantic:lib`
2018-10-17 18:57:29 -04:00