Class: Plumb::NeverClass

Inherits:
Object
  • Object
show all
Includes:
Composable
Defined in:
lib/plumb/never_class.rb

Overview

The bottom type — the dual of AnyClass. No value inhabits it, so it always invalidates. It is produced by a provably-empty intersection (see Composable#& / Subtyping.intersect) and reduces at composition time:

A & Never == Never   (Never dominates the meet)
A | Never == A       (Never is absorbed by the join)
Never >> A == Never

As a subtype, Never is below everything: Never <= X for all X (its #subtype_of? hook always says yes), and nothing but Never is <= Never.

Instance Method Summary collapse

Methods included from Composable

#[], #absorb_input, #absorb_output, #accepted_type, #as_node, #build, #check, #children, #defer, #fusable_step?, #fuse_with, #generate, #idempotent?, included, #input_type, #invalid, #invoke, #match, #metadata, #not, #output_type, #pipeline, #policy, resolve_operand, #static, #subtype_identity, #to_json_schema, #to_mermaid, #to_plumb_type, #to_s, #transform, #value, #where, #with, wrap

Methods included from Callable

#parse, #resolve

Instance Method Details

#&(_other) ⇒ Object

Never dominates intersection and short-circuits sequencing/narrowing.



18
# File 'lib/plumb/never_class.rb', line 18

def &(_other) = self

#/(_other) ⇒ Object



20
# File 'lib/plumb/never_class.rb', line 20

def /(_other) = self

#>>(_other) ⇒ Object



19
# File 'lib/plumb/never_class.rb', line 19

def >>(_other) = self

#call(result) ⇒ Object



28
# File 'lib/plumb/never_class.rb', line 28

def call(result) = result.invalid!(errors: 'no value is allowed (Never)')

#subtype_of?(_other) ⇒ Boolean

Bottom is a subtype of every type. The mirror direction (X <= Never) is left to the default leaf hook, which is true only reflexively (X == Never).

Returns:

  • (Boolean)


32
# File 'lib/plumb/never_class.rb', line 32

def subtype_of?(_other) = true

#value_preserving?Boolean

It never succeeds, so it never changes a value — value-preserving like Any, which keeps union absorption uniform.

Returns:

  • (Boolean)


36
# File 'lib/plumb/never_class.rb', line 36

def value_preserving? = true

#|(other) ⇒ Object

Never is the identity of union: Never | X == X. Route through the hook (not bare Composable.wrap) so a context-resolving operand — an Encoder orients, a Codec raises at composition — is handled like every other #| rather than leaking in as an unresolved node.



26
# File 'lib/plumb/never_class.rb', line 26

def |(other) = Composable.resolve_operand(other, op: :|, left: self)