-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
Description
Instances declared with StandaloneDeriving are not recognized by withStatic, and they don't get their static version defined. The following program does not compile (missing instance for (Static (Show D))).
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StaticPointers #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# Language TemplateHaskell #-}
import Control.Distributed.Closure
import Control.Distributed.Closure.TH
import Data.Typeable
data D = D
deriving (Typeable)
withStatic [d|
deriving instance Show D
|]
showC :: forall a. (Typeable a, Static (Show a)) => Closure a -> String
showC a = unclosure $ static (\Dict -> show)
`cap` (closureDict :: Closure (Dict (Show a)))
`cap` a
main :: IO ()
main = do
putStrLn $ showC $ static DNeither does withStatic work with derived instances
withStatic [d|
data D = D
deriving (Typeable, Show)
|]
-- Static (Show D) doesn't get definedAs a result, there is no way to auto-generate static versions of instances with default implementations.
Reactions are currently unavailable