-
-
Notifications
You must be signed in to change notification settings - Fork 440
Open
Description
Currently, there's no standard way to detect Effect data types (Option, Either, etc.) at runtime and retrieve their type names for generic dispatch systems (like trait implementations).
Use case: Building a trait system that needs to:
- Detect if a value is an Effect type (vs native JS type)
- Get the type name (e.g., "Option", "Either") for dispatch
Current approach:
// Check for TypeId symbol and parse description
for (const typeId of [Option.TypeId, Either.TypeId]) {
if (typeId in value) {
const typeName = typeId.description?.slice(7) // "effect/Option" → "Option"
return typeName
}
}Issues:
- Brittle: relies on Symbol.description format "effect/TypeName"
- Requires maintaining hardcoded list of TypeId symbols
- No way to detect all Effect types generically
Proposed solution:
Effect.getTypeName(value) // "Option" | "Either" | ... | nullThis single API provides both detection (non-null) and identification (the name), enabling generic handling of Effect types in libraries without brittle Symbol parsing.
Metadata
Metadata
Assignees
Labels
No labels