strange type mismatch when trying to use takusen

I have a simple test program for takusen and PostgreSQL:
import Database.Enumerator import Database.PostgreSQL.Enumerator import Control.Monad.Trans
gazdbSession dbname = connect [CAdbname dbname]
resultCollector :: (Monad m) => String -> IterAct m [String] resultCollector str accum = result' (str:accum)
main = do withSession (connect [CAdbname "template1"]) $ main'
main' = do r <- doQuery (sql "select 'fred'") resultCollector [] liftIO $ putStrLn $ show r
But it won't compile: [1 of 1] Compiling Main ( takusen-test.hs, takusen-test.o ) takusen-test.hs:11:57: Couldn't match expected type `forall mark. DBM mark Session a' against inferred type `DBM mark sess ()' In the second argument of `($)', namely `main'' In the expression: (withSession (connect [CAdbname "template1"])) $ main' In the expression: do (withSession (connect [CAdbname "template1"])) $ main' Adding an explicit "main' :: DBM mark Session ()" type signature doesn't change the error message. The takusen source that I'm using was updated from darcs on November 14 and compiled with ghc 6.6.

On 11/23/06, Seth Gordon
takusen-test.hs:11:57: Couldn't match expected type `forall mark. DBM mark Session a' against inferred type `DBM mark sess ()' In the second argument of `($)', namely `main'' In the expression: (withSession (connect [CAdbname "template1"])) $ main' In the expression: do (withSession (connect [CAdbname "template1"])) $ main'
Ah, the dreaded $ with existential types problem. $ is not quite
equivalent to application -- the type checker does something funny
with forall types. Just take out the $ and you'll be fine.
--
Taral

Taral wrote:
Ah, the dreaded $ with existential types problem. $ is not quite equivalent to application -- the type checker does something funny with forall types. Just take out the $ and you'll be fine.
Is this a ghc bug, or some subtlety of the type system that I don't understand?

It's not a bug. It's what the type of ($) forces. On Nov 24, 2006, at 12:37 , Seth Gordon wrote:
Taral wrote:
Ah, the dreaded $ with existential types problem. $ is not quite equivalent to application -- the type checker does something funny with forall types. Just take out the $ and you'll be fine.
Is this a ghc bug, or some subtlety of the type system that I don't understand? _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (3)
-
Lennart Augustsson
-
Seth Gordon
-
Taral