lisp/classic.lisp
2024-12-16 14:34:52 -05:00

26 lines
503 B
Common Lisp

(load "utils.lisp")
(defparameter example
'(
(class (Monoid a)
(mzero a)
(mplus (-> a a a)))
(instance (Monoid String)
(mzero "")
(mplus (lambda (a b) (native (concatenate 'string a b)))))
(def + (-> Number Number Number)
(lambda (a b) (native (+ a b))))
(instance (Monoid Number)
(mzero 0)
(mplus +))
(def msum (=> (Monoid a) (-> (List a) a))
(lambda (xs)
(List.iter xs
mzero
mplus)))
))