[lisp-interface-library-devel] Fwd: Curating libraries

Drew Crampsie me at drewc.ca
Tue Oct 30 02:33:05 UTC 2012


forgot to cc the list, fwded!

---------- Forwarded message ----------
From: Drew Crampsie <me at drewc.ca>
Date: Mon, Oct 29, 2012 at 4:41 PM
Subject: Re: [lisp-interface-library-devel] Curating libraries
To: Faré <fahree at gmail.com>




On Mon, Oct 29, 2012 at 3:36 PM, Faré <fahree at gmail.com> wrote:

> On Tue, Oct 30, 2012 at 6:32 AM, Drew Crampsie <me at drewc.ca> wrote:
> > This is the call/cc that will/should be included in :interface/monad :
> >
> Yay for the continuation monad!
>
> I propose you create a ips-monad.asd system and put the code
> in a new monad/ directory.
>
> K, can do. In my local code, I have one package per file. And I plan on
keeping it that way...

 > (define-interface <monad> (<type>) ()
> >   (:singleton)
> >   (:generic result (<monad> value))
> >   (:generic bind (<monad>  monadic-value monadic-function)))
> >
> I would personally use :generic> to elide the <monad> argument,
> here and in all definitions you have where it applies.
>

Makes sense, it simply was not there when I did that :)

>
> >   ,@(when (string-equal (symbol-name symbol) "_")
> >   `((declare (ignorable ,symbol))))
> Shouldn't that be ignore instead?
>
> > ORG/IPS/MONAD/CONTINUATION>
> I would put everything in the MONAD package,
> or IPS-MONAD if you suspect there might be
> any useful non-IPS monad package.
>

can we say INTERFACE/MONAD ? that package name makes sense to me as it
relies on INTERFACE package and is a part of the new IPS thingie.

>
> > So, that is call/cc based on the cont monad, in IPS. w00t.
> >
> Re-w00t!
>
> > any questions/comments/etc are most welcome.
> >
> How do I combine several monads,
> say, non-determinism, continuation, error, state monads?
>

strangley enough, this is dealt with by monads themselves .

(interface:define-interface <transformer> (<monad>)
  ((inner-monad :accessor inner
:initarg :inner
:initarg inner
 :initform <identity>))
  (:singleton)
  (:parametric (&optional (inner <identity>))
     (make-interface :key-interface inner))
  (:generic inner (<transformer>))
  (:generic lift (<transformer> inner-monadic-value))
  (:method lift (inner-monadic-value)
   inner-monadic-value))

(defmethod result ((m <transformer>) value)
  (lift m (result (inner m) value)))

(defmethod bind ((m <transformer>) mv mf)
  (lift m (bind (inner m) mv mf)))

 and ...

(interface:define-interface <list-transformer>
    (<list> <transformer>)
  ()
  (:singleton)
  (:method* result ((m <list-transformer>) value)
    (call-next-method m
      (result (inner m) value))))

(defmethod lift ((m <list-transformer>) inner-mv)
  (list inner-mv))


(defmethod bind ((m <list-transformer>) mvs mf)
  (loop :for mv in mvs
     :append (bind (inner m) mv mf)))


The double (<list> <transformer>) superclasses is new, but besides that,
the <list-transformer> is pretty much copied straight from haskell.

How to combine the monads? that depends on which order you want them in,
but <foo-transformer> for every one that needs an 'inner' monad.

Does that make sense? There is no inheritance to combine the monads, but
rather <transformer>s (the code, not the robots in disguise).

So, say, (define-interface <foo> (<state-transformer>) (()
(:default-initargs :inner <error>))) or something like that, to combine the
state (toplevel) with the error.

or, heh ... (eval '(<state-transformer> :inner (<error-transformer> :inner
<continuation>)) if we do not need the class define at all etc.

Can tell more about it if required, and do not mind because it will all be
in my docs anyway :)

Cheers,
drewc


♯ƒ • François-René ÐVB Rideau •Reflection&Cybernethics•
> http://fare.tunes.org
> Few facts are more revealing than the direction people travel
> when they vote with their feet. — Don Boudreaux http://bit.ly/afZgx2
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/lisp-interface-library-devel/attachments/20121029/bf4f7b28/attachment.html>


More information about the lisp-interface-library-devel mailing list