{-# OPTIONS_GHC -XEmptyDataDecls -XScopedTypeVariables #-} module NET.System.Func (module NET.System.Func ) where import NET import NET.System.Func.Type as NET.System.Func newFunc :: (Arg tyArg, Type tyArg, Type tyRes, Result tyRes) => (tyArg -> Func a tyArg tyRes -> IO tyRes) -> IO (Func a tyArg tyRes) newFunc hFunc = do let ts = tyName (tyFunArg hFunc) ++ tyName (tyCtorParam (tyFunRes (tyFunRes hFunc))) -- print ts obj <- case length ts of 1 -> newDelegator1 (toGenericTypeString "System.Func" ts) (\ o1 -> do (v, _) <- fromArgs [] th <- mkObject o1 hFunc v th) 2 -> newDelegator2 (toGenericTypeString "System.Func" ts) ( \ o1 o2 -> do (v,_) <- fromArgs [o1] th <- mkObject o2 hFunc v th) 3 -> newDelegator3 (toGenericTypeString "System.Func" ts) ( \ o1 o2 o3 -> do (v,_) <- fromArgs [o1,o2] th <- mkObject o3 hFunc v th) return (castObjTy obj) invokeFunc :: (Arg ty, Type ty, Type res, Result res) => ty -> Func a ty res -> IO res invokeFunc arg obj = obj # invoke "Invoke" arg