Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. My Continuation doesn't typecheck (martin) ---------------------------------------------------------------------- Message: 1 Date: Sat, 6 Aug 2016 10:03:17 +0200 From: martin <martin.drautzb...@web.de> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: [Haskell-beginners] My Continuation doesn't typecheck Message-ID: <57a599c5.2030...@web.de> Content-Type: text/plain; charset=utf-8 Hello all, in order to gain some intuition about continuations, I tried the following: -- two functions accepting a continuation f1 :: Int -> (Integer->r) -> r f1 a c = c $ fromIntegral (a+1) f2 :: Integer -> (String -> r) -> r f2 b c = c $ show b -- combine the two functions into a single one run1 :: Int -> (String -> r) -> r run1 a = f1 a f2 -- *Main> run1 9 id -- "10" So far so good. Then I tried to write a general combinator, which does not have f1 and f2 hardcoded: combine a f g = f a g -- This also works -- *Main> combine 9 f1 f2 id -- "10" What confuses me is the the type of combine. I thought it should be combine :: Int -> (Int -> (Integer->r) -> r) -> -- f1 (Integer -> (String -> r) -> r) -> -- f2 ((String -> r) -> r) but that doesn't typecheck: Couldn't match expected type ‘(String -> r) -> r’ with actual type ‘r’ Can you tell me where I am making a mistake? ------------------------------ Subject: Digest Footer _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 98, Issue 5 ****************************************