Description
[Imported from JIRA. Reported by Niklas Hambuechen @[email protected]) as DP-67 on 2013-02-12 18:12:08]
Assume I write a function
f :: (ProcessId, ProcessId) -> Process ()
remotable ['f]
works fine.
Then I make
type WorkStealingSlaveProcess a = (ProcessId, ProcessId) -> Process a
slave :: WorkStealingSlaveProcess ()
Now remotable ['f]
fails, it says (my f
is called slave here):
SimpleLocalnet.hs:1:1: Splicing declarations
remotable ['slave]
======>
SimpleLocalnet.hs:37:1-18
slave__static :: Static (WorkStealingSlaveProcess ())
slave__static = Control.Distributed.Static.staticLabel "Main.slave"
__remoteTable :: RemoteTable -> RemoteTable
__remoteTable
= Control.Distributed.Static.registerStatic
"Main.slave" (Data.Rank1Dynamic.toDynamic slave)
SimpleLocalnet.hs:56:22-37: Splicing expression
mkClosure 'slave
======>
((closure
(slave__static
`Control.Distributed.Static.staticCompose`
(staticDecode slave__sdict)))
. Data.Binary.encode)
SimpleLocalnet.hs:56:22:
Not in scope: `slave__sdict'
In the result of the splice:
$(mkClosure 'slave)
To see what the splice expanded to, use -ddump-splices
In the expression: $(mkClosure 'slave)
In an equation for `slaveProcess':
slaveProcess = $(mkClosure 'slave)
It simply doesn't generate the f__sdict
function, which is because my type doesn't contain an arrow = see the following code from distributed-process (http://hackage.haskell.org/packages/archive/distributed-process/0.2.1.4/doc/html/src/Control-Distributed-Process-Internal-Closure-TH.html#remotable):
generateDefs :: Name -> Q ([Dec], [Q Exp])
generateDefs n = do
proc <- [t| Process |]
mType <- getType n
case mType of
Just (origName, typ) -> do
let (typVars, typ') = case typ of ForallT vars [] mono -> (vars, mono)
_ -> ([], typ)
-- The main "static" entry
(static, register) <- makeStatic origName typVars typ'
-- If n :: T1 -> T2, static serializable dictionary for T1
-- TODO: we should check if arg is an instance of Serializable, but we cannot
-- http://hackage.haskell.org/trac/ghc/ticket/7066
(sdict, registerSDict) <- case (typVars, typ') of
([], ArrowT `AppT` arg `AppT` _res) ->
makeDict (sdictName origName) arg
_ ->
return ([], [])
We are in the second case because there is no ArrowT inside - it is hidden inside my type declaration.
Probably the solution is to "unfold" type aliases first.
If not, there should at least be a warning about this, instead of just returning []
.