[Haskell-beginners] My Continuation doesn't typecheck

martin martin.drautzburg at web.de
Mon Aug 8 14:40:00 UTC 2016

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.

More information about the Beginners mailing list