-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Haskell client for Rserve -- -- This module allows you to issue R commands from Haskell to be executed -- via Rserve and get the results back in Haskell data types. @package rclient @version 0.1.0.0 -- | This module allows you to issue R commands from Haskell to be executed -- via Rserve and get the results back in Haskell data types. module Network.Rserve.Client data RConn RConn :: Handle -> String -> String -> String -> [String] -> RConn rcHandle :: RConn -> Handle rcRserveSig :: RConn -> String rcRserveVersion :: RConn -> String rcProtocol :: RConn -> String rcAttributes :: RConn -> [String] type Result = Either RserveError (Maybe RSEXP) type RserveError = String -- | The ResultUnpack instances are used to extract R data structures from -- the Result container. class ResultUnpack a unpack :: ResultUnpack a => Result -> Maybe a -- | Representations for the types transmitted on the Rserve protocol, -- refer to Rserve documentation for details data RSEXP RNULL :: RSEXP RInt :: Int -> RSEXP RDouble :: Double -> RSEXP RString :: String -> RSEXP RSym :: String -> RSEXP RBool :: Bool -> RSEXP RVector :: [RSEXP] -> RSEXP RClos :: Word32 -> RSEXP RListTag :: [(RSEXP, RSEXP)] -> RSEXP RArrayInt :: [Int] -> RSEXP RArrayDouble :: [Double] -> RSEXP RArrayString :: [String] -> RSEXP RArrayBool :: [Bool] -> RSEXP RArrayComplex :: [(Double, Double)] -> RSEXP RSEXPWithAttrib :: RSEXP -> RSEXP -> RSEXP RUnknown :: Word32 -> RSEXP -- | Connect to Rserve server connect :: String -> Int -> IO RConn -- | evaluate an R expression eval :: RConn -> String -> IO Result -- | evaluate an R expression, discarding any result voidEval :: RConn -> String -> IO () -- | login to Rserve, not normally required, for authenticated sessions -- only login :: RConn -> String -> String -> IO Result -- | shutdown the Rserve server shutdown :: RConn -> IO () -- | open a file openFile :: RConn -> String -> IO Result -- | create a file createFile :: RConn -> String -> IO Result -- | close a file closeFile :: RConn -> String -> IO Result -- | remove a file removeFile :: RConn -> String -> IO Result -- | write content to a file accessible to the Rserve session writeFile :: RConn -> ByteString -> IO Result -- | assign a RSEXP value to a symbol assign :: RConn -> String -> RSEXP -> IO Result -- | unpack a Result containing an RArrayInt unpackRArrayInt :: Result -> Maybe [Int] -- | unpack a Result containing an RArrayBool unpackRArrayBool :: Result -> Maybe [Bool] -- | unpack a Result containing an RArrayDouble unpackRArrayDouble :: Result -> Maybe [Double] -- | unpack a Result containing an RArrayComplex unpackRArrayComplex :: Result -> Maybe [(Double, Double)] -- | unpack a Result containing an RArrayString unpackRArrayString :: Result -> Maybe [String] -- | unpack a Result containing an RInt unpackRInt :: Result -> Maybe Int -- | unpack a Result containing an RBool unpackRBool :: Result -> Maybe Bool -- | unpack a Result containing an RDouble unpackRDouble :: Result -> Maybe Double -- | unpack a Result containing an RString unpackRString :: Result -> Maybe String -- | unpack a Result containing an RSym unpackRSym :: Result -> Maybe String -- | unpack a Result containing an RVector unpackRVector :: Result -> Maybe [RSEXP] -- | unpack a Result containing an RListTag unpackRListTag :: Result -> Maybe [(RSEXP, RSEXP)] -- | unpack a Result containing an RSEXPWithAttrib unpackRSEXPWithAttrib :: Result -> Maybe (RSEXP, RSEXP) -- | Read-evaluate-print-loop for interacting with Rserve session. in ghci, -- load this module and run this command to test and play with Rserve -- this is useful to check the actual types returned by Rserve, e.g. -- -- $ ghci -- -- Prelude>:m Network.Rserve.Client -- -- Prelude Network.Rserve.Client> rRepl -- -- >c(1,2,3) -- -- Just (RArrayDouble [1.0,2.0,3.0]) -- -- >summary(rnorm(100)) -- -- Just (RSEXPWithAttrib (RListTag [(RArrayString ["Min.","1st -- Qu.","Median","Mean","3rd Qu.","Max."],RSym "names"),(RArrayString -- ["table"],RSym "class")]) (RArrayDouble -- [-2.914,-0.5481,0.1618,0.1491,0.9279,3.001])) rRepl :: IO () instance ResultUnpack [(RSEXP, RSEXP)] instance ResultUnpack [RSEXP] instance ResultUnpack (RSEXP, RSEXP) instance ResultUnpack [(Double, Double)] instance ResultUnpack [Bool] instance ResultUnpack [String] instance ResultUnpack [Double] instance ResultUnpack [Int] instance ResultUnpack Bool instance ResultUnpack String instance ResultUnpack Double instance ResultUnpack Int