module Graphics.QML.DataModel.Internal.Generic.Set where
import Graphics.QML.DataModel.Internal.FFI
import Graphics.QML.DataModel.Internal.Generic.Count
import Data.Proxy
import GHC.Generics
class SetupColumns t where
setupColumns :: HmDelegateHandle -> proxy t -> IO ()
default setupColumns
:: ( Generic t, GSetupColumns (Rep t) )
=> HmDelegateHandle
-> proxy t
-> IO ()
setupColumns d _ = gSetupColumns d p
where p :: Proxy (Rep t) = Proxy
class GSetupColumns f where
gSetupColumns :: HmDelegateHandle -> proxy f -> IO ()
class GSetupColumnIx f where
gSetupColumnIx :: HmDelegateHandle -> Int -> proxy f -> IO ()
instance GSetupColumns f => GSetupColumns (M1 D t f) where
gSetupColumns h _ = gSetupColumns h p
where p :: Proxy f = Proxy
instance GSetupColumnIx f => GSetupColumns (M1 C t f) where
gSetupColumns h _ = gSetupColumnIx h 0 p
where p :: Proxy f = Proxy
instance ( GCountFields a
, GCountFields b
, GSetupColumnIx a
, GSetupColumnIx b
) => GSetupColumnIx (a :*: b) where
gSetupColumnIx h ix _ = do
gSetupColumnIx h ix a
gSetupColumnIx h (ix + gCountFields a) b
where a :: Proxy a = Proxy
b :: Proxy b = Proxy
instance Selector t => GSetupColumnIx (M1 S t f) where
gSetupColumnIx h ix _ = addHaskellModelRole h ix $ selName u
where u :: M1 S t f _ = undefined