Skip to content

[DP-67] remotable TH fails on type synonyms #226

Open

Description

@qnikst

[Imported from JIRA. Reported by Niklas Hambuechen @mail@nh2.me) 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 [].

Activity

  1. changed the title [-]remotable TH fails on type synonyms[/-] [+][DP-67] remotable TH fails on type synonyms[/+] on Jun 18, 2015
  2. linked a pull request that will close this issueLean into static pointers #493on Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions