Hyperlinkv0.8.0-beta.28

Config

Config.optionconsteffect/Config.ts:401
<A>(self: Config<A>): Config<Option.Option<A>>

Makes a config optional: returns Some(value) on success and None when data is missing.

When to use

Use when you need to handle a config key that may or may not be present.

Gotchas

Like withDefault, only missing-data errors produce None. Validation errors still propagate.

Example (Reading optional config)

import { Config, ConfigProvider, Effect } from "effect"

const maybePort = Config.option(Config.number("port"))

const provider = ConfigProvider.fromUnknown({})
// Effect.runSync(maybePort.parse(provider)) // { _tag: "None" }
combinatorswithDefault
Source effect/Config.ts:4012 lines
export const option = <A>(self: Config<A>): Config<Option.Option<A>> =>
  self.pipe(map(Option.some), withDefault(Option.none()))