Opaque Type

Noun · Development

Definitions

  1. A type whose internal representation is hidden from consumers of a module or API, exposing only the operations defined on it. In Swift (`some Protocol`), Haskell (via module exports), and Rust (via `impl Trait` in return position), opaque types allow a function to commit to returning a specific concrete type without revealing which one.

    In plain English: A type where you know what you can do with it but not how it's built inside — like a sealed box with buttons on the outside.

    Example: "Returning `some View` makes the type opaque so SwiftUI can optimize the view hierarchy without us spelling out the 14-level nested generic."

Related Terms