Question regarding implicit parameters... The GHC manual says:

"Dynamic binding constraints behave just like other type class constraints in that they are automatically propagated."

But the following code produces an error:

---------------------------------------------------------------------------------------------------------

main = do
var <- newIORef (0::Int)
let ?global_counter = var in f


f = do
a <- get_unique
putStr (showInt a "\n")
b <- get_unique
putStr (showInt b "\n")
c <- get_unique
putStr (showInt c "\n")


get_unique :: (?global_counter :: IORef Int) => IO Int
get_unique = readIORef ?global_counter

----------------------------------------------------------------------------------------------------------

If "(?global_counter :: IORef Int)" were a class constraint the type signature
for 'f' could be derived automatically... but we get:


   Unbound implicit parameter (?global_counter::IORef a)
   arising from use of `get_unique' at Test.hs:17:13-22

Is this a bug? Is there some reason why this is not possible? (and if it is not possible
shouldn't the documentation be changed to reflect this)...


   Keean.

_______________________________________________
Glasgow-haskell-users mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to