Re: Lift and bind

2010-01-12 Thread Steven E. Harris
jim  writes:

> You know, I think you're right. I would refer you to part 2 of
> Konrad's monad tutorial, but the link is broken. Check google's cache,
> if you want to read an explanation immediately.

That's how I've been reading his tutorials, as WordPress isn't
delivering the pages.

In "A monad tutorial for Clojure programmers (part 2)", he writes:

,
| Perhaps the most frequently used generic monad function is m-lift. It
| converts a function of n standard value arguments into a function of n
| monadic expressions that returns a monadic expression.
`

I take it "monadic expression" is a synonym for "monadic value".

> I'll have to go change that. Thanks for pointing it out and sorry for
> any confusion.

Well, having caught a conflict, it caused me to look deeper several
times until I felt confident enough to ask. Learning was my goal, and
your essays have been tremendously helpful.

-- 
Steven E. Harris

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Lift and bind (was: Understanding the continuation monad's bind operator)

2010-01-11 Thread jim
You know, I think you're right. I would refer you to part 2 of
Konrad's monad tutorial, but the link is broken. Check google's cache,
if you want to read an explanation immediately.

I'll have to go change that. Thanks for pointing it out and sorry for
any confusion.

Jim

Steven E. Harris wrote:
> Konrad Hinsen  writes:
>
> > For a function of a single argument, m-lift and m-fmap are equivalent.
>
> In Jim Duey's essay Higher Level Monads¹, he writes the following on the
> lift operator:
>
> ,[ m-lift ]
> | If you have a function that you would like to turn into a monadic
> | function, that is a function that can be passed to m-bind, you use
> | m-lift.
> |
> | m-lift takes two parameters, a function to lift and the number of
> | arguments that function accepts. The argument count is the first
> | parameter and the function is second. The return value is a function
> | that can be passed to m-bind.
> `
>
> Isn't it the case, though, that a lifted function /can't/ be passed to
> bind, because it's not a monadic function? A lifted function takes
> monadic values as input, rather than a basic value.
>
> Is there some operator that converts a "normal" function
>
>   a -> b
>
> to a monadic function
>
>   a -> m b
>
> such that one could adapt a "normal" function for use in and among some
> other monadic functions (such as with m-chain)? I'm not sure such a
> translation is possible for all monads.
>
> I considered something like this
>
> ,
> | (defn as-monadic-fn [f]
> |   (fn [v]
> | (m-result (f v
> `
>
> but it looks too simple.
>
>
> Footnotes:
> ¹ http://intensivesystems.net/tutorials/monads_201.html
>
> --
> Steven E. Harris
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Lift and bind (was: Understanding the continuation monad's bind operator)

2010-01-12 Thread Graham Fawcett
Hi,

On Mon, Jan 11, 2010 at 8:44 PM, Steven E. Harris  wrote:
> Konrad Hinsen  writes:
>
>> For a function of a single argument, m-lift and m-fmap are equivalent.
>
> In Jim Duey's essay Higher Level Monads¹, he writes the following on the
> lift operator:
>
> ,[ m-lift ]
> | If you have a function that you would like to turn into a monadic
> | function, that is a function that can be passed to m-bind, you use
> | m-lift.
> |
> | m-lift takes two parameters, a function to lift and the number of
> | arguments that function accepts. The argument count is the first
> | parameter and the function is second. The return value is a function
> | that can be passed to m-bind.
> `
>
> Isn't it the case, though, that a lifted function /can't/ be passed to
> bind, because it's not a monadic function? A lifted function takes
> monadic values as input, rather than a basic value.
>
> Is there some operator that converts a "normal" function
>
>  a -> b
>
> to a monadic function
>
>  a -> m b
>
> such that one could adapt a "normal" function for use in and among some
> other monadic functions (such as with m-chain)? I'm not sure such a
> translation is possible for all monads.

I don't know Clojure monads, but in Haskell that operator would be
"(.) return", that is the partial application of the composition
function to the 'return' function:

Prelude> :t (.) return
(.) return :: (Monad m) => (a -> b) -> a -> m b

> I considered something like this
>
> ,
> | (defn as-monadic-fn [f]
> |   (fn [v]
> |     (m-result (f v

I'd say that looks right. It has the same meaning as:

(def as-monadic-fn (partial comp m-result))

...which is a transliteration of "(.) return" in Haskell.

Best,
Graham

> but it looks too simple.
>
>
> Footnotes:
> ¹ http://intensivesystems.net/tutorials/monads_201.html
>
> --
> Steven E. Harris
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en