define-instance supplies an implementation of a type class for a concrete
type or constrained type pattern.
Syntax
(define-instance (⟨class⟩ ⟨type⟩...)
⟨method⟩...)
;; ⟨method⟩ := ⟨define-form⟩
Semantics
- The instance head determines which class/type combination is being implemented.
- All required class methods must be implemented.
- Overlapping instances must all opt in with the
overlapattribute. Resolution requires a unique most-specific matching head.
Example
(define-instance (Eq Unit)
(define (== _ _) True))