Skip to content

silasfox/guile-monads

Repository files navigation

README for Monads

-*- mode: org; coding: utf-8; -*-

guile-monads is a monads library for guile scheme.

Installation:

With guix:

guix package -f guix.scm

Usage:

(use-modules (monads))

(with-m m-seq
	  i <- '(1 2 3)
	  j <- '(2 4 6)
	  (return (list i j)))

; => ((1 2) (1 4) (1 6) (2 2) (2 4) (2 6) (3 2) (3 4) (3 6))
(use-modules (monads))

(reify m-seq (list (reflect-seq '(1 2 3))
                   (reflect-seq '(2 4 6))))

; => ((1 2) (1 4) (1 6) (2 2) (2 4) (2 6) (3 2) (3 4) (3 6))  

Implemented monads are: Identity (m-id), Sequence/List (m-seq), State (m-state), Maybe (m-maybe), Continuation (m-cont) and Writer (m-writer).