{-|
Module      : Graphics.QML.Transient.Marshal
License     : BSD3
Maintainer  : marcin.jan.mrotek@gmail.com
Stability   : experimental

Break up Haskell data types into arguments of QML signals and methods.
-}

{-# LANGUAGE 
    ExplicitForAll 
  , FlexibleContexts
  , ScopedTypeVariables
  #-}

module Graphics.QML.Transient.Marshal 
  ( marshalArgs
  , GMarshalArgs
  ) where

import Graphics.QML.Transient.Internal.Marshal

import Data.Proxy
import GHC.Generics

marshalArgs 
  :: forall t x
   . ( Generic t
     , GMarshalArgs (Rep t)
     )
  => (t -> IO x) 
  -> MarshalArgs (Rep t) (IO x) 
-- ^Cannot be made into a type class because of the type family.
marshalArgs action = gMarshalArgs proxy $ action . to
  where proxy :: Proxy (Rep t) = Proxy

