On 19/02/14 07:28, Ścisław Dercz wrote: > Dnia 18 lutego 2014 19:27 "Thompson, David" <dthomps...@worcester.edu> > napisał(a): > >> On Tue, Feb 18, 2014 at 3:53 AM, Panicz Maciej Godek >> <godek.mac...@gmail.com> wrote: >>> Hi, >>> sorry that it took so long, but my friend Drcz wrote a clone of >>> Pandora game in Guile using my SLAYER framework. Due to some >>> difficulties of a technical nature, I only managed to set up the >>> website today, so now the screens are available here: >>> http://puszcza.gnu.org.ua/software/slayer/?page=screenshots >> >> Cool! Thanks for sharing. Care to explain a bit about the monoid >> code? I'm interested in monads as applied to games. >> >> - Dave >> > > Hi! > > Actually it's not "a clone of Pandora game", the game is called "pandora" > and it is "a chimera-alike". > The monoid... I wanted to write the mechanics in a purely functional style, > and the obvious choice was to describe it as a couple of world->world > transformations; these in turn form a monoid under the composition action > (and with identity map as unit). > That's all, unfortunately it does not have much to do with monads per se... > or does it? I'm an categorial ignorant!
Categories for the Working Mathematician states: “All told, a monad in X is just a monoid in the category of endofunctors of X, with product × replaced by composition of endofunctors and unit set by the identity endofunctor.”. There is tons of reading material about this if you want to look up the quote. Whether you can argue that it holds in Guile is another matter, especially considering that trying to reason about these things in a dynamically typed language is silly to begin with. You can try ;) The common way to make a monad from functions of type ‘a → b’ (that is a monad for (→ a) is to make η/return the constant function and to make μ/bind/>>= look like ‘f >>= k = λ r → k (f r) r’. I don't see this exercised anywhere in the source although again, I'm not looking too carefully. I hope that satisfies your question. > > Cheers, > d. > -- Mateusz K.