Initial commit
Some checks failed
Lint / lint (push) Failing after 12s
Publish / publish (push) Failing after 11s

This commit is contained in:
Julien Valverdé
2026-03-25 00:44:50 +01:00
commit c77057a2c9
68 changed files with 5627 additions and 0 deletions

26
packages/example/.gitignore vendored Normal file
View File

@@ -0,0 +1,26 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
.tanstack

View File

View File

@@ -0,0 +1,8 @@
{
"$schema": "https://biomejs.dev/schemas/latest/schema.json",
"root": false,
"extends": "//",
"files": {
"includes": ["./src/**"]
}
}

View File

@@ -0,0 +1,19 @@
{
"name": "@effect-lens/example",
"version": "0.0.0",
"type": "module",
"private": true,
"scripts": {
"lint:tsc": "tsc --noEmit",
"lint:biome": "biome lint",
"clean:cache": "rm -rf .turbo",
"clean:modules": "rm -rf node_modules"
},
"dependencies": {
"effect": "^3.21.0",
"effect-lens": "workspace:*"
},
"overrides": {
"effect": "^3.21.0"
}
}

View File

@@ -0,0 +1,20 @@
import { Array, Console, Effect, Stream, SubscriptionRef } from "effect"
import { Lens } from "effect-lens"
Effect.gen(function*() {
// The ref is the data source
const ref = yield* SubscriptionRef.make([12, 87, 69])
// The lens acts as a proxy that allows reading, subscribing from and writing to that
// data source with a similar API to Effect's SubscriptionRef
const lens = Lens.fromSubscriptionRef(ref)
// ^ Lens.Lens<number[], never, never, never, never>
const value = yield* Lens.get(lens)
yield* Effect.forkScoped(Stream.runForEach(lens.changes, Console.log))
yield* Lens.update(lens, Array.replace(1, 1664))
})
Effect.gen(function*() {
})

View File

@@ -0,0 +1,39 @@
{
"compilerOptions": {
// Enable latest features
"lib": ["ESNext", "DOM"],
"target": "ESNext",
"module": "NodeNext",
"moduleDetection": "force",
"jsx": "react-jsx",
// "allowJs": true,
// Bundler mode
"moduleResolution": "NodeNext",
// "allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
// "noEmit": true,
// Best practices
"strict": true,
"skipLibCheck": true,
"noFallthroughCasesInSwitch": true,
// Some stricter flags (disabled by default)
"noUnusedLocals": false,
"noUnusedParameters": false,
"noPropertyAccessFromIndexSignature": false,
// Build
"outDir": "./dist",
"declaration": true,
"sourceMap": true,
"plugins": [
{ "name": "@effect/language-service" }
]
},
"include": ["./src"],
"exclude": ["**/*.test.ts", "**/*.spec.ts"]
}