✨ ARCANUM RUNE DIFFICULTY: Apprentice Structural

The Decorator Aura

Attaching additional responsibilities to an object dynamically.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Decorator
ARCANUM SCHOOL: Enchantment // Aura Modification
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
module DecoratorPattern where

open import Data.String

record Notifier : Set where
  field send : String → String
  
baseNotifier : Notifier
baseNotifier = record { send = λ msg → "Sent: " }

encryptDecorator : Notifier → Notifier
encryptDecorator inner = record 
  { send = λ msg → Notifier.send inner "EncryptedMsg" }

The Decorator Aura

By layering continuous auras around a base construct, we can alter its behavior without opening up its core matrix. The Decorator Aura wraps functions and records dynamically.

The Dependent Runes

A decorator in pure functional paradigms is merely a higher-order function or a wrapper that takes a record of a specific type and returns an augmented record of that same type.

Runic Tags: #agda #decorator #enchantment