Skip to content

Commit

Permalink
Bring in all the autoserialization goodness (#196)
Browse files Browse the repository at this point in the history
This is finally in a place where it's self-hosting -- the config & lockfile ser/de are generated within it. Also we have auto-migration & backwards compatability ;)
  • Loading branch information
jaredly authored Nov 21, 2018
1 parent 157818f commit ea4b73d
Show file tree
Hide file tree
Showing 52 changed files with 10,909 additions and 542 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
types.lock.json binary
3 changes: 1 addition & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
// "reason_language_server.location": "./lib/bs/native/bin.native",
"reason_language_server.location": "./_esy/default/build/default/bin/Bin.exe",
// "reason_language_server.show_debug_errors": true,
"reason_language_server.format_width": 120,
"reason_language_server.format_width": 100,
// "reason_language_server.location": "./lib/bs/native/bin.native.exe",
// "reason_language_server.reloadOnChange": true,
"editor.tabSize": 2,
"editor.parameterHints": false,
"editor.formatOnPaste": true,
"workbench.settings.editor": "json"
}
20 changes: 20 additions & 0 deletions core/SharedTypes.re
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,25 @@ module SimpleType = {
body: body('source)
};

let rec usedSourcesExpr = exp => switch exp {
| Tuple(items) => items->Belt.List.map(usedSourcesExpr)->List.concat
| Reference(source, args) => [source, ...args->Belt.List.map(usedSourcesExpr)->List.concat]
| Fn(args, res) => args->Belt.List.map(snd)->Belt.List.map(usedSourcesExpr)->List.concat @ usedSourcesExpr(res)
| Variable(_) | AnonVariable | Other => []
};

let usedSources = decl => switch (decl.body) {
| Expr(exp) => usedSourcesExpr(exp)
| Record(items) => items->Belt.List.map(snd)->Belt.List.map(usedSourcesExpr)->List.concat
| Variant(items) => items->Belt.List.map(((_, items, res)) =>
items->Belt.List.map(usedSourcesExpr)->List.concat @ switch res {
| None => []
| Some(res) => usedSourcesExpr(res)
}
)->List.concat
| Open | Abstract => []
};

let rec cmp: 'a 'b . (('a, 'b) => bool, expr('a), expr('b)) => bool = (compareSources, one, two) => switch (one, two) {
| (Variable(one), Variable(two)) => one == two
| (AnonVariable, AnonVariable) => true
Expand Down Expand Up @@ -78,6 +97,7 @@ type flexibleDeclaration = {
declToString: string => string,
declarationKind: kinds,
asSimpleDeclaration: string => SimpleType.declaration(Path.t),
migrateAttributes: unit => Parsetree.attributes,
};

type filePath = string
Expand Down
29 changes: 29 additions & 0 deletions examples/example-project/src/Hello.re
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,32 @@ switch (y) {
/* let x = [%raw " hello"]; */

let awesome = "hello";


type shortReference = (string, list(string), string);

type reference = {
uri: string,
moduleName: string,
modulePath: list(string),
name: string,
};

type typeSource =
| Builtin(string)
| Public(reference)
| NotFound;

type lockfile = {
version: int,
pastVersions: Belt.HashMap.Int.t(
list((
shortReference,
int
))
),
current: list((
shortReference,
int
))
};
Loading

0 comments on commit ea4b73d

Please sign in to comment.