{"action":"created","issue":{"url":"https://api.github.com/repos/osa1/hslua/issues/32","labels_url":"https://api.github.com/repos/osa1/hslua/issues/32/labels{/name}","comments_url":"https://api.github.com/repos/osa1/hslua/issues/32/comments","events_url":"https://api.github.com/repos/osa1/hslua/issues/32/events","html_url":"https://github.com/osa1/hslua/issues/32","id":97819237,"number":32,"title":"callfunc with string ","user":{"login":"ka3a4ok","id":890755,"avatar_url":"https://avatars.githubusercontent.com/u/890755?v=3","gravatar_id":"","url":"https://api.github.com/users/ka3a4ok","html_url":"https://github.com/ka3a4ok","followers_url":"https://api.github.com/users/ka3a4ok/followers","following_url":"https://api.github.com/users/ka3a4ok/following{/other_user}","gists_url":"https://api.github.com/users/ka3a4ok/gists{/gist_id}","starred_url":"https://api.github.com/users/ka3a4ok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ka3a4ok/subscriptions","organizations_url":"https://api.github.com/users/ka3a4ok/orgs","repos_url":"https://api.github.com/users/ka3a4ok/repos","events_url":"https://api.github.com/users/ka3a4ok/events{/privacy}","received_events_url":"https://api.github.com/users/ka3a4ok/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-28T22:55:18Z","updated_at":"2015-07-28T23:32:16Z","closed_at":null,"body":"This code doesn't compile\r\n\r\n```haskell\r\nLua.callfunc l \"print\" (Data.ByteString.Char8.pack \"Hello\")\r\n```\r\nError:\r\n```\r\n    No instance for (Lua.StackValue a0)\r\n      arising from a use of `Lua.callfunc'\r\n    The type variable `a0' is ambiguous\r\n    Note: there are several potential instances:\r\n      instance Lua.StackValue Lua.LuaInteger\r\n        -- Defined in `Scripting.Lua'\r\n      instance Lua.StackValue (GHC.Ptr.FunPtr Lua.LuaCFunction)\r\n        -- Defined in `Scripting.Lua'\r\n      instance Lua.StackValue (GHC.Ptr.Ptr a)\r\n        -- Defined in `Scripting.Lua'\r\n      ...plus 7 others\r\n```\r\n\r\nHow can I use callfunc with ByteStrings?\r\n"},"comment":{"url":"https://api.github.com/repos/osa1/hslua/issues/comments/125781506","html_url":"https://github.com/osa1/hslua/issues/32#issuecomment-125781506","issue_url":"https://api.github.com/repos/osa1/hslua/issues/32","id":125781506,"user":{"login":"osa1","id":448274,"avatar_url":"https://avatars.githubusercontent.com/u/448274?v=3","gravatar_id":"","url":"https://api.github.com/users/osa1","html_url":"https://github.com/osa1","followers_url":"https://api.github.com/users/osa1/followers","following_url":"https://api.github.com/users/osa1/following{/other_user}","gists_url":"https://api.github.com/users/osa1/gists{/gist_id}","starred_url":"https://api.github.com/users/osa1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/osa1/subscriptions","organizations_url":"https://api.github.com/users/osa1/orgs","repos_url":"https://api.github.com/users/osa1/repos","events_url":"https://api.github.com/users/osa1/events{/privacy}","received_events_url":"https://api.github.com/users/osa1/received_events","type":"User","site_admin":false},"created_at":"2015-07-28T23:32:16Z","updated_at":"2015-07-28T23:32:16Z","body":"It's not a ByteString issue -- GHC can't figure out the expected return value of the called function(`print`). It should be inferred from the call site, you may either annotate your expression with types or somehow refactor your code to allow GHC to infer that.\r\n\r\nAs an example, this won't work:\r\n\r\n```haskell\r\nmodule Main where\r\n\r\nimport Scripting.Lua\r\n\r\nmain = do\r\n  l <- newstate\r\n  openlibs l\r\n  -- this fails, because GHC can't infer return type:\r\n  callfunc l \"print\" (10 :: Int)\r\n  close l\r\n```\r\n\r\nIf I annotate the type or let GHC infer that somehow, it works:\r\n\r\n\r\n```haskell\r\nmain = do\r\n  l <- newstate\r\n  openlibs l\r\n  () <- callfunc l \"print\" (10 :: Int)\r\n  close l\r\n```\r\n\r\nor similarly, `callfunc l \"print\" (10 :: Int) :: IO ()` also works. In your case, you can do `callfunc l \"print\" (BC.pack \"blah\") :: IO ()`."}}