@@ -485,14 +485,55 @@ export const omit: <Services, S extends Array<ValidTagsById<Services>>>(
485485export  const  Tag : < const  Id  extends  string > ( id : Id )  =>  < Self ,  Shape > ( )  =>  TagClass < Self ,  Id ,  Shape >  =  internal . Tag 
486486
487487/** 
488+  * Creates a context tag with a default value. 
489+  * 
490+  * **Details** 
491+  * 
492+  * `Context.Reference` allows you to create a tag that can hold a value. You can 
493+  * provide a default value for the service, which will automatically be used 
494+  * when the context is accessed, or override it with a custom implementation 
495+  * when needed. 
496+  * 
488497 * @example  
489-  * import { Context, Layer } from "effect" 
498+  * ```ts 
499+  * // Title: Declaring a Tag with a default value 
500+  * import { Context, Effect } from "effect" 
501+  * 
502+  * class SpecialNumber extends Context.Reference<SpecialNumber>()( 
503+  *   "SpecialNumber", 
504+  *   { defaultValue: () => 2048 } 
505+  * ) {} 
506+  * 
507+  * //      ┌─── Effect<void, never, never> 
508+  * //      ▼ 
509+  * const program = Effect.gen(function* () { 
510+  *   const specialNumber = yield* SpecialNumber 
511+  *   console.log(`The special number is ${specialNumber}`) 
512+  * }) 
513+  * 
514+  * // No need to provide the SpecialNumber implementation 
515+  * Effect.runPromise(program) 
516+  * // Output: The special number is 2048 
517+  * ``` 
490518 * 
491-  * class MyTag extends Context.Reference<MyTag>()("MyTag", { 
492-  *   defaultValue: () => ({ myNum: 108 }) 
493-  * }) { 
494-  *  static Live = Layer.succeed(this, { myNum: 108 }) 
495-  * } 
519+  * @example  
520+  * ```ts 
521+  * // Title: Overriding the default value 
522+  * import { Context, Effect } from "effect" 
523+  * 
524+  * class SpecialNumber extends Context.Reference<SpecialNumber>()( 
525+  *   "SpecialNumber", 
526+  *   { defaultValue: () => 2048 } 
527+  * ) {} 
528+  * 
529+  * const program = Effect.gen(function* () { 
530+  *   const specialNumber = yield* SpecialNumber 
531+  *   console.log(`The special number is ${specialNumber}`) 
532+  * }) 
533+  * 
534+  * Effect.runPromise(program.pipe(Effect.provideService(SpecialNumber, -1))) 
535+  * // Output: The special number is -1 
536+  * ``` 
496537 * 
497538 * @since  3.11.0 
498539 * @category  constructors 
0 commit comments