[Haskell-cafe] Type problem with simple takusen code (was: Trivial
database access in Haskell)
Seth Gordon
sethg at ropine.com
Tue Dec 12 10:41:10 EST 2006
Paul Moore wrote:
> db.hs:10:64:
> Couldn't match expected type `forall mark. DBM mark Session a'
> against inferred type `a1 b'
> In the second argument of `($)', namely
> `do r <- doQuery
> (sql "select username from all_users") query1Iteratee []
> liftIO $ (putStrLn $ (show r))'
> In the expression:
> (withSession (connect "USER" "PASSWORD" "DB"))
> $ (do r <- doQuery
> (sql "select username from all_users")
> query1Iteratee []
> liftIO $ (putStrLn $ (show r)))
> In the expression:
> do (withSession (connect "USER" "PASSWORD" "DB"))
> $ (do r <- doQuery
> (sql "select username from all_users")
> query1Iteratee []
> liftIO $ (putStrLn $ (show r)))
I had the same problem...
($) doesn't have the expected semantics with existential types (like
"forall mark. DBM mark Session a"). Some day I will be able to explain
why this is so, but in the meantime, if you replace "liftIO $ putStrLn $
show r" with "liftIO (putStrLn (show r))", it should work.
More information about the Haskell-Cafe
mailing list