Skip to content

Commit 163403c

Browse files
committed
article content
0 parents  commit 163403c

38 files changed

+6174
-0
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
[*]
7+
indent_style = space
8+
indent_size = 2
9+
end_of_line = lf

.eslintrc.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/* eslint-disable no-undef */
2+
module.exports = {
3+
ignorePatterns: ["dtslint/", "lib/", "es6/", "build/", "react/demo/"],
4+
parser: "@typescript-eslint/parser",
5+
parserOptions: {
6+
ecmaVersion: 2018,
7+
sourceType: "module"
8+
},
9+
settings: {
10+
"import/parsers": {
11+
"@typescript-eslint/parser": [".ts", ".tsx"]
12+
},
13+
"import/resolver": {
14+
typescript: {
15+
alwaysTryTypes: true
16+
}
17+
}
18+
},
19+
extends: [
20+
"eslint:recommended",
21+
"plugin:@typescript-eslint/eslint-recommended",
22+
"plugin:@typescript-eslint/recommended",
23+
"plugin:prettier/recommended"
24+
],
25+
plugins: ["import", "sort-destructure-keys", "simple-import-sort", "codegen"],
26+
rules: {
27+
// codegen
28+
"codegen/codegen": "error",
29+
30+
// eslint built-in rules, sorted alphabetically
31+
"no-fallthrough": "off",
32+
"no-inner-declarations": "off",
33+
"no-irregular-whitespace": "off",
34+
"object-shorthand": "error",
35+
"prefer-destructuring": "off",
36+
"sort-imports": "off",
37+
38+
// all other rules, sorted alphabetically
39+
"@typescript-eslint/ban-ts-comment": "off",
40+
"@typescript-eslint/ban-types": "off",
41+
"@typescript-eslint/camelcase": "off",
42+
"@typescript-eslint/consistent-type-imports": "error",
43+
"@typescript-eslint/explicit-function-return-type": "off",
44+
"@typescript-eslint/explicit-module-boundary-types": "off",
45+
"@typescript-eslint/interface-name-prefix": "off",
46+
"@typescript-eslint/no-empty-interface": "off",
47+
"@typescript-eslint/no-explicit-any": "off",
48+
"@typescript-eslint/no-namespace": "off",
49+
"@typescript-eslint/no-unused-vars": "off",
50+
"@typescript-eslint/no-use-before-define": "off",
51+
"import/first": "error",
52+
"import/newline-after-import": "error",
53+
"import/no-duplicates": "error",
54+
"import/no-unresolved": "error",
55+
"import/order": "off",
56+
"simple-import-sort/imports": "error",
57+
"sort-destructure-keys/sort-destructure-keys": "error"
58+
}
59+
}

.github/FUNDING.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# These are supported funding model platforms
2+
3+
github: Matechs-Garage

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "npm"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"

.github/workflows/publish.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Node CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v1
14+
- name: Use Node.js 12.x
15+
uses: actions/setup-node@v1
16+
with:
17+
node-version: 12.x
18+
- name: npm install, build, and test
19+
run: |
20+
npm install -g yarn
21+
yarn
22+
yarn run ci
23+
env:
24+
CI: "true"

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/
2+
coverage/
3+
lib/
4+
tsbuildinfo/

.husky/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.prettierrc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
semi: false,
3+
trailingComma: 'none',
4+
singleQuote: false,
5+
printWidth: 88,
6+
tabWidth: 2,
7+
endOfLine: 'auto'
8+
};

.vscode/common-imports.code-snippets

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{
2+
"Effect": {
3+
"prefix": "+T",
4+
"body": ["import * as T from \"@effect-ts/core/Effect\""],
5+
"description": "Effect as T"
6+
},
7+
"Managed": {
8+
"prefix": "+M",
9+
"body": ["import * as M from \"@effect-ts/core/Effect/Managed\""],
10+
"description": "Managed as M"
11+
},
12+
"Layer": {
13+
"prefix": "+L",
14+
"body": ["import * as L from \"@effect-ts/core/Effect/Layer\""],
15+
"description": "Layer as L"
16+
},
17+
"Ref": {
18+
"prefix": "+Ref",
19+
"body": ["import * as Ref from \"@effect-ts/core/Effect/Ref\""],
20+
"description": "Ref"
21+
},
22+
"RefM": {
23+
"prefix": "+RefM",
24+
"body": ["import * as RefM from \"@effect-ts/core/Effect/RefM\""],
25+
"description": "RefM"
26+
},
27+
"Prelude": {
28+
"prefix": "+P",
29+
"body": ["import * as P from \"@effect-ts/core/Prelude\""],
30+
"description": "Prelude as NA"
31+
},
32+
"DSL": {
33+
"prefix": "+DSL",
34+
"body": ["import * as DSL from \"@effect-ts/core/Prelude/DSL\""],
35+
"description": "Prelude DSL as DSL"
36+
},
37+
"Queue": {
38+
"prefix": "+Q",
39+
"body": ["import * as Q from \"@effect-ts/core/Effect/Queue\""],
40+
"description": "Queue as Q"
41+
},
42+
"Semaphore": {
43+
"prefix": "+Q",
44+
"body": ["import * as Sem from \"@effect-ts/core/Effect/Semaphore\""],
45+
"description": "Semaphore as Sem"
46+
},
47+
"Stream": {
48+
"prefix": "+S",
49+
"body": ["import * as S from \"@effect-ts/core/Effect/Stream\""],
50+
"description": "Semaphore as S"
51+
},
52+
"Either": {
53+
"prefix": "+E",
54+
"body": ["import * as E from \"@effect-ts/core/Either\""],
55+
"description": "Either as E"
56+
},
57+
"Exit": {
58+
"prefix": "+Ex",
59+
"body": ["import * as Ex from \"@effect-ts/core/Effect/Exit\""],
60+
"description": "Exit as Ex"
61+
},
62+
"Cause": {
63+
"prefix": "+C",
64+
"body": ["import * as C from \"@effect-ts/core/Effect/Cause\""],
65+
"description": "Cause as C"
66+
},
67+
"Option": {
68+
"prefix": "+O",
69+
"body": ["import * as O from \"@effect-ts/core/Option\""],
70+
"description": "Option as O"
71+
},
72+
"Fiber": {
73+
"prefix": "+F",
74+
"body": ["import * as F from \"@effect-ts/core/Effect/Fiber\""],
75+
"description": "Fiber as F"
76+
},
77+
"Tuple": {
78+
"prefix": "+Tp",
79+
"body": ["import * as Tp from \"@effect-ts/system/Collections/Immutable/Tuple\""],
80+
"description": "Tuple as Tp"
81+
}
82+
}

.vscode/launch.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"type": "node",
6+
"request": "launch",
7+
"name": "Jest All",
8+
"program": "${workspaceFolder}/node_modules/.bin/jest",
9+
"args": ["--runInBand"],
10+
"console": "integratedTerminal",
11+
"internalConsoleOptions": "neverOpen",
12+
"disableOptimisticBPs": true,
13+
"windows": {
14+
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
15+
}
16+
},
17+
{
18+
"type": "node",
19+
"request": "launch",
20+
"name": "Jest Current File",
21+
"program": "${workspaceFolder}/node_modules/.bin/jest",
22+
"args": [
23+
"${fileBasenameNoExtension}",
24+
"--config",
25+
"jest.config.js"
26+
],
27+
"console": "integratedTerminal",
28+
"internalConsoleOptions": "neverOpen",
29+
"disableOptimisticBPs": true,
30+
"windows": {
31+
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
32+
}
33+
}
34+
]
35+
}

.vscode/operators.code-snippets

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"Pipe Operator |": {
3+
"prefix": "|",
4+
"body": ["[\"|>\"]($0)"],
5+
"description": "Pipe Operator"
6+
},
7+
"Gen Function": {
8+
"prefix": "gen",
9+
"body": ["function* (_) {}"],
10+
"description": "Generator FUnction with _ input"
11+
},
12+
"Gen Yield *": {
13+
"prefix": "!",
14+
"body": ["yield* _($0)"],
15+
"description": "Yield generator calling _()"
16+
}
17+
}

.vscode/settings.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"typescript.tsdk": "node_modules/typescript/lib",
3+
"editor.formatOnSave": true,
4+
"eslint.format.enable": true,
5+
"[javascript]": {
6+
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
7+
},
8+
"[javascriptreact]": {
9+
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
10+
},
11+
"[typescript]": {
12+
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
13+
},
14+
"[typescriptreact]": {
15+
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
16+
},
17+
"prettier.disableLanguages": [
18+
"javascript",
19+
"javascriptreact",
20+
"typescript",
21+
"typescriptreact"
22+
],
23+
"eslint.validate": ["markdown", "javascript", "typescript"],
24+
"editor.codeActionsOnSave": {
25+
"source.fixAll.eslint": true
26+
},
27+
"editor.quickSuggestions": {
28+
"other": true,
29+
"comments": false,
30+
"strings": false
31+
},
32+
"editor.acceptSuggestionOnCommitCharacter": true,
33+
"editor.acceptSuggestionOnEnter": "on",
34+
"editor.quickSuggestionsDelay": 10,
35+
"editor.suggestOnTriggerCharacters": true,
36+
"editor.tabCompletion": "off",
37+
"editor.suggest.localityBonus": true,
38+
"editor.suggestSelection": "recentlyUsed",
39+
"editor.wordBasedSuggestions": true,
40+
"editor.parameterHints.enabled": true,
41+
"files.watcherExclude": {
42+
"**/target": true
43+
}
44+
}

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
### Building custom DSLs in TypeScript
2+
3+
Article at: [Link]()
4+
5+
### Run Examples
6+
7+
Use `yarn dev` to run the examples as:
8+
9+
```
10+
yarn dev final-encodings/io-exec.ts
11+
```

jest.config.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// eslint-disable-next-line
2+
module.exports = {
3+
preset: "ts-jest",
4+
testEnvironment: "node",
5+
rootDir: "./",
6+
clearMocks: true,
7+
collectCoverage: false,
8+
coverageDirectory: "coverage",
9+
collectCoverageFrom: ["src/**/*.ts"],
10+
setupFiles: ["./scripts/jest-setup.ts"],
11+
setupFilesAfterEnv: ["<rootDir>/scripts/jest-setup-after-env.ts"],
12+
modulePathIgnorePatterns: ["<rootDir>/lib"],
13+
verbose: true,
14+
globals: {
15+
"ts-jest": {
16+
tsconfig: "<rootDir>/tsconfig.json",
17+
compiler: "ttypescript"
18+
}
19+
}
20+
}

package.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "building-dsls-in-ts",
3+
"private": "true",
4+
"license": "UNLICENSED",
5+
"scripts": {
6+
"test": "jest",
7+
"postinstall": "husky install",
8+
"ci": "yarn test",
9+
"build": "ttsc -p tsconfig.build.json",
10+
"dev": "ts-node --compiler ttypescript --project tsconfig.json -r @effect-ts/core/Tracing/Enable"
11+
},
12+
"devDependencies": {
13+
"@effect-ts/tracing-plugin": "^0.10.2",
14+
"@types/jest": "^26.0.23",
15+
"@types/node": "^15.3.0",
16+
"@typescript-eslint/eslint-plugin": "^4.23.0",
17+
"@typescript-eslint/parser": "^4.23.0",
18+
"eslint": "^7.26.0",
19+
"eslint-config-prettier": "^8.3.0",
20+
"eslint-import-resolver-typescript": "^2.4.0",
21+
"eslint-plugin-codegen": "^0.15.0",
22+
"eslint-plugin-import": "^2.23.2",
23+
"eslint-plugin-jest": "^24.3.6",
24+
"eslint-plugin-prettier": "^3.4.0",
25+
"eslint-plugin-simple-import-sort": "^7.0.0",
26+
"eslint-plugin-sort-destructure-keys": "^1.3.5",
27+
"husky": "^6.0.0",
28+
"jest": "^26.6.3",
29+
"prettier": "^2.3.0",
30+
"ts-jest": "^26.5.6",
31+
"ts-node": "^9.1.1",
32+
"ttypescript": "^1.5.12",
33+
"typescript": "4.2.4",
34+
"typescript-transform-paths": "^2.2.3",
35+
"yarn-deduplicate": "^3.1.0"
36+
},
37+
"dependencies": {
38+
"@effect-ts/core": "^0.39.2"
39+
}
40+
}

pre-commit.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
if yarn yarn-deduplicate -fl; then
3+
echo "No duplicates found. Pursuing..."
4+
else
5+
echo "ERROR: Lockfile contains duplicates!"
6+
echo "deduplicating..."
7+
yarn yarn-deduplicate
8+
yarn
9+
echo "deduplication finished"
10+
exit 1
11+
fi

0 commit comments

Comments
 (0)