https://github.com/fredokun/defvariant.git
git clone 'https://github.com/fredokun/defvariant.git'
(ql:quickload :defvariant)
Variants for Common Lisp (for ML nostalgics ?)
(defpackage :try-defvariant
(:use :cl :defvariant))
(in-package :try-defvariant)
(defvariant btree
(leaf)
(node val left right))
=> MATCH-BTREE
(let ((my-tree
(make-btree-node :val 42
:left (make-btree-leaf)
:right (make-btree-leaf))))
(match-btree my-tree
(leaf _ "leaf !")
(node (v _ _) v)))
=> 42
—-
See. defvariant.md
for the whole story.