1
1
mirror of https://github.com/github/semantic.git synced 2024-12-30 18:36:27 +03:00
Commit Graph

26981 Commits

Author SHA1 Message Date
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
36c7bcd678 Merge remote-tracking branch 'origin/master' into docstrings-round2 2018-11-02 13:58:47 -07:00
Timothy Clem
8d12b5c242 Fix declarations to make tests pass 2018-11-02 13:55:55 -07:00
Timothy Clem
5b9b0daee3 Helper for testing ruby tags 2018-11-02 13:55:46 -07:00
Timothy Clem
0f56f33f24 Introduce some symbol/tags tests 2018-11-02 13:55:30 -07:00
Timothy Clem
bf90ef8e45 Did this 2018-11-02 13:54:55 -07:00
Patrick Thomson
a720cf06d4 Merge pull request #2250 from github/python-functions-wo-annotations
Python assignment: conditionally include annotation on functions
2018-11-02 16:42:25 -04:00
joshvera
2f3fc46e00 Remove subterm uses 2018-11-02 16:18:49 -04:00
joshvera
29383adf7a currentScope returns in Maybe 2018-11-02 16:18:35 -04:00
joshvera
42b350cc6e Remove evalQualifiedImport 2018-11-02 16:18:24 -04:00
joshvera
bb39ebde84 use withLexicalScopeAndFrame 2018-11-02 16:18:16 -04:00
joshvera
6470a3a976 Remove ScopeEnv constraint 2018-11-02 16:17:58 -04:00
joshvera
39deb34db6 ignore define values 2018-11-02 16:17:50 -04:00
joshvera
5647df2a16 remove instance sigs 2018-11-02 16:17:43 -04:00
joshvera
cb8a1222c0 forLoop in terms of withLexicalScopeAndFrame 2018-11-02 16:17:32 -04:00
joshvera
595b3d8747 Add withLexicalScopeAndFrame 2018-11-02 16:17:10 -04:00
joshvera
02bcc64102 Fix Env constraints 2018-11-02 16:17:01 -04:00
Timothy Clem
223298b86a Merge remote-tracking branch 'origin/master' into docstrings-round2 2018-11-02 12:54:21 -07:00
Timothy Clem
018dc73af9 Python assignment: conditionally include annotation on functions 2018-11-02 12:39:38 -07:00
joshvera
f50329ced4 fix up Abstract, Type, and Value 2018-11-02 15:33:45 -04:00
Timothy Clem
a87c526977 No errors, just keep trying 2018-11-02 12:30:43 -07:00
joshvera
d93f2adcd5 fix up primitive, value, and heap 2018-11-02 15:03:10 -04:00
Patrick Thomson
a2ad6664ee Merge pull request #2226 from github/add-tsparse-quiet-flag
Add a --quiet flag to the ts-parse command.
2018-11-02 14:09:07 -04:00
Patrick Thomson
b4a469c706 Merge branch 'master' into add-tsparse-quiet-flag 2018-11-02 13:07:58 -04:00
Patrick Thomson
0a117222c1 Merge branch 'master' into add-explicit-assignment-timeout 2018-11-02 11:10:09 -04:00
Patrick Thomson
b9a742e6db address @rewinfrey's suggestion 2018-11-02 11:03:57 -04:00
Patrick Thomson
9329531c23 Merge pull request #2237 from github/diff-via-fused-effects
Diff via fused effects
2018-11-02 11:01:45 -04:00
Patrick Thomson
a62840c58d Be commensurate with parse --quiet 2018-11-02 11:00:09 -04:00
Patrick Thomson
bd51a186e7 Merge remote-tracking branch 'origin/master' into add-tsparse-quiet-flag 2018-11-02 09:16:28 -04:00
joshvera
e2f9773f7f type signatures 2018-11-01 23:09:03 -04:00
joshvera
4e2126611b Remove allocator from Heap 2018-11-01 23:08:57 -04:00
joshvera
e30239123d port State ScopeGraph to fused effects 2018-11-01 23:08:45 -04:00
joshvera
f85a2d0f1a Evaluator sig 2018-11-01 23:08:28 -04:00
joshvera
daf17e426d derive any class 2018-11-01 22:45:51 -04:00
joshvera
2ae950d82e Pin to the right packages 2018-11-01 22:34:32 -04:00
joshvera
2c4c53904b No effectful constraint 2018-11-01 22:33:43 -04:00
joshvera
82c50ed96d remove pureeffect 2018-11-01 22:32:46 -04:00
joshvera
5234688d9c circular imports 2018-11-01 22:32:30 -04:00
joshvera
c2643d3463 Don't make the heap a monoidal map 2018-11-01 22:32:14 -04:00
joshvera
86253d11c7 NFData instance 2018-11-01 22:31:55 -04:00
joshvera
4870936047 add value param to LoadError 2018-11-01 22:28:45 -04:00
joshvera
069a50a634 add NFData to Position 2018-11-01 22:28:38 -04:00
joshvera
ef9a54cabe add value back to Modules 2018-11-01 22:28:21 -04:00
joshvera
a1bdbccb53 parameterize LoopControl by value 2018-11-01 22:28:10 -04:00
Josh Vera
9f22607fc0 Merge branch 'master' into diff-via-fused-effects 2018-11-01 22:21:46 -04:00
Patrick Thomson
7e09be9b86 Merge pull request #2245 from github/add-data-coerce-to-prologue
Add Data.Coerce to the Prologue.
2018-11-01 21:26:52 -04:00
joshvera
14adcf37d4 ++fastsum 2018-11-01 21:25:08 -04:00
Timothy Clem
4ef4c63851 I changed functions in python that don't have annotations 2018-11-01 17:48:27 -07:00
Timothy Clem
55787183b9 Use evalState 2018-11-01 17:40:58 -07:00
Timothy Clem
12a4fc5073 Turn this on for classes and Modules 2018-11-01 17:40:49 -07:00