Hi,

On Mon, Jan 11, 2010 at 8:44 PM, Steven E. Harris <s...@panix.com> wrote:
> Konrad Hinsen <konrad.hin...@fastmail.net> 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

Reply via email to