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

27913 Commits

Author SHA1 Message Date
Patrick Thomson
ebbe50a080 Stray import 2019-03-01 16:54:02 -05:00
Patrick Thomson
6a0c0e67c5 Document APIConvert and APIBridge. 2019-03-01 16:45:26 -05:00
Patrick Thomson
37d697f0da Remove unlawful lens. 2019-03-01 16:38:37 -05:00
Patrick Thomson
c316b20f07 Isolate the pattern of a ^? re b into its own combinator. 2019-03-01 16:25:59 -05:00
Josh Vera
403c97abf3 Merge branch 'master' into env-var-name-update 2019-03-01 16:19:03 -05:00
Patrick Thomson
a66407ec02 Merge remote-tracking branch 'origin/master' into converting-api-rfc 2019-03-01 16:17:03 -05:00
Patrick Thomson
e5563f39d5 Merge branch 'master' into pattern-synonyms-for-blobpair 2019-03-01 16:16:53 -05:00
Patrick Thomson
f7aa57a123 Merge pull request #2414 from github/bump-python-ts
Bump python-tree-sitter to avoid dirty worktrees.
2019-03-01 16:16:36 -05:00
Josh Vera
734fa692e2 Merge branch 'master' into alephd-feature-flag 2019-03-01 15:35:36 -05:00
Patrick Thomson
83322e9f94 Fix lints. 2019-03-01 15:28:22 -05:00
Patrick Thomson
b92d9a5382 Rename Helpers to Bridge. 2019-03-01 15:27:13 -05:00
Patrick Thomson
7204da3951 RFC: unified interface for converting API/legacy/native types.
As we've brought up a Twirp-based API, we've found a need to convert
between several different "views" of the same data, such as position
or span information. Because all protobuf fields are optional, we have
to juggle the `Maybe` values associated with the protobuf fields that
we are converting. While I think this approach has merit, there is a
complexity overhead associated with these conversions: we currently
have around ten ad-hoc functions that perform these conversions, often
containing superfluous `Maybe`s for the sake of convenience.

I've replaced these ad-hoc functions with two classes: `APIBridge` and
`APIConvert`. An instance of `APIBridge` between types `a` and `b`
means that we can convert between `a` and `b` and vice versa
losslessly; in other words, there is an isomorphism between them.
`APIConvert` means that you can convert from an `a` to a `b`, but you
may not be able to convert from all `b`s to an `a` (such as in the
case of missing fields); in other words, there is a partial isomorphism.

These are implemented with concepts from `lens`, namely an `Iso` for
`APIBridge` and a `Prism` for `APIConvert`.

Advantages of this approach:
* Lawful API. We can now clearly delineate the fact that converting a
  native data type to an API data type always succeeds, but the
  reverse may fail: an API `Span` may have missing position
  information, and we want to handle that explicitly, rather than
  paper over it with these helper functions. Both the APIBridge and
  APIConvert typeclasses provide a set of strong laws re. behavior,
  since they provide a lens-y interface.
* Unified API. No longer do we have to juggle a set of functions in
  our heads - no need to choose between `spanToSpan`,
  `spanToLegacySpan`, or `apiSpanToSpan`. `converting` and `bridging`
  do the work for you. Everything is much cleaner.
* Fewer partial functions. The converter from API blob pairs to native
  blob pairs no longer calls `error`, which is definitely a good
  thing.
* Historical precedent. Prisms and isomorphisms are a fluent way to
  express data transformations; the team behind Minecraft uses
  isomorphisms and prisms [to transfer data between versions][minecraft].

Disadvantages:
* Complexity overhead. You have to learn about prisms, reviews,
  isomorphisms, neither of which is the world's hardest concept but
  which take a little while to internalize.
* This might be polymorphism for polymorphism's sake.

Something we could do is postpone this patch until I have a chance to
give a lens tutorial in a Codex.

[minecraft]: https://github.com/Mojang/DataFixerUpper
2019-03-01 14:17:23 -05:00
Patrick Thomson
39ff80f652 Merge branch 'bump-python-ts' into converting-api-rfc 2019-03-01 14:01:40 -05:00
Patrick Thomson
2eb1280681 WIP 2019-03-01 14:01:27 -05:00
Patrick Thomson
e7c4884cb6 Otiose parentheses. 2019-03-01 13:00:12 -05:00
Patrick Thomson
77672564eb unused imports 2019-03-01 12:58:51 -05:00
Patrick Thomson
a2772e4338 Bump python-tree-sitter so to avoid dirty worktrees.
Because of Python grammar changes, this removes the `Identifier'` token.
2019-03-01 12:53:19 -05:00
Patrick Thomson
f29f26cc71 Fix some errors that crept in. 2019-03-01 12:36:16 -05:00
Patrick Thomson
079ce8baa0 Eliminate other places where These leaked to implementation. 2019-03-01 11:52:21 -05:00
Patrick Thomson
c41d60548c Use pattern synonyms in API helpers. 2019-03-01 11:50:46 -05:00
Patrick Thomson
060c8f50ff Refactor: use pattern synonyms to construct BlobPairs.
The `BlobPair` type is defined as an alias for `Join These Blob`. Though
this sacrifices a degree of type safety, it's extremely convenient, as
you can get to a Functor and Bifunctor instance very quickly.
Pattern-matching on `BlobPair` is less elegant though, as it requires
a nested Join then a match on `These`, which is not immediately
indicative of what a given pair might do.

This adds pattern synonyms for the `Inserting`, `Deleting`, and
`Diffing` cases, and removes the less-expressive functions returning such.
2019-03-01 11:19:24 -05:00
Rick Winfrey
ca6d7b432d Merge branch 'scope-graph-indexer' of https://github.com/github/semantic into scope-graph-indexer 2019-02-28 15:58:11 -08:00
Rick Winfrey
6bbc437d62 Merge branch 'master' into scope-graph-indexer 2019-02-28 15:57:59 -08:00
joshvera
a7a975f00b Merge remote-tracking branch 'origin/master' into alephd-feature-flag 2019-02-28 17:47:27 -05:00
joshvera
7dad030d34 Update repository push proto schema using twirp-haskell 2019-02-28 16:05:00 -05:00
Timothy Clem
4b449170f0 Merge pull request #2407 from github/bump-alephd-resources
Give alephd a few more resources
2019-02-28 09:07:23 -08:00
Josh Vera
6de8ae0128 Merge branch 'master' into bump-alephd-resources 2019-02-28 10:46:07 -05:00
Josh Vera
3df675606d Merge pull request #2406 from github/rename-aleph-flags
Rename env flags to have an ALEPHD prefix
2019-02-28 10:45:29 -05:00
Rick Winfrey
0e23e4256d Merge branch 'master' into scope-graph-indexer 2019-02-27 17:03:08 -08:00
Josh Vera
b525bad1ba Merge branch 'master' into rename-aleph-flags 2019-02-27 18:23:56 -05:00
Timothy Clem
d0c6513d30 Merge pull request #2405 from github/alephd-github-api
Allow querying regular github.com api
2019-02-27 15:09:53 -08:00
Josh Vera
fb4aaf9a53 Merge branch 'master' into rename-aleph-flags 2019-02-27 18:02:05 -05:00
Timothy Clem
229592411a Merge branch 'master' into alephd-github-api 2019-02-27 14:55:37 -08:00
Timothy Clem
59ab1c7758 Merge pull request #2404 from github/slurp-enhancements
Slurp enhancements to publish RepositoryPush Event to kafka
2019-02-27 14:55:27 -08:00
Timothy Clem
1ad07234c9 Merge branch 'master' into slurp-enhancements 2019-02-27 14:08:21 -08:00
Josh Vera
1e52628324 Merge pull request #2403 from github/kafka-config-changes
Add env vars for kafka broker and topic name
2019-02-27 16:53:38 -05:00
Patrick Thomson
aa197eb107 Something in that last revision made licensed segfault. 2019-02-27 16:18:42 -05:00
Rick Winfrey
e7942347b7 Merge branch 'master' into kafka-config-changes 2019-02-27 13:09:02 -08:00
Rick Winfrey
b8c25e0bab Merge pull request #2401 from github/indexer-setup
Wrap up alephd-setup
2019-02-27 12:56:19 -08:00
Patrick Thomson
fd76bfe42f After removing --depth=1. 2019-02-27 15:34:47 -05:00
Patrick Thomson
dad7be04af First results from bribe upgrades. 2019-02-27 14:21:45 -05:00
Rick Winfrey
6112be42ec Merge branch 'master' into indexer-setup 2019-02-27 09:45:40 -08:00
Timothy Clem
6c43919667 Merge pull request #2400 from github/more-aleph-fixes
More alephd indexer fixes
2019-02-27 09:35:48 -08:00
Timothy Clem
bfc4c12729 Merge branch 'master' into more-aleph-fixes 2019-02-27 09:22:20 -08:00
Patrick Thomson
67c2b79b53 Merge pull request #2398 from github/indexer-setup
Indexer setup instructions
2019-02-27 11:51:37 -05:00
Rick Winfrey
5385793916 Merge branch 'master' into indexer-setup 2019-02-27 08:35:09 -08:00
Timothy Clem
2fb4d678ad Merge remote-tracking branch 'origin/master' into more-aleph-fixes 2019-02-27 08:06:30 -08:00
Rick Winfrey
2aaf9b3f54 Merge branch 'master' into indexer-setup 2019-02-26 18:05:45 -08:00
Rick Winfrey
005869fd91 Merge pull request #2397 from github/indexer-fixes
Rename Repository model types to Index
2019-02-26 18:05:21 -08:00
Rick Winfrey
41effd867f Merge branch 'indexer-fixes' of https://github.com/github/semantic into indexer-fixes 2019-02-26 17:52:18 -08:00