raw-feldspar-0.3: Resource-Aware Feldspar

Feldspar.Run.Marshal

Synopsis

# Documentation

newtype Parser a Source #

Constructors

 Parser FieldsrunParser :: String -> (a, String)
Instances
 Source # Instance detailsDefined in Feldspar.Run.Marshal Methods(>>=) :: Parser a -> (a -> Parser b) -> Parser b #(>>) :: Parser a -> Parser b -> Parser b #return :: a -> Parser a #fail :: String -> Parser a # Source # Instance detailsDefined in Feldspar.Run.Marshal Methodsfmap :: (a -> b) -> Parser a -> Parser b #(<$) :: a -> Parser b -> Parser a # Source # Instance detailsDefined in Feldspar.Run.Marshal Methodspure :: a -> Parser a #(<*>) :: Parser (a -> b) -> Parser a -> Parser b #liftA2 :: (a -> b -> c) -> Parser a -> Parser b -> Parser c #(*>) :: Parser a -> Parser b -> Parser b #(<*) :: Parser a -> Parser b -> Parser a # readParser :: forall a. (Read a, Typeable a) => Parser a Source # parse :: Parser a -> String -> a Source # class MarshalHaskell a where Source # Serialization/deserialization of Haskell values The following property must hold for all a: a = parse toHaskell (fromHaskell a) Prelude.== a Minimal complete definition Nothing Methods fromHaskell :: a -> String Source # Serialize a Haskell value fromHaskell :: Show a => a -> String Source # Serialize a Haskell value Deserialize a Haskell value toHaskell :: (Read a, Typeable a) => Parser a Source # Deserialize a Haskell value Instances  Source # Instance detailsDefined in Feldspar.Run.Marshal Methods Source # Instance detailsDefined in Feldspar.Run.Marshal Methods Source # Instance detailsDefined in Feldspar.Run.Marshal Methods Source # Instance detailsDefined in Feldspar.Run.Marshal Methods Source # Instance detailsDefined in Feldspar.Run.Marshal Methods Source # Instance detailsDefined in Feldspar.Run.Marshal Methods Source # Instance detailsDefined in Feldspar.Run.Marshal Methods Source # Instance detailsDefined in Feldspar.Run.Marshal Methods Source # Instance detailsDefined in Feldspar.Run.Marshal Methods Source # Instance detailsDefined in Feldspar.Run.Marshal Methods Source # Instance detailsDefined in Feldspar.Run.Marshal Methods MarshalHaskell a => MarshalHaskell [a] Source # Instance detailsDefined in Feldspar.Run.Marshal MethodsfromHaskell :: [a] -> String Source # Source # Instance detailsDefined in Feldspar.Run.Marshal Methods Source # Instance detailsDefined in Feldspar.Run.Marshal Methods (MarshalHaskell a, MarshalHaskell b) => MarshalHaskell (a, b) Source # Instance detailsDefined in Feldspar.Run.Marshal MethodsfromHaskell :: (a, b) -> String Source #toHaskell :: Parser (a, b) Source # (MarshalHaskell a, MarshalHaskell b, MarshalHaskell c) => MarshalHaskell (a, b, c) Source # Instance detailsDefined in Feldspar.Run.Marshal MethodsfromHaskell :: (a, b, c) -> String Source #toHaskell :: Parser (a, b, c) Source # (MarshalHaskell a, MarshalHaskell b, MarshalHaskell c, MarshalHaskell d) => MarshalHaskell (a, b, c, d) Source # Instance detailsDefined in Feldspar.Run.Marshal MethodsfromHaskell :: (a, b, c, d) -> String Source #toHaskell :: Parser (a, b, c, d) Source # class MarshalHaskell (HaskellRep a) => MarshalFeld a where Source # Serialization/deserialization of Feldspar values Minimal complete definition Nothing Associated Types type HaskellRep a Source # The Haskell representation of a Feldspar value Methods fwrite :: Handle -> a -> Run () Source # Serialize a Feldspar value to a handle fwrite :: (PrimType b, Formattable b, a ~ Data b) => Handle -> a -> Run () Source # Serialize a Feldspar value to a handle Deserialize a Feldspar value from a handle fread :: (PrimType b, Formattable b, a ~ Data b) => Handle -> Run a Source # Deserialize a Feldspar value from a handle Instances  Source # Instance detailsDefined in Feldspar.Run.Marshal Associated Typestype HaskellRep (Data Double) :: Type Source # Methodsfwrite :: Handle -> Data Double -> Run () Source # Source # Instance detailsDefined in Feldspar.Run.Marshal Associated Typestype HaskellRep (Data Float) :: Type Source # Methodsfwrite :: Handle -> Data Float -> Run () Source # Source # Instance detailsDefined in Feldspar.Run.Marshal Associated Typestype HaskellRep (Data Int8) :: Type Source # Methodsfwrite :: Handle -> Data Int8 -> Run () Source # Source # Instance detailsDefined in Feldspar.Run.Marshal Associated Typestype HaskellRep (Data Int16) :: Type Source # Methodsfwrite :: Handle -> Data Int16 -> Run () Source # Source # Instance detailsDefined in Feldspar.Run.Marshal Associated Typestype HaskellRep (Data Int32) :: Type Source # Methodsfwrite :: Handle -> Data Int32 -> Run () Source # Source # Instance detailsDefined in Feldspar.Run.Marshal Associated Typestype HaskellRep (Data Int64) :: Type Source # Methodsfwrite :: Handle -> Data Int64 -> Run () Source # Source # Instance detailsDefined in Feldspar.Run.Marshal Associated Typestype HaskellRep (Data Word8) :: Type Source # Methodsfwrite :: Handle -> Data Word8 -> Run () Source # Source # Instance detailsDefined in Feldspar.Run.Marshal Associated Typestype HaskellRep (Data Word16) :: Type Source # Methodsfwrite :: Handle -> Data Word16 -> Run () Source # Source # Instance detailsDefined in Feldspar.Run.Marshal Associated Typestype HaskellRep (Data Word32) :: Type Source # Methodsfwrite :: Handle -> Data Word32 -> Run () Source # Source # Instance detailsDefined in Feldspar.Run.Marshal Associated Typestype HaskellRep (Data Word64) :: Type Source # Methodsfwrite :: Handle -> Data Word64 -> Run () Source # Source # Instance detailsDefined in Feldspar.Run.Marshal Associated Typestype HaskellRep (Data (Complex Double)) :: Type Source # Methodsfwrite :: Handle -> Data (Complex Double) -> Run () Source # Source # Instance detailsDefined in Feldspar.Run.Marshal Associated Typestype HaskellRep (Data (Complex Float)) :: Type Source # Methodsfwrite :: Handle -> Data (Complex Float) -> Run () Source # (MarshalHaskell (Internal a), MarshalFeld a, Syntax a) => MarshalFeld (IArr a) Source # Instance detailsDefined in Feldspar.Run.Marshal Associated Typestype HaskellRep (IArr a) :: Type Source # Methodsfwrite :: Handle -> IArr a -> Run () Source #fread :: Handle -> Run (IArr a) Source # (MarshalHaskell (Internal a), MarshalFeld a, Syntax a) => MarshalFeld (Arr a) Source # Instance detailsDefined in Feldspar.Run.Marshal Associated Typestype HaskellRep (Arr a) :: Type Source # Methodsfwrite :: Handle -> Arr a -> Run () Source #fread :: Handle -> Run (Arr a) Source # MarshalFeld a => MarshalFeld (Nest a) Source # Note that HaskellRep (Nest a) = (Length, Length, HaskellRep a) rather than [HaskellRep a]. This means that e.g. Nest (Nest (Fin (IArr a))) is represented as (Length,Length,(Length,Length,(Length,[...]))) instead of the more convenient [[...]]. Instance detailsDefined in Feldspar.Data.Array Associated Typestype HaskellRep (Nest a) :: Type Source # Methodsfwrite :: Handle -> Nest a -> Run () Source #fread :: Handle -> Run (Nest a) Source # (Syntax a, MarshalHaskell (Internal a), MarshalFeld a) => MarshalFeld (Pull2 a) Source # Instance detailsDefined in Feldspar.Data.Vector Associated Typestype HaskellRep (Pull2 a) :: Type Source # Methodsfwrite :: Handle -> Pull2 a -> Run () Source #fread :: Handle -> Run (Pull2 a) Source # (Syntax a, MarshalHaskell (Internal a), MarshalFeld a) => MarshalFeld (Pull a) Source # Instance detailsDefined in Feldspar.Data.Vector Associated Typestype HaskellRep (Pull a) :: Type Source # Methodsfwrite :: Handle -> Pull a -> Run () Source #fread :: Handle -> Run (Pull a) Source # (MarshalFeld a, MarshalFeld b) => MarshalFeld (a, b) Source # Instance detailsDefined in Feldspar.Run.Marshal Associated Typestype HaskellRep (a, b) :: Type Source # Methodsfwrite :: Handle -> (a, b) -> Run () Source #fread :: Handle -> Run (a, b) Source # (Syntax a, MarshalHaskell (Internal a), MarshalFeld a, m ~ Run) => MarshalFeld (Seq m a) Source # Instance detailsDefined in Feldspar.Data.Vector Associated Typestype HaskellRep (Seq m a) :: Type Source # Methodsfwrite :: Handle -> Seq m a -> Run () Source #fread :: Handle -> Run (Seq m a) Source # (Syntax a, MarshalHaskell (Internal a), MarshalFeld a, m ~ Run) => MarshalFeld (Push2 m a) Source # Instance detailsDefined in Feldspar.Data.Vector Associated Typestype HaskellRep (Push2 m a) :: Type Source # Methodsfwrite :: Handle -> Push2 m a -> Run () Source #fread :: Handle -> Run (Push2 m a) Source # (Syntax a, MarshalHaskell (Internal a), MarshalFeld a, m ~ Run) => MarshalFeld (Push m a) Source # Instance detailsDefined in Feldspar.Data.Vector Associated Typestype HaskellRep (Push m a) :: Type Source # Methodsfwrite :: Handle -> Push m a -> Run () Source #fread :: Handle -> Run (Push m a) Source # (MarshalFeld a, MarshalFeld b, MarshalFeld c) => MarshalFeld (a, b, c) Source # Instance detailsDefined in Feldspar.Run.Marshal Associated Typestype HaskellRep (a, b, c) :: Type Source # Methodsfwrite :: Handle -> (a, b, c) -> Run () Source #fread :: Handle -> Run (a, b, c) Source # (MarshalFeld a, MarshalFeld b, MarshalFeld c, MarshalFeld d) => MarshalFeld (a, b, c, d) Source # Instance detailsDefined in Feldspar.Run.Marshal Associated Typestype HaskellRep (a, b, c, d) :: Type Source # Methodsfwrite :: Handle -> (a, b, c, d) -> Run () Source #fread :: Handle -> Run (a, b, c, d) Source # writeStd :: MarshalFeld a => a -> Run () Source # Write a value to stdout readStd :: MarshalFeld a => Run a Source # Read a value from stdin connectStdIO :: (MarshalFeld a, MarshalFeld b) => (a -> Run b) -> Run () Source # Connect a Feldspar function between serializable types to stdin/stdout streamStdIO :: (MarshalFeld a, MarshalFeld b) => (a -> Run b) -> Run () Source # Connect a Feldspar function between serializable types to stdin/stdout. The inputoutput will be in the form of a list as recognized by toHaskell fromHaskell (i.e. the length followed by the elements in sequence). The function will be mapped over the input list in a lazy manner. Arguments  :: (MarshalFeld a, MarshalFeld b) => CompilerOpts -> ExternalCompilerOpts -> (a -> Run b) Function to compile -> ((HaskellRep a -> IO (HaskellRep b)) -> IO c) Function that has access to the compiled executable as a function -> IO c A version of marshalled that takes ExternalCompilerOpts as additional argument Arguments  :: (MarshalFeld a, MarshalFeld b) => (a -> Run b) Function to compile -> ((HaskellRep a -> IO (HaskellRep b)) -> IO c) Function that has access to the compiled executable as a function -> IO c Compile a function and make it available as an IO function. Note that compilation only happens once, even if the function is used many times in the body. For example, given the following Feldspar function: sumArr :: DIArr Int32 -> Run (Data Int32) sumArr arr = do r <- initRef 0 for (0,1,Excl$ length arr) $\i -> modifyRef r (+ arrIx arr i) unsafeFreezeRef r marshalled can be used as follows: *Main> marshalled sumArr$ \f -> (f [3,4,5] >>= print) >> (f [6,7,8,9] >>= print)

Arguments

 :: (MarshalFeld a, MarshalFeld b) => CompilerOpts -> ExternalCompilerOpts -> (a -> Run b) Function to compile -> (([HaskellRep a] -> IO [HaskellRep b]) -> IO c) Function that has access to the compiled executable as a function -> IO c

A version of marshalledStream that takes ExternalCompilerOpts as additional argument

Arguments

 :: (MarshalFeld a, MarshalFeld b) => (a -> Run b) Function to compile -> (([HaskellRep a] -> IO [HaskellRep b]) -> IO c) Function that has access to the compiled executable as a function -> IO c

Compile a function and make it available as an IO function. The compiled function will be applied repeatedly over the list of inputs producing a list of outputs. Note that compilation only happens once, even if the function is used many times in the body.