From e650a80856edc1d1df1f163c3f84082455717fa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 18 Mar 2019 18:43:51 +0100 Subject: Compleately redid file structure. --- monad/monoid.scm | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 monad/monoid.scm (limited to 'monad/monoid.scm') diff --git a/monad/monoid.scm b/monad/monoid.scm new file mode 100644 index 0000000..4b10a72 --- /dev/null +++ b/monad/monoid.scm @@ -0,0 +1,26 @@ +;;; ??? +(define-module (monad monoid) + #:use-module (oop goops) + #:use-module (srfi srfi-1) + #:export (null mappend <>)) + +(define-generic null) +(define-generic mappend) + +(define (<> . args) + (fold mappend (null (car args)) (reverse args))) + +;;; Lists + +(define-method (mappend (a ) (b )) + (append a b)) +(define-method (mappend (a ) (b )) a) +(define-method (mappend (a ) (b )) b) +(define-method (mappend (a ) (b )) '()) +(define-method (null (a )) '()) +(define-method (null (a )) '()) + +;;; Strings +(define-method (mappend (a ) (b )) + (string-append a b)) +(define-method (null (a )) "") -- cgit v1.2.3