{-# OPTIONS_GHC -XEmptyDataDecls -XScopedTypeVariables #-} -------------------------------------------------------------------- -- | -- Module : NET.System.Predicate -- Description : Interface to @System.Predicate@ -- Copyright : (c) Sigbjorn Finne, 2008 -- License : BSD3 -- -- Maintainer : Sigbjorn Finne -- Stability : provisional -- Portability : portable -- -- Bindings to the @System.Predicate@ generic delegate. -- -------------------------------------------------------------------- module NET.System.Predicate (module NET.System.Predicate, module NET.System.Predicate.Type ) where import NET import NET.System.Predicate.Type newPredicate :: (Arg ty, Type ty) => (ty -> Predicate ty a -> IO Bool) -> IO (Predicate ty a) newPredicate hPred = do let ts = tyName (tyFunArg hPred) obj <- newDelegator2 (toGenericTypeString "System.Predicate" ts) ( \ a b -> do (v,_) <- fromArgs [a] th <- mkObject b hPred v th) return (castObjTy obj) invokePredicate :: (Arg ty, Type ty) => ty -> Predicate obj ty -> IO () invokePredicate arg obj = obj # invoke "Invoke" arg