| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Language.Futhark.Interpreter.FFI.ServerM
Synopsis
- type TypeName = Text
- data ValueRef
- data Server
- startServer :: ServerCfg -> IO Server
- newServer :: Server -> IO Server
- stopServer :: Server -> IO (Maybe Text)
- data ServerM a
- runServerM :: Server -> ServerM a -> IO (Either String a)
- gc :: ServerM ()
- release :: [(ValueRef, VarName)] -> ServerM [VarName]
- call :: Name -> [ValueRef] -> ServerM ValueRef
- inputs :: Name -> ServerM [TypeName]
- output :: Name -> ServerM TypeName
- kind :: TypeName -> ServerM Kind
- vtype :: ValueRef -> ServerM TypeName
- getPrim :: ValueRef -> ServerM PrimValue
- putPrim :: PrimValue -> ServerM ValueRef
- putData :: Value -> ServerM ValueRef
- getData :: ValueRef -> ServerM (Maybe Value)
- rank :: TypeName -> ServerM Int
- elemType :: TypeName -> ServerM TypeName
- mkArray :: TypeName -> [Int64] -> [ValueRef] -> ServerM ValueRef
- shape :: ValueRef -> ServerM [Int64]
- index :: [Int64] -> ValueRef -> ServerM ValueRef
- fieldOrder :: TypeName -> ServerM [(Name, TypeName)]
- mkRecord :: TypeName -> Map Name ValueRef -> ServerM ValueRef
- project :: ValueRef -> Name -> ServerM ValueRef
- unzipArray :: ValueRef -> Int -> ServerM [ValueRef]
- variants :: TypeName -> ServerM (Map Name [TypeName])
- mkSum :: TypeName -> Name -> [ValueRef] -> ServerM ValueRef
- destruct :: ValueRef -> ServerM (Name, [ValueRef])
- throwNothing :: MonadError String m => String -> Maybe a -> m a
Documentation
newServer :: Server -> IO Server Source #
Use an already-running server. Shutting it down remains the responsibility of whoever started it.
stopServer :: Server -> IO (Maybe Text) Source #
Shut down the server. Returns a message on termination failure.
Instances
| Applicative ServerM Source # | |
| Functor ServerM Source # | |
| Monad ServerM Source # | |
| MonadIO ServerM Source # | |
Defined in Language.Futhark.Interpreter.FFI.ServerM | |
| MonadError String ServerM Source # | |
Defined in Language.Futhark.Interpreter.FFI.ServerM Methods throwError :: String -> ServerM a # catchError :: ServerM a -> (String -> ServerM a) -> ServerM a # | |
release :: [(ValueRef, VarName)] -> ServerM [VarName] Source #
End the use of this Server. The variables of the given values are
adopted by the caller under the given names, and every other variable we
have created is freed, whether or not its ValueRef is still reachable.
Neither the Server nor any ValueRef may be used afterwards. A variable
may occur more than once, in which case it is adopted under the first of its
names. Returns the name of the variable of each value.
putData :: Value -> ServerM ValueRef Source #
Put an entire value on the server at once. This is only possible for values that can be represented in the Futhark data format (primitives and arrays of primitive).
getData :: ValueRef -> ServerM (Maybe Value) Source #
Retrieve an entire value from the server at once. This is only possible for values that can be represented in the Futhark data format (primitives and arrays of primitive).
fieldOrder :: TypeName -> ServerM [(Name, TypeName)] Source #
The fields of a record type, in the order the server uses.
unzipArray :: ValueRef -> Int -> ServerM [ValueRef] Source #
Split an array of records into one array per field, in fieldOrder. The
fields of an array cannot be projected one element at a time, and doing so
would anyway be impossible for an empty array.
throwNothing :: MonadError String m => String -> Maybe a -> m a Source #