lisp/classic.lisp

26 lines
503 B
Common Lisp
Raw Normal View History

2024-12-16 14:34:52 -05:00
(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)))
))