Skip to content

Commit fab91b0

Browse files
author
Patrick Thomson
committed
more refinements
1 parent 5e4d177 commit fab91b0

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

.github/workflows/haskell.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
strategy:
1616
matrix:
17-
ghc: ["8.8.3", "8.10.1"]
17+
ghc: ["8.10.1"]
1818
cabal: ["3.2.0.0"]
1919

2020
steps:

semantic-ast/BUILD.bazel

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,19 @@ haskell_library(
4848
],
4949
)
5050

51+
all_ts_deps = ["@tree-sitter-{name}//:tree-sitter-{name}".format(name = name) for name in [
52+
"go",
53+
"java",
54+
"json",
55+
"php",
56+
"python",
57+
"ql",
58+
"ruby",
59+
"rust",
60+
"tsx",
61+
"typescript",
62+
]]
63+
5164
haskell_binary(
5265
name = "generate-ast",
5366
srcs = glob(["app/**/*.hs"]),
@@ -64,6 +77,5 @@ haskell_binary(
6477
"@stackage//:lens",
6578
"@stackage//:neat-interpolation",
6679
"@stackage//:optparse-generic",
67-
"@tree-sitter-json//:tree-sitter-json",
68-
],
80+
] + all_ts_deps,
6981
)

semantic-ast/app/Main.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ data Config = Config {language :: Text, path :: FilePath}
3838
-- a qualified name on the LHS of a typeclass declaration, which Haskell
3939
-- doesn't like at all. I haven't figured out quite why we get this qualified
4040
-- name, but for now the easiest thing to do is some nested updates with lens.
41-
adjust :: [Dec] -> [Dec]
42-
adjust = mapped._InstanceD.typed.mapped %~ (values %~ truncate) . (functions %~ truncate)
41+
adjust :: Dec -> Dec
42+
adjust = _InstanceD.typed.mapped %~ (values %~ truncate) . (functions %~ truncate)
4343
where
4444
-- Need to handle functions with no arguments, which are parsed as ValD entities,
4545
-- as well as those with arguments, which are FunD.
@@ -53,7 +53,7 @@ adjust = mapped._InstanceD.typed.mapped %~ (values %~ truncate) . (functions %~
5353
main :: IO ()
5454
main = do
5555
Config language path <- Opt.getRecord "generate-ast"
56-
decls <- T.pack . pprint . adjust <$> astDeclarationsIO JSON.tree_sitter_json path
56+
decls <- T.pack . pprint . fmap adjust <$> astDeclarationsIO JSON.tree_sitter_json path
5757

5858
let programText =
5959
[trimming|

0 commit comments

Comments
 (0)