Unscoped

zio.blocks.scope.Unscoped
See theUnscoped companion object
trait Unscoped[A]

Marker typeclass for types that can escape a scope unscoped.

Types with an Unscoped instance are considered "safe data" - they don't hold resources and can be freely extracted from a scope without tracking.

==Default Instances==

The following types have Unscoped instances by default:

  • Primitives: Int, Long, Short, Byte, Char, Boolean, Float, Double, Unit
  • Text: String
  • Numeric: BigInt, BigDecimal
  • Collections: Array, List, Vector, Set, Seq, IndexedSeq, Iterable, Map (when elements are Unscoped)
  • Containers: Option, Either (when elements are Unscoped)
  • Tuples: up to 4-tuples (when elements are Unscoped)
  • Time: java.time.* value types, scala.concurrent.duration.*
  • Other: java.util.UUID, zio.blocks.chunk.Chunk

==Resource Types==

Types representing resources (streams, connections, handles, etc.) should NOT have Unscoped instances. This ensures they remain tracked by the scope system and cannot accidentally escape.

Type parameters

A

the type that can escape scopes

Attributes

Example
 // Primitives escape freely (auto-unwrapped by $)
 Scope.global.scoped { s =>
   import s._
   (s $ stream)(_.read()) // returns Int directly since Int: Unscoped
 }
 // Resources stay scoped
 val body: $[InputStream] = (scope $ request)(_.body)  // InputStream stays scoped (no Unscoped instance)
Companion
object
Source
Unscoped.scala
Graph
Supertypes
class Object
trait Matchable
class Any
In this article