Comments (3)
This is how you would nest tagged enums:
import { Data } from "effect"
type ServerError = Data.TaggedEnum<{
InternalError: { message: string }
}>
type HttpError = Data.TaggedEnum<{
ServerError: { error: ServerError }
}>
const { InternalError } = Data.taggedEnum<ServerError>()
const { ServerError } = Data.taggedEnum<HttpError>()
ServerError({ error: InternalError({ message: "oops" }) })
from effect.
@ahrjarrett / @tim-smart Is there now a way to create nested taggedEnums
? E.g.
export type ServerErrors = Data.TaggedEnum<{
BadGateway: {},
GatewayTimeout: {
timeout: number;
}
}>
export type HttpError = Data.TaggedEnum<{
NotFound: {};
ServerError: ServerErrors;
}>;
from effect.
@Clindbergh It's been a minute since I worked on this, but IIRC the change implemented as part of #1521 was to show users a TypeError if they attempt to nest a TaggedEnum
inside another TaggedEnum
.
from effect.
Related Issues (20)
- Code documentation doesn't reflect actual changes in the code ("provideContext" was renamed to "provide")
- CLI: `Options.repeated` causes CLI to hang in certain senarios HOT 4
- Schema: Allow non-async Effects to be used with `*Sync` combinators
- CLI: nesting args/options within objects causes stack overflow at `reconstructConfigTree`
- From Discord: Unexpected Logs from Test and AnotherTest
- Schema: default class field constructors HOT 6
- CLI: Enable prompt commands to be able to have `Options` and `Args` HOT 1
- Type error when using `S.literal` and `S.optional` with `default` HOT 2
- Add option to preserve excess properties from S.decode, S.parse
- Tree shaking question HOT 3
- Schema: expose `literals` and `fields` HOT 15
- From Discord: Adding a Service to an Existing Runtime
- Regression: Allow specifying empty object in Data.TaggedEnum HOT 5
- Persisted Cache for preheating on startup HOT 2
- ReadOnly Array flatMap stack overflow HOT 3
- When using SchemaTaggedError with Match, I got an Effect.Effect<unknow, unknown, unknown> HOT 3
- JSONSchema not working as expected with `S.optional` HOT 4
- From Discord: Bug with Rpc API: Suppressed Transport Level Errors HOT 1
- CLI: Transform JS object of CLI options to a string HOT 2
- Schema: Create API to add annotations to Class schemas HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from effect.