chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] [ANN] Monad Egg


From: Jörg F . Wittenberger
Subject: Re: [Chicken-users] [ANN] Monad Egg
Date: 15 Apr 2012 16:08:04 +0200

On Apr 13 2012, Daniel Leslie wrote:

(define-monad
 <complex-id>
 (lambda (r i) (values r i))
 (lambda (f r i) (f r i)))


Why not:

(define-monad <cid> (lambda (a) (values (car a) (cdr a)))
   (lambda (a f) (f (car a) (cdr a))))

That's how the <logger> monad example goes about things. The parameter list
itself is just compacted into a pair, and passed through the unit and bind
functions.

I suppose I could extend it to support a full parameter list... It's
certainly worth considering.

I'm pretty confused now.

A) About the parameter order.
B) the approach to multiple values.

Let's start with (B) for logic even though unimportant

(define-monad <cid> (lambda (a) (values (car a) (cdr a)))
   (lambda (a f) (f (car a) (cdr a))))

Confused I am because where the identity returns one
value it return now two.  Access however is as if it
had returned a list.

As for (A): The API-point of mine derives from the consideration,
what changes would be needed to support a full parameter list.
This lead me to see the "f" parameter as naturally in the first
position.  Not

(define-monad <id> (lambda (a) a)
   (lambda (a f) (f a)))

but

(define-monad <id> (lambda (a) a)
   (lambda (f a) (f a)))

I would prefer.  I feel it looks more natural when extended to

(define-monad <cid> (lambda (a b) (values a b))
   (lambda (f a b) (f a b)))

because the "f" is always in "operator position".

/Jerry
......



reply via email to

[Prev in Thread] Current Thread [Next in Thread]