From: Ian Price <ianprice90@googlemail.com>
To: ludo@gnu.org (Ludovic Courtès)
Cc: guile-user@gnu.org
Subject: Re: prompts: any example ?
Date: Thu, 08 Mar 2012 18:27:15 +0000 [thread overview]
Message-ID: <87wr6vx81o.fsf@Kagami.home> (raw)
In-Reply-To: <871up4zi51.fsf@Kagami.home> (Ian Price's message of "Wed, 07 Mar 2012 12:54:02 +0000")
Ian Price <ianprice90@googlemail.com> writes:
> The trick comes from, I think, Filinski's "Representing Monads",
> although it has been quite a while since I've read it. Instead of monads
> being represented by the usual 'bind' and 'unit' functions, or the
> (categorical?) definition of 'unit', 'fmap', 'join', they are instead
> represented by two operators 'reflect' and 'reify'.
>
> reify : (() -> a) -> m a
> reflect : m a -> a
>
> reify takes a function that returns a value, and returns a monadic
> value i.e. it lifts a pure expression to an effectful one.
>
> reflect takes a monadic value and returns the value. i.e. it lowers the
> effectful value into the pure layer.
One thing I forgot to mention is that there is a simple way to turn the
unit/bind representation into the reify/reflect representation, and you
see it at the top of the gist.
(define (reify thunk)
(reset (return (thunk))))
(define (reflect m)
(shift k (>>= m k)))
only I used tagged variants of shift/reset instead to allow mixing (as
already mentioned)
--
Ian Price
"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"
next prev parent reply other threads:[~2012-03-08 18:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-27 21:32 prompts: any example ? Catonano
2012-03-03 8:08 ` Ian Price
2012-03-03 15:18 ` Ludovic Courtès
2012-03-07 12:54 ` Ian Price
2012-03-08 18:27 ` Ian Price [this message]
2016-08-22 12:51 ` Catonano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wr6vx81o.fsf@Kagami.home \
--to=ianprice90@googlemail.com \
--cc=guile-user@gnu.org \
--cc=ludo@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).