The Adapter of Arcane Interfaces
Translating incompatible magical protocols using functional wrappers.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Adapter
ARCANUM SCHOOL: Transmutation // Metamagic
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
interface ArcaneAdapter
exposes [castOldSpell, newSpellAdapter]
imports []
# The old, incompatible magic interface
OldSpell : {
incantation : Str,
powerLevel : U64
}
castOldSpell : OldSpell -> Str
castOldSpell = \spell ->
"Casting ${spell.incantation} at power ${Num.toStr spell.powerLevel}"
# The new modern interface
NewSpell : {
formula : Str,
intensity : F64
}
# The Adapter function
newSpellAdapter : NewSpell -> OldSpell
newSpellAdapter = \newSpell ->
{
incantation: newSpell.formula,
powerLevel: Num.round (newSpell.intensity * 100.0)
}
Runic Tags:
#fast-functional-wards
#roc
#adapter