(self: LogLevel, that: LogLevel): booleanEquivalence instance for log levels using strict equality (===).
When to use
Use to compare two LogLevel values when only the exact same level should
match.
Details
Each log level string, including All and None, only matches itself.
Example (Comparing log levels)
import { LogLevel } from "effect"
console.log(LogLevel.Equivalence("Error", "Error")) // true
console.log(LogLevel.Equivalence("Error", "Info")) // falseexport const const Equivalence: Equ.Equivalence<LogLevel>Equivalence instance for log levels using strict equality (===).
When to use
Use to compare two LogLevel values when only the exact same level should
match.
Details
Each log level string, including All and None, only matches itself.
Example (Comparing log levels)
import { LogLevel } from "effect"
console.log(LogLevel.Equivalence("Error", "Error")) // true
console.log(LogLevel.Equivalence("Error", "Info")) // false
Equivalence: import EquEqu.type Equivalence<in A> = (
self: A,
that: A
) => boolean
Represents an equivalence relation over type A.
When to use
Use as a type annotation when you accept or return an equivalence function.
Details
- Returns
boolean: true if values are equivalent, false otherwise
- Must satisfy reflexive, symmetric, and transitive properties
Example (Defining simple number equivalence)
import type { Equivalence } from "effect"
const numberEq: Equivalence.Equivalence<number> = (a, b) => a === b
console.log(numberEq(1, 1)) // true
console.log(numberEq(1, 2)) // false
Example (Defining custom object equivalence)
import type { Equivalence } from "effect"
interface Point {
x: number
y: number
}
const pointEq: Equivalence.Equivalence<Point> = (a, b) =>
a.x === b.x && a.y === b.y
console.log(pointEq({ x: 1, y: 2 }, { x: 1, y: 2 })) // true
Equivalence<type LogLevel =
| "All"
| "Fatal"
| "Error"
| "Warn"
| "Info"
| "Debug"
| "Trace"
| "None"
Represents every level used by Effect logging, including concrete message
severities and the All and None sentinel levels.
When to use
Use to type values that may be either concrete log message severities or
logging configuration sentinels.
Details
The levels are ordered from most severe to least severe:
All - Special level that allows all messages
Fatal - System is unusable, immediate attention required
Error - Error conditions that should be investigated
Warn - Warning conditions that may indicate problems
Info - Informational messages about normal operation
Debug - Debug information useful during development
Trace - Very detailed trace information
None - Special level that suppresses all messages
Example (Using log levels)
import { Effect } from "effect"
// Using log levels with Effect logging
const program = Effect.gen(function*() {
yield* Effect.logFatal("System failure")
yield* Effect.logError("Database error")
yield* Effect.logWarning("High memory usage")
yield* Effect.logInfo("User logged in")
yield* Effect.logDebug("Processing request")
yield* Effect.logTrace("Variable state")
})
// Type-safe log level variables
const errorLevel = "Error" // LogLevel
const debugLevel = "Debug" // LogLevel
LogLevel> = import EquEqu.const strictEqual: <A>() => Equivalence<A>Creates an equivalence relation that uses strict equality (===) to compare values.
When to use
Use when you need strict equality (===) as the comparison.
Details
Uses JavaScript's strict equality operator (===). Primitives compare by
value. Objects compare by reference, so only the same object instance is
equivalent. Use this as a building block for more complex equivalences via
mapInput or combine.
Gotchas
NaN !== NaN, so NaN values are never considered equivalent.
Example (Comparing primitive types)
import { Equivalence } from "effect"
const strictEq = Equivalence.strictEqual<number>()
console.log(strictEq(1, 1)) // true
console.log(strictEq(1, 2)) // false
console.log(strictEq(NaN, NaN)) // false (NaN !== NaN)
Example (Comparing objects by reference)
import { Equivalence } from "effect"
const obj = { value: 42 }
const strictObjEq = Equivalence.strictEqual<typeof obj>()
console.log(strictObjEq(obj, obj)) // true
console.log(strictObjEq(obj, { value: 42 })) // false (different references)
strictEqual<type LogLevel =
| "All"
| "Fatal"
| "Error"
| "Warn"
| "Info"
| "Debug"
| "Trace"
| "None"
Represents every level used by Effect logging, including concrete message
severities and the All and None sentinel levels.
When to use
Use to type values that may be either concrete log message severities or
logging configuration sentinels.
Details
The levels are ordered from most severe to least severe:
All - Special level that allows all messages
Fatal - System is unusable, immediate attention required
Error - Error conditions that should be investigated
Warn - Warning conditions that may indicate problems
Info - Informational messages about normal operation
Debug - Debug information useful during development
Trace - Very detailed trace information
None - Special level that suppresses all messages
Example (Using log levels)
import { Effect } from "effect"
// Using log levels with Effect logging
const program = Effect.gen(function*() {
yield* Effect.logFatal("System failure")
yield* Effect.logError("Database error")
yield* Effect.logWarning("High memory usage")
yield* Effect.logInfo("User logged in")
yield* Effect.logDebug("Processing request")
yield* Effect.logTrace("Variable state")
})
// Type-safe log level variables
const errorLevel = "Error" // LogLevel
const debugLevel = "Debug" // LogLevel
LogLevel>()