(1) what is the "more useful Kleisli composition" and what would be "less useful" ?

This type signature

         (Int -> (Integer->r) -> r) ->
         (Integer -> (String -> r) -> r) ->
         (Int -> (String -> r) -> r)

is the Cont monad instantiation of

(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c

See

http://hackage.haskell.org/package/base-4.9.0.0/docs/Control-Monad.html#v:-62--61--62-

Being more uniform, this signature is more useful than the one you had earlier worked with:

combine :: Int ->
        (Int -> (Integer->r) -> r) ->        -- f1
        (Integer -> (String -> r) -> r) ->   -- f2
        ((String -> r) -> r)


> Now my 'combine' function seems to be different from 'bind' (>>=). It also just too simple to be true.

You got Kleisli composition, although not monadic bind. That's still a win of sorts.

Best, Kim-Ee Yeoh

On Monday, August 8, 2016, martin <martin.drautzburg@web.de> wrote:
Am 08/07/2016 um 05:18 PM schrieb Kim-Ee Yeoh:
> Have you heard of Djinn?
>
> https://hackage.haskell.org/package/djinn
>
> If you punch in the signature of the combine function you're looking for (rewritten more usefully in Kleisli composition
> form):
>
>         (Int -> (Integer->r) -> r) ->
>         (Integer -> (String -> r) -> r) ->
>         (Int -> (String -> r) -> r)
>

Thanks for pointing out Djinn, but I want to understand. And there are a number of things I don't understand. Maybe you
can help me out:

(1) what is the "more useful Kleisli composition" and what would be "less useful" ?

(2) I was hoping my experiments would eventually make the Cont monad appear and I originally even named my combinator
'bind' instead of 'combine'. My hope was fueled by the observation that


        combine a f g = f a g

works with
        f substitued with f1 :: Int -> (Integer->r) -> r and
        g substitued with f2 :: Integer -> (String -> r) -> r

As a next step I would have wrapped (b->r) -> r in a newtype C r b and my functions f1 and f2  would have had the types

        f1 :: Int -> C r Integer
        f2 :: Integer -> C r String

Now my 'combine' function seems to be different from 'bind' (>>=). It also just too simple to be true.

Somwhere I am making a fundamental mistake, but I cannot quite see it.


_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


--
-- Kim-Ee