Have you heard of Djinn?<div><br></div><div><a href="https://hackage.haskell.org/package/djinn">https://hackage.haskell.org/package/djinn</a><br><div><br></div><div>If you punch in the signature of the combine function you're looking for (rewritten more usefully in Kleisli composition form):</div><div><br></div><div><font size="2"><span style="background-color:rgba(255,255,255,0)">        (Int -> (Integer->r) -> r) -> <br>        (Integer -> (String -> r) -> r) -><br>        (Int -> (String -> r) -> r)</span></font><br><br>you'll get your wish granted. Djinn will magically write combine for you.</div><div><br></div><div>It'll work even if you abstract over the concrete types of Int, Integer, String.</div><div><br></div><div>You can popover to the haskell IRC to try it out on the djinn bot there if installation is too much of a bother.</div><div><br></div><div>Best, Kim-Ee <br><br>On Saturday, August 6, 2016, martin <<a href="mailto:martin.drautzburg@web.de">martin.drautzburg@web.de</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello all,<br>
<br>
in order to gain some intuition about continuations, I tried the following:<br>
<br>
-- two functions accepting a continuation<br>
<br>
        f1 :: Int -> (Integer->r) -> r<br>
        f1 a c = c $ fromIntegral (a+1)<br>
<br>
        f2 :: Integer -> (String -> r) -> r<br>
        f2 b c = c $ show b<br>
<br>
        -- combine the two functions into a single one<br>
<br>
        run1 :: Int -> (String -> r) -> r<br>
        run1 a = f1 a f2<br>
<br>
<br>
        -- *Main> run1 9 id<br>
        -- "10"<br>
<br>
So far so good.<br>
<br>
<br>
Then I tried to write a general combinator, which does not have f1 and f2 hardcoded:<br>
<br>
        combine a f g = f a g<br>
<br>
        -- This also works<br>
<br>
        -- *Main> combine 9 f1 f2 id<br>
        -- "10"<br>
<br>
<br>
What confuses me is the the type of combine. I thought it should be<br>
<br>
        combine :: Int -><br>
        (Int -> (Integer->r) -> r) ->        -- f1<br>
        (Integer -> (String -> r) -> r) ->   -- f2<br>
        ((String -> r) -> r)<br>
<br>
<br>
but that doesn't typecheck:<br>
<br>
        Couldn't match expected type ‘(String -> r) -> r’<br>
        with actual type ‘r’<br>
<br>
<br>
Can you tell me where I am making a mistake?<br>
<br>
______________________________<wbr>_________________<br>
Beginners mailing list<br>
<a href="javascript:;" onclick="_e(event, 'cvml', 'Beginners@haskell.org')">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/beginners</a><br>
</blockquote></div></div><br><br>-- <br>-- Kim-Ee<br>