-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Seamlessly call R from Haskell and vice versa. No FFI required. -- -- For up to date Haddock documentation, please see -- http://www.stackage.org/package/inline-r. @package inline-r @version 0.9.2 -- | Phantom type indices for segregating values into "regions" of memory, -- which are markers that serve as static conservative approximations of -- the liveness of an object. That is, regions have scopes, and objects -- within a region are guaranteed to remain live within the scope of that -- region. module Control.Memory.Region -- | The global region is a special region whose scope extends all the way -- to the end of the program. As such, any object allocated within this -- region lives "forever". In this sense, it is the top-level region, -- whose scope includes all other regions. type GlobalRegion = RealWorld -- | Void is not a region. It is a placeholder marking the absence of -- region. Useful to tag objects that belong to no region at all. data Void -- | Convenient shorthand. type G = GlobalRegion -- | Convenient shorthand. type V = Void -- | A partial order on regions. In fact regions form a lattice, with -- GlobalRegion being the supremum and Void the infimum. -- | Bindings for R/Rembedded.h, containing entry points -- for running an instance of R embedded within another program. module Foreign.R.Embedded -- | Initialize R. initEmbeddedR :: Int -> Ptr CString -> IO () endEmbeddedR :: Int -> IO () -- | Exception type wrapping errors thrown by the R runtime. module Foreign.R.Error data RError RError :: String -> RError instance GHC.Show.Show Foreign.R.Error.RError instance GHC.Exception.Exception Foreign.R.Error.RError -- | Bindings for R/R_ext/eventloop.h, for building event -- loops. module Foreign.R.EventLoop -- | R input handler chain. Each input handler points to the next. This -- view of input handlers is shallow, in the sense that the -- Storable instance only unmarshalls the first element in the -- chain at any one time. A shallow view allows peek and -- poke to be inlinable. data InputHandler InputHandler :: FunPtr (Ptr () -> IO ()) -> CInt -> CInt -> Fd -> Ptr () -> Ptr InputHandler -> InputHandler -- | The input handler callback. [inputHandlerCallback] :: InputHandler -> FunPtr (Ptr () -> IO ()) -- | Undocumented and currently unused. [inputHandlerActivity] :: InputHandler -> CInt -- | Whether this input handler is activated or deactivated. [inputHandlerActive] :: InputHandler -> CInt -- | The file descriptor ahssociated with this handler. [inputHandlerFD] :: InputHandler -> Fd -- | Callbacks can optionally be passed in arbitrary data. [inputHandlerUserData] :: InputHandler -> Ptr () -- | The next input handler in the chain. [inputHandlerNext] :: InputHandler -> Ptr InputHandler -- | Input handlers used in event loops. inputHandlers :: Ptr (Ptr InputHandler) -- | R_PolledEvents global variable. polledEvents :: Ptr (FunPtr (IO ())) -- | R_wait_usec global variable. pollingPeriod :: Ptr CInt -- | R_PolledEvents global variable. graphicsPolledEvents :: Ptr (FunPtr (IO ())) -- | R_wait_usec global variable. graphicsPollingPeriod :: Ptr CInt checkActivity :: CInt -> CInt -> IO (Ptr FdSet) runHandlers :: Ptr InputHandler -> Ptr FdSet -> IO () -- | Create and register a new InputHandler. The given file -- descriptor should be open in non-blocking read mode. Make sure to -- dispose of the callback using freeHaskellFunPtr after calling -- removeInputHandler where appropriate. addInputHandler :: Ptr InputHandler -> Fd -> FunPtr (Ptr () -> IO ()) -> Int -> IO (Ptr InputHandler) -- | Remove an input handler from an input handler chain. Returns -- True if the handler was successfully removed, False -- otherwise. removeInputHandler :: Ptr InputHandler -> Ptr InputHandler -> IO Bool instance GHC.Show.Show Foreign.R.EventLoop.InputHandler instance GHC.Classes.Eq Foreign.R.EventLoop.InputHandler instance Foreign.Storable.Storable Foreign.R.EventLoop.InputHandler -- | R-specific predicates for encoding form constraints in type -- signatures. There are no actual bindings in this module. module Foreign.R.Constraints -- | The predicate a :∈ as states that a is a member type -- of the set as. -- | Non unicode wrapper for the ':∈' type family. type In a b = a :∈ b -- | inline-c context. module Foreign.R.Context rCtx :: Context data {-# CTYPE "SEXPREC" #-} SEXPREC type SEXP0 = Ptr SEXPREC -- | R uses three-valued logic. data {-# CTYPE "Logical" #-} Logical FALSE :: Logical TRUE :: Logical NA :: Logical instance GHC.Show.Show Foreign.R.Context.Logical instance GHC.Classes.Ord Foreign.R.Context.Logical instance GHC.Classes.Eq Foreign.R.Context.Logical instance Foreign.Storable.Storable Foreign.R.Context.Logical -- | Definition of SEXPTYPE, which classifies the possible forms of -- an R expression (a SEXP). It is normally not necessary to -- import this module directly, since it is reexported by -- Foreign.R. -- -- This is done in a separate module because we want to use hsc2hs rather -- than c2hs for discharging the boilerplate around SEXPTYPE. This -- is because SEXPTYPE is nearly but not quite a true enumeration -- and c2hs has trouble dealing with that. -- -- This module also defines a singleton version of SEXPTYPE, -- called SSEXPTYPE. This is actually a family of types, one for -- each possible SEXPTYPE. Singleton types are a way of emulating -- dependent types in a language that does not have true dependent type. -- They are useful in functions whose result type depends on the value of -- one of its arguments. See e.g. allocVector. module Foreign.R.Type -- | R "type". Note that what R calls a "type" is not what is usually meant -- by the term: there is really only a single type, called SEXP, -- and an R "type" in fact refers to the class or form of -- the expression. -- -- To better illustrate the distinction, note that any sane type system -- normally has the subject reduction property: that the type of -- an expression is invariant under reduction. For example, (x -> -- x) 1 has type Int, and so does the value of this -- expression, 2, have type Int. Yet the form of -- the expression is an application of a function to a literal, while the -- form of its reduct is an integer literal. -- -- We introduce convenient Haskell-like names for forms because this -- datatype is used to index SEXP and other types through the -- DataKinds extension. data SEXPTYPE Nil :: SEXPTYPE Symbol :: SEXPTYPE List :: SEXPTYPE Closure :: SEXPTYPE Env :: SEXPTYPE Promise :: SEXPTYPE Lang :: SEXPTYPE Special :: SEXPTYPE Builtin :: SEXPTYPE Char :: SEXPTYPE Logical :: SEXPTYPE Int :: SEXPTYPE Real :: SEXPTYPE Complex :: SEXPTYPE String :: SEXPTYPE DotDotDot :: SEXPTYPE Any :: SEXPTYPE Vector :: SEXPTYPE Expr :: SEXPTYPE Bytecode :: SEXPTYPE ExtPtr :: SEXPTYPE WeakRef :: SEXPTYPE Raw :: SEXPTYPE S4 :: SEXPTYPE New :: SEXPTYPE Free :: SEXPTYPE Fun :: SEXPTYPE type SSEXPTYPE = (Sing :: SEXPTYPE -> Type) -- | R uses three-valued logic. data {-# CTYPE "Logical" #-} Logical FALSE :: Logical TRUE :: Logical NA :: Logical -- | Used where the R documentation speaks of "pairlists", which are really -- just regular lists. type PairList = List -- | Constraint synonym grouping all vector forms into one class. -- IsVector a holds iff R's is.vector() returns -- TRUE. type IsVector (a :: SEXPTYPE) = (SingI a, a :∈ ( 'Char : ( 'Logical : ( 'Int : ( 'Real : ( 'Complex : ( 'String : ( 'Vector : ( 'Expr : ( 'WeakRef : ( 'Raw : '[]))))))))))) -- | Non-atomic vector forms. See src/main/memory.c:SET_VECTOR_ELT -- in the R source distribution. type IsGenericVector (a :: SEXPTYPE) = (SingI a, a :∈ [Vector, Expr, WeakRef]) -- | IsList a holds iff R's is.list() returns -- TRUE. type IsList (a :: SEXPTYPE) = (SingI a, a :∈ ( 'Char : ( 'Logical : ( 'Int : ( 'Real : ( 'Complex : ( 'String : ( 'Vector : ( 'Expr : ( 'WeakRef : ( 'Raw : (List : '[])))))))))))) -- | IsPairList a holds iff R's is.pairlist() returns -- TRUE. type IsPairList (a :: SEXPTYPE) = (SingI a, a :∈ [List, Nil]) -- | Constraint synonym grouping all expression forms into one class. -- According to R internals, an expression is usually a Lang, but -- can sometimes also be an Expr or a Symbol. type IsExpression (a :: SEXPTYPE) = (SingI a, a :∈ [Lang, Expr, Symbol]) instance Data.Singletons.SingKind Foreign.R.Type.SEXPTYPE instance Data.Singletons.SingI 'Foreign.R.Type.Nil instance Data.Singletons.SingI 'Foreign.R.Type.Symbol instance Data.Singletons.SingI 'Foreign.R.Type.List instance Data.Singletons.SingI 'Foreign.R.Type.Closure instance Data.Singletons.SingI 'Foreign.R.Type.Env instance Data.Singletons.SingI 'Foreign.R.Type.Promise instance Data.Singletons.SingI 'Foreign.R.Type.Lang instance Data.Singletons.SingI 'Foreign.R.Type.Special instance Data.Singletons.SingI 'Foreign.R.Type.Builtin instance Data.Singletons.SingI 'Foreign.R.Type.Char instance Data.Singletons.SingI 'Foreign.R.Type.Logical instance Data.Singletons.SingI 'Foreign.R.Type.Int instance Data.Singletons.SingI 'Foreign.R.Type.Real instance Data.Singletons.SingI 'Foreign.R.Type.Complex instance Data.Singletons.SingI 'Foreign.R.Type.String instance Data.Singletons.SingI 'Foreign.R.Type.DotDotDot instance Data.Singletons.SingI 'Foreign.R.Type.Any instance Data.Singletons.SingI 'Foreign.R.Type.Vector instance Data.Singletons.SingI 'Foreign.R.Type.Expr instance Data.Singletons.SingI 'Foreign.R.Type.Bytecode instance Data.Singletons.SingI 'Foreign.R.Type.ExtPtr instance Data.Singletons.SingI 'Foreign.R.Type.WeakRef instance Data.Singletons.SingI 'Foreign.R.Type.Raw instance Data.Singletons.SingI 'Foreign.R.Type.S4 instance Data.Singletons.SingI 'Foreign.R.Type.New instance Data.Singletons.SingI 'Foreign.R.Type.Free instance Data.Singletons.SingI 'Foreign.R.Type.Fun instance Language.Haskell.TH.Syntax.Lift Foreign.R.Type.SEXPTYPE instance GHC.Show.Show Foreign.R.Type.SEXPTYPE instance GHC.Classes.Ord Foreign.R.Type.SEXPTYPE instance GHC.Classes.Eq Foreign.R.Type.SEXPTYPE instance GHC.Enum.Enum Foreign.R.Type.SEXPTYPE instance Control.DeepSeq.NFData Foreign.R.Type.SEXPTYPE -- | Low-level bindings to core R datatypes and functions which depend on -- computing offsets of C struct field. We use hsc2hs for this purpose. module Foreign.R.Internal -- | The basic type of all R expressions, classified by the form of the -- expression, and the memory region in which it has been allocated. newtype SEXP s (a :: SEXPTYPE) SEXP :: Ptr (HExp s a) -> SEXP s [unSEXP] :: SEXP s -> Ptr (HExp s a) -- | Add a type index to the pointer. sexp :: SEXP0 -> SEXP s a -- | Remove the type index from the pointer. unsexp :: SEXP s a -> SEXP0 -- | Like sexp but for SomeSEXP. somesexp :: SEXP0 -> SomeSEXP s -- | Release object into another region. Releasing is safe so long as the -- target region is "smaller" than the source region, in the sense of -- '(Control.Memory.Region.<=)'. release :: (t <= s) => SEXP s a -> SEXP t a unsafeRelease :: SEXP s a -> SEXP r a -- | A SEXP of unknown form. data SomeSEXP s SomeSEXP :: {-# UNPACK #-} !(SEXP s a) -> SomeSEXP s -- | Deconstruct a SomeSEXP. Takes a continuation since otherwise -- the existentially quantified variable hidden inside SomeSEXP -- would escape. unSomeSEXP :: SomeSEXP s -> (forall a. SEXP s a -> r) -> r cIntConv :: (Integral a, Integral b) => a -> b cIntToEnum :: Enum a => CInt -> a cUIntFromSingEnum :: SSEXPTYPE a -> CUInt cIntFromEnum :: Enum a => a -> CInt -- | Return the "type" tag (aka the form tag) of the given SEXP. -- This function is pure because the type of an object does not normally -- change over the lifetime of the object. typeOf :: SEXP s a -> SEXPTYPE cTYPEOF :: SEXP0 -> IO CInt -- | Set CAR field of object, when object is viewed as a cons cell. setCar :: SEXP s a -> SEXP s b -> IO () -- | Set CDR field of object, when object is viewed as a cons cell. setCdr :: SEXP s a -> SEXP s b -> IO () -- | Set TAG field of object, when object is viewed as a cons cell. setTag :: SEXP s a -> SEXP s b -> IO () unsafeCast :: SEXPTYPE -> SomeSEXP s -> SEXP s b -- | Cast the type of a SEXP into another type. This function is -- partial: at runtime, an error is raised if the source form tag does -- not match the target form tag. cast :: SSEXPTYPE a -> SomeSEXP s -> SEXP s a -- | Cast form of first argument to that of the second argument. asTypeOf :: SomeSEXP s -> SEXP s a -> SEXP s a -- | Unsafe coercion from one form to another. This is unsafe, in the sense -- that using this function improperly could cause code to crash in -- unpredictable ways. Contrary to cast, it has no runtime cost -- since it does not introduce any dynamic check at runtime. unsafeCoerce :: SEXP s a -> SEXP s b -- | Length of the vector. length :: IsVector a => SEXP s a -> IO Int -- | Extract the data pointer from a vector. unsafeSEXPToVectorPtr :: SEXP s a -> Ptr () -- | Inverse of vectorPtr. unsafeVectorPtrToSEXP :: Ptr a -> SomeSEXP s isRInteractive :: Ptr CInt -- | Global nil value. Constant throughout the lifetime of the R instance. nilValue :: Ptr (SEXP G Nil) -- | Unbound marker. Constant throughout the lifetime of the R instance. unboundValue :: Ptr (SEXP G Symbol) -- | Missing argument marker. Constant throughout the lifetime of the R -- instance. missingArg :: Ptr (SEXP G Symbol) -- | The base environment. baseEnv :: Ptr (SEXP G Env) -- | The empty environment. emptyEnv :: Ptr (SEXP G Env) -- | Global environment. globalEnv :: Ptr (SEXP G Env) -- | Signal handler switch signalHandlers :: Ptr CInt -- | Flag that shows if computation should be interrupted. interruptsPending :: Ptr CInt -- | Info header for the SEXP data structure. data SEXPInfo SEXPInfo :: SEXPTYPE -> Bool -> Int -> Int -> Bool -> Bool -> Bool -> Bool -> Int -> Int -> SEXPInfo -- | Type of the SEXP. [infoType] :: SEXPInfo -> SEXPTYPE -- | Is this an object with a class attribute. [infoObj] :: SEXPInfo -> Bool -- | Control copying information. [infoNamed] :: SEXPInfo -> Int -- | General purpose data. [infoGp] :: SEXPInfo -> Int -- | Mark object as 'in use' in GC. [infoMark] :: SEXPInfo -> Bool -- | Debug marker. [infoDebug] :: SEXPInfo -> Bool -- | Trace marker. [infoTrace] :: SEXPInfo -> Bool -- | Alignment (not in use). [infoSpare] :: SEXPInfo -> Bool -- | GC Generation. [infoGcGen] :: SEXPInfo -> Int -- | GC Class of node. [infoGcCls] :: SEXPInfo -> Int -- | Extract the header from the given SEXP. peekInfo :: SEXP s a -> IO SEXPInfo cOBJECT :: SEXP0 -> IO CInt cNAMED :: SEXP0 -> IO CInt cLEVELS :: SEXP0 -> IO CInt cMARK :: SEXP0 -> IO CInt cRDEBUG :: SEXP0 -> IO CInt cRTRACE :: SEXP0 -> IO CInt cRSTEP :: SEXP0 -> IO CInt cGCGEN :: SEXP0 -> IO CInt cGCCLS :: SEXP0 -> IO CInt -- | Write a new header. pokeInfo :: SEXP s a -> SEXPInfo -> IO () cSET_TYPEOF :: SEXP0 -> CInt -> IO () cSET_OBJECT :: SEXP0 -> CInt -> IO () cSET_NAMED :: SEXP0 -> CInt -> IO () cSETLEVELS :: SEXP0 -> CInt -> IO () cSET_MARK :: SEXP0 -> CInt -> IO () cSET_RDEBUG :: SEXP0 -> CInt -> IO () cSET_RTRACE :: SEXP0 -> CInt -> IO () cSET_RSTEP :: SEXP0 -> CInt -> IO () cSET_GCGEN :: SEXP0 -> CInt -> IO () cSET_GCCLS :: SEXP0 -> CInt -> IO () -- | Set the GC mark. mark :: Bool -> SEXP s a -> IO () named :: Int -> SEXP s a -> IO () -- | Check if object is an S4 object. -- -- This is a function call so it will be more precise than using -- typeOf. isS4 :: SEXP s ty -> Bool -- | Get the attribute list from the given object. getAttributes :: SEXP s a -> IO (SEXP s b) -- | Get attribute with the given name. getAttribute :: SEXP s a -> SEXP s2 b -> SEXP s c -- | Set the attribute list. setAttributes :: SEXP s a -> SEXP s b -> IO () cAttrib :: SEXP0 -> IO SEXP0 csetAttrib :: SEXP0 -> SEXP0 -> IO () cgetAttrib :: SEXP0 -> SEXP0 -> SEXP0 cisS4 :: SEXP0 -> Int instance GHC.Show.Show Foreign.R.Internal.SEXPInfo instance Foreign.Storable.Storable (Foreign.R.Internal.SEXP s a) instance GHC.Classes.Ord (Foreign.R.Internal.SEXP s a) instance GHC.Classes.Eq (Foreign.R.Internal.SEXP s a) instance GHC.Show.Show (Foreign.R.Internal.SomeSEXP s) instance Foreign.Storable.Storable (Foreign.R.Internal.SomeSEXP s) instance Control.DeepSeq.NFData (Foreign.R.Internal.SomeSEXP s) instance GHC.Show.Show (Foreign.R.Internal.SEXP s a) instance Control.DeepSeq.NFData (Foreign.R.Internal.SEXP s a) -- | Low-level bindings to core R datatypes and functions. Nearly all -- structures allocated internally in R are instances of a -- SEXPREC. A pointer to a SEXPREC is called a SEXP. -- -- To allow for precise typing of bindings to primitive R functions, we -- index SEXPs by SEXPTYPE, which classifies the -- form of a SEXP (see Foreign.R.Type). A function -- accepting SEXP arguments of any type should leave the type -- index uninstantiated. A function returning a SEXP result of -- unknown type should use SomeSEXP. (More precisely, unknown -- types in negative position should be universally -- quantified and unknown types in positive position should be -- existentially quantified). -- -- This module is intended to be imported qualified. module Foreign.R -- | The basic type of all R expressions, classified by the form of the -- expression, and the memory region in which it has been allocated. newtype SEXP s (a :: SEXPTYPE) SEXP :: Ptr (HExp s a) -> SEXP s [unSEXP] :: SEXP s -> Ptr (HExp s a) -- | A SEXP of unknown form. data SomeSEXP s SomeSEXP :: {-# UNPACK #-} !(SEXP s a) -> SomeSEXP s -- | Deconstruct a SomeSEXP. Takes a continuation since otherwise -- the existentially quantified variable hidden inside SomeSEXP -- would escape. unSomeSEXP :: SomeSEXP s -> (forall a. SEXP s a -> r) -> r -- | Cast the type of a SEXP into another type. This function is -- partial: at runtime, an error is raised if the source form tag does -- not match the target form tag. cast :: SSEXPTYPE a -> SomeSEXP s -> SEXP s a -- | Cast form of first argument to that of the second argument. asTypeOf :: SomeSEXP s -> SEXP s a -> SEXP s a -- | Unsafe coercion from one form to another. This is unsafe, in the sense -- that using this function improperly could cause code to crash in -- unpredictable ways. Contrary to cast, it has no runtime cost -- since it does not introduce any dynamic check at runtime. unsafeCoerce :: SEXP s a -> SEXP s b -- | Allocate a SEXP. allocSEXP :: SSEXPTYPE a -> IO (SEXP V a) -- | Allocate a pairlist of SEXPs, chained together. allocList :: Int -> IO (SEXP V 'List) -- | Allocate Vector. allocVector :: IsVector a => SSEXPTYPE a -> Int -> IO (SEXP V a) allocVectorProtected :: (IsVector a) => SSEXPTYPE a -> Int -> IO (SEXP s a) -- | Intern a string name into the symbol table. -- -- If name is not found, it is added to the symbol table. The -- symbol corresponding to the string name is returned. install :: CString -> IO (SEXP V 'Symbol) -- | Initialize a new string vector. mkString :: CString -> IO (SEXP V 'String) -- | Initialize a new character vector (aka a string). mkChar :: CString -> IO (SEXP V 'Char) -- | Content encoding. data CEType CE_Native :: CEType CE_UTF8 :: CEType CE_Latin1 :: CEType CE_Bytes :: CEType CE_Symbol :: CEType CE_Any :: CEType -- | Create Character value with specified encoding mkCharCE :: CEType -> CString -> IO (SEXP V 'Char) mkCharLenCE :: CEType -> CString -> Int -> IO (SEXP V 'Char) mkWeakRef :: SEXP s a -> SEXP s b -> SEXP s c -> Bool -> IO (SEXP V 'WeakRef) -- | Return the "type" tag (aka the form tag) of the given SEXP. -- This function is pure because the type of an object does not normally -- change over the lifetime of the object. typeOf :: SEXP s a -> SEXPTYPE -- | Check if object is an S4 object. -- -- This is a function call so it will be more precise than using -- typeOf. isS4 :: SEXP s ty -> Bool -- | Set the attribute list. setAttributes :: SEXP s a -> SEXP s b -> IO () -- | Get attribute with the given name. getAttribute :: SEXP s a -> SEXP s2 b -> SEXP s c -- | Get the attribute list from the given object. getAttributes :: SEXP s a -> IO (SEXP s b) -- | Allocate a so-called cons cell, in essence a pair of SEXP -- pointers. cons :: SEXP s a -> SEXP s b -> IO (SEXP V 'List) -- | Allocate a so-called cons cell of language objects, in essence a pair -- of SEXP pointers. lcons :: SEXP s a -> SEXP s b -> IO (SEXP V 'Lang) -- | read CAR object value car :: SEXP s a -> IO (SomeSEXP s) -- | read CDR object cdr :: SEXP s a -> IO (SomeSEXP s) -- | read object`s Tag tag :: SEXP s a -> IO (SomeSEXP s) -- | Set CAR field of object, when object is viewed as a cons cell. setCar :: SEXP s a -> SEXP s b -> IO () -- | Set CDR field of object, when object is viewed as a cons cell. setCdr :: SEXP s a -> SEXP s b -> IO () -- | Set TAG field of object, when object is viewed as a cons cell. setTag :: SEXP s a -> SEXP s b -> IO () envFrame :: (SEXP s 'Env) -> IO (SEXP s PairList) -- | Enclosing environment. envEnclosing :: SEXP s 'Env -> IO (SEXP s 'Env) -- | Hash table associated with the environment, used for faster name -- lookups. envHashtab :: SEXP s 'Env -> IO (SEXP s 'Vector) -- | Closure formals (aka the actual arguments). closureFormals :: SEXP s 'Closure -> IO (SEXP s PairList) -- | The code of the closure. closureBody :: SEXP s 'Closure -> IO (SomeSEXP s) -- | The environment of the closure. closureEnv :: SEXP s 'Closure -> IO (SEXP s 'Env) -- | The code of a promise. promiseCode :: SEXP s 'Promise -> IO (SomeSEXP s) -- | The environment in which to evaluate the promise. promiseEnv :: SEXP s 'Promise -> IO (SomeSEXP s) -- | The value of the promise, if it has already been forced. promiseValue :: SEXP s 'Promise -> IO (SomeSEXP s) -- | Read a name from symbol. symbolPrintName :: SEXP s 'Symbol -> IO (SEXP s a) -- | Read value from symbol. symbolValue :: SEXP s 'Symbol -> IO (SEXP s a) -- | Read internal value from symbol. symbolInternal :: SEXP s 'Symbol -> IO (SEXP s a) -- | Length of the vector. length :: IsVector a => SEXP s a -> IO Int -- | Read True Length vector field. trueLength :: IsVector a => SEXP s a -> IO CInt -- | Read character vector data char :: SEXP s 'Char -> IO CString -- | Read real vector data. real :: SEXP s 'Real -> IO (Ptr Double) -- | Read integer vector data. integer :: SEXP s 'Int -> IO (Ptr Int32) -- | Read logical vector data. logical :: SEXP s 'Logical -> IO (Ptr Logical) -- | Read complex vector data. complex :: SEXP s 'Complex -> IO (Ptr (Complex Double)) -- | Read raw data. raw :: SEXP s 'Raw -> IO (Ptr CChar) -- | Read string vector data. string :: SEXP s 'String -> IO (Ptr (SEXP s 'Char)) -- | Extract the data pointer from a vector. unsafeSEXPToVectorPtr :: SEXP s a -> Ptr () -- | Inverse of vectorPtr. unsafeVectorPtrToSEXP :: Ptr a -> SomeSEXP s readVector :: IsGenericVector a => SEXP s a -> Int -> IO (SomeSEXP s) writeVector :: IsGenericVector a => SEXP s a -> Int -> SEXP s b -> IO (SEXP s a) -- | Evaluate any SEXP to its value. eval :: SEXP s a -> SEXP s 'Env -> IO (SomeSEXP V) -- | Try to evaluate expression. tryEval :: SEXP s a -> SEXP s 'Env -> Ptr CInt -> IO (SomeSEXP V) -- | Try to evaluate without printing error/warning messages to stdout. tryEvalSilent :: SEXP s a -> SEXP s 'Env -> Ptr CInt -> IO (SomeSEXP V) -- | Construct a nullary function call. lang1 :: SEXP s a -> IO (SEXP V 'Lang) -- | Construct unary function call. lang2 :: SEXP s a -> SEXP s b -> IO (SEXP V 'Lang) -- | Construct a binary function call. lang3 :: SEXP s a -> SEXP s b -> SEXP s c -> IO (SEXP V 'Lang) -- | Find a function by name. findFun :: SEXP s a -> SEXP s 'Env -> IO (SomeSEXP s) -- | Find a variable by name. findVar :: SEXP s a -> SEXP s 'Env -> IO (SEXP s 'Symbol) -- | Protect a SEXP from being garbage collected by R. It is in -- particular necessary to do so for objects that are not yet pointed by -- any other object, e.g. when constructing a tree bottom-up rather than -- top-down. -- -- To avoid unbalancing calls to protect and unprotect, do -- not use these functions directly but use withProtected instead. protect :: SEXP s a -> IO (SEXP G a) -- | unprotect n unprotects the last n objects that were -- protected. unprotect :: Int -> IO () -- | Unprotect a specific object, referred to by pointer. unprotectPtr :: SEXP G a -> IO () -- | Preserve an object accross GCs. preserveObject :: SEXP s a -> IO () -- | Allow GC to remove an preserved object. releaseObject :: SEXP s a -> IO () -- | Invoke an R garbage collector sweep. gc :: IO () isRInteractive :: Ptr CInt -- | Global nil value. Constant throughout the lifetime of the R instance. nilValue :: Ptr (SEXP G Nil) -- | Unbound marker. Constant throughout the lifetime of the R instance. unboundValue :: Ptr (SEXP G Symbol) -- | Missing argument marker. Constant throughout the lifetime of the R -- instance. missingArg :: Ptr (SEXP G Symbol) -- | The base environment. baseEnv :: Ptr (SEXP G Env) -- | The empty environment. emptyEnv :: Ptr (SEXP G Env) -- | Global environment. globalEnv :: Ptr (SEXP G Env) -- | Signal handler switch signalHandlers :: Ptr CInt -- | Flag that shows if computation should be interrupted. interruptsPending :: Ptr CInt printValue :: SEXP s a -> IO () -- | Info header for the SEXP data structure. data SEXPInfo SEXPInfo :: SEXPTYPE -> Bool -> Int -> Int -> Bool -> Bool -> Bool -> Bool -> Int -> Int -> SEXPInfo -- | Type of the SEXP. [infoType] :: SEXPInfo -> SEXPTYPE -- | Is this an object with a class attribute. [infoObj] :: SEXPInfo -> Bool -- | Control copying information. [infoNamed] :: SEXPInfo -> Int -- | General purpose data. [infoGp] :: SEXPInfo -> Int -- | Mark object as 'in use' in GC. [infoMark] :: SEXPInfo -> Bool -- | Debug marker. [infoDebug] :: SEXPInfo -> Bool -- | Trace marker. [infoTrace] :: SEXPInfo -> Bool -- | Alignment (not in use). [infoSpare] :: SEXPInfo -> Bool -- | GC Generation. [infoGcGen] :: SEXPInfo -> Int -- | GC Class of node. [infoGcCls] :: SEXPInfo -> Int -- | Extract the header from the given SEXP. peekInfo :: SEXP s a -> IO SEXPInfo -- | Write a new header. pokeInfo :: SEXP s a -> SEXPInfo -> IO () -- | Set the GC mark. mark :: Bool -> SEXP s a -> IO () named :: Int -> SEXP s a -> IO () data {-# CTYPE "SEXPREC" #-} SEXPREC type SEXP0 = Ptr SEXPREC -- | Add a type index to the pointer. sexp :: SEXP0 -> SEXP s a -- | Remove the type index from the pointer. unsexp :: SEXP s a -> SEXP0 -- | Release object into another region. Releasing is safe so long as the -- target region is "smaller" than the source region, in the sense of -- '(Control.Memory.Region.<=)'. release :: (t <= s) => SEXP s a -> SEXP t a unsafeRelease :: SEXP s a -> SEXP r a -- | Perform an action with resource while protecting it from the garbage -- collection. This function is a safer alternative to protect and -- unprotect, guaranteeing that a protected resource gets -- unprotected irrespective of the control flow, much like -- bracket_. withProtected :: IO (SEXP V a) -> (SEXP s a -> IO b) -> IO b -- | Deprecated: Use readVector instead. indexVector :: IsGenericVector a => SEXP s a -> Int -> IO (SomeSEXP s) instance GHC.Show.Show Foreign.R.CEType instance GHC.Classes.Eq Foreign.R.CEType instance GHC.Enum.Enum Foreign.R.CEType -- | Global variables used by the R interpreter. All are constant, but the -- values of some of them may change over time (e.g. the global -- environment). module Language.R.Globals -- | The base environment. baseEnv :: SEXP G 'Env -- | The empty environment. emptyEnv :: SEXP G 'Env -- | The global environment. globalEnv :: SEXP G 'Env -- | R's NULL value. nilValue :: SEXP G 'Nil -- | Value substituted for all missing actual arguments of a function call. missingArg :: SEXP G 'Symbol -- | Special value to which all symbols unbound in the current environment -- resolve to. unboundValue :: SEXP G 'Symbol isRInteractive :: Ptr CInt signalHandlersPtr :: Ptr CInt inputHandlers :: Ptr InputHandler pokeRVariables :: RVariables -> IO () -- | Bindings for R/R_ext/Parse.h. module Foreign.R.Parse -- | parseVector text num status source parses the input string -- into an AST. source, if provided, names the origin of -- text (e.g. a filename). num limits the number of -- expressions to parse, or -1 if no limit. parseVector :: (In a [Nil, String]) => SEXP s String -> Int -> Ptr CInt -> SEXP s a -> IO (SEXP s Expr) -- | The return code of a call to parseVector, indicating whether -- the parser failed or succeeded. data ParseStatus PARSE_NULL :: ParseStatus PARSE_OK :: ParseStatus PARSE_INCOMPLETE :: ParseStatus PARSE_ERROR :: ParseStatus PARSE_EOF :: ParseStatus instance GHC.Show.Show Foreign.R.Parse.ParseStatus instance GHC.Classes.Eq Foreign.R.Parse.ParseStatus instance GHC.Enum.Enum Foreign.R.Parse.ParseStatus module Data.Vector.SEXP.Base -- | Function from R types to the types of the representations of each -- element in the vector. -- | ElemRep in the form of a relation, for convenience. type E s a b = ElemRep s a ~ b -- | Constraint synonym for all operations on vectors. type VECTOR s ty a = (Storable a, IsVector ty, SingI ty, ElemRep s ty ~ a) -- | Constraint synonym for all operations on vectors. type SVECTOR ty a = (Storable a, IsVector ty, SingI ty, ElemRep V ty ~ a) -- | Facilities to get Haskell's garbage collector to manage the liveness -- of values allocated on the R heap. By default, R values remain live so -- long as the current region is extant. The R garbage collector may only -- free them after the end of the region. Sometimes, this discipline -- incurs too high of a memory usage and nested regions are not always a -- solution. -- -- This module enables registering a callback with the GHC garbage -- collector. In this way, when the GHC garbage collector detects that a -- value is no longer live, we can notify the R garbage collector of this -- fact. The R garbage collector is then free to deallocate the memory -- associated with the value soon after that. -- -- This module hence offers an alternative, more flexible memory -- management discipline, at a performance cost. In particular, -- collections of many small, short-lived objects are best managed using -- regions. module Language.R.GC -- | Declare memory management for this value to be automatic. That is, the -- memory associated with it may be freed as soon as the garbage -- collector notices that it is safe to do so. -- -- Values with automatic memory management are tagged with the global -- region. The reason is that just like for other global values, -- deallocation of the value can never be observed. Indeed, it is a mere -- "optimization" to deallocate the value sooner - it would still be -- semantically correct to never deallocate it at all. automatic :: MonadR m => SEXP s a -> m (SEXP G a) -- | automatic for SomeSEXP. automaticSome :: MonadR m => SomeSEXP s -> m (SomeSEXP G) -- | Helper module for writing event loops that mesh with R events. -- -- Events in R are dispatched from a number of file descriptors. The R -- runtime maintains a list of "input handlers", essentially a set of -- file descriptors together with callbacks for each one, invoked -- whenever the file descriptor becomes available for reading. This -- module exports functions for dispatching on both R events and Haskell -- events simultaneously, using GHC.Event, which is based on -- epollkqueuepoll under the hood for efficient and scalable event -- dispatching. -- -- Event dispatching and processing is in particular necessary for R's -- GUI to be responsive. For a consistent user experience, you should -- arrange for all GUI related events to be dispatched from a single -- thread, ideally the program's main thread. In fact on some platforms, -- most notably OS X (darwin), you must use the main thread. -- -- Event loops can be constructed in one of two ways: -- --
-- copy mv v = ... write mv i (v ! i) ... ---- -- For lazy vectors, v ! i would not be evaluated which means -- that mv would unnecessarily retain a reference to v -- in each element written. -- -- With indexM, copying can be implemented like this instead: -- --
-- copy mv v = ... do -- x <- indexM v i -- write mv i x ---- -- Here, no references to v are retained because indexing (but -- not the elements) is evaluated eagerly. indexM :: (VECTOR s ty a, Monad m) => Vector s ty a -> Int -> m a -- | O(1) First element of a vector in a monad. See indexM -- for an explanation of why this is useful. headM :: (VECTOR s ty a, Monad m) => Vector s ty a -> m a -- | O(1) Last element of a vector in a monad. See indexM for -- an explanation of why this is useful. lastM :: (VECTOR s ty a, Monad m) => Vector s ty a -> m a -- | O(1) Indexing in a monad without bounds checks. See -- indexM for an explanation of why this is useful. unsafeIndexM :: (VECTOR s ty a, Monad m) => Vector s ty a -> Int -> m a -- | O(1) First element in a monad without checking for empty -- vectors. See indexM for an explanation of why this is useful. unsafeHeadM :: (VECTOR s ty a, Monad m) => Vector s ty a -> m a -- | O(1) Last element in a monad without checking for empty -- vectors. See indexM for an explanation of why this is useful. unsafeLastM :: (VECTOR s ty a, Monad m) => Vector s ty a -> m a -- | O(N) Yield a slice of the vector with copying it. The vector -- must contain at least i+n elements. slice :: VECTOR s ty a => Int -> Int -> Vector s ty a -> Vector s ty a -- | O(N) Yield all but the last element, this operation will copy -- an array. The vector may not be empty. init :: VECTOR s ty a => Vector s ty a -> Vector s ty a -- | O(N) Yield at the first n elements with copying. The -- vector may contain less than n elements in which case it is -- returned unchanged. take :: VECTOR s ty a => Int -> Vector s ty a -> Vector s ty a -- | O(N) Yield all but the first n elements with copying. -- The vector may contain less than n elements in which case an -- empty vector is returned. drop :: VECTOR s ty a => Int -> Vector s ty a -> Vector s ty a -- | O(N) Copy all but the first element. The vector may not be -- empty. tail :: VECTOR s ty a => Vector s ty a -> Vector s ty a -- | O(N) Yield the first n elements paired with the -- remainder with copying. -- -- Note that splitAt n v is equivalent to -- (take n v, drop n v) but slightly more -- efficient. splitAt :: VECTOR s ty a => Int -> Vector s ty a -> (Vector s ty a, Vector s ty a) -- | O(N) Yield all but the first element with copying. The vector -- may not be empty but this is not checked. unsafeTail :: VECTOR s ty a => Vector s ty a -> Vector s ty a -- | O(N) Yield a slice of the vector with copying. The vector must -- contain at least i+n elements but this is not checked. unsafeSlice :: VECTOR s ty a => Int -> Int -> Vector s ty a -> Vector s ty a -- | O(N) Yield all but the first n elements with copying. -- The vector must contain at least n elements but this is not -- checked. unsafeDrop :: VECTOR s ty a => Int -> Vector s ty a -> Vector s ty a -- | O(N) Yield the first n elements with copying. The -- vector must contain at least n elements but this is not -- checked. unsafeTake :: VECTOR s ty a => Int -> Vector s ty a -> Vector s ty a -- | O(N) Yield all but the last element with copying. The vector -- may not be empty but this is not checked. unsafeInit :: VECTOR s ty a => Vector s ty a -> Vector s ty a -- | O(1) Empty vector empty :: VECTOR s ty a => Vector s ty a -- | O(1) Vector with exactly one element singleton :: VECTOR s ty a => a -> Vector s ty a -- | O(n) Vector of the given length with the same value in each -- position replicate :: VECTOR s ty a => Int -> a -> Vector s ty a -- | O(n) Construct a vector of the given length by applying the -- function to each index generate :: VECTOR s ty a => Int -> (Int -> a) -> Vector s ty a -- | O(n) Apply function n times to value. Zeroth element is -- original value. iterateN :: VECTOR s ty a => Int -> (a -> a) -> a -> Vector s ty a -- | O(n) Execute the monadic action the given number of times and -- store the results in a vector. replicateM :: (Monad m, VECTOR s ty a) => Int -> m a -> m (Vector s ty a) -- | O(n) Construct a vector of the given length by applying the -- monadic action to each index generateM :: (Monad m, VECTOR s ty a) => Int -> (Int -> m a) -> m (Vector s ty a) -- | Execute the monadic action and freeze the resulting vector. -- --
-- create (do { v <- new 2; write v 0 'a'; write v 1 'b'; return v }) = <a,b>
--
create :: VECTOR s ty a => (forall r. ST r (MVector r ty a)) -> Vector s ty a
-- | O(n) Construct a Vector s ty by repeatedly applying the
-- generator function to a seed. The generator function yields
-- Just the next element and the new seed or Nothing if
-- there are no more elements.
--
-- -- unfoldr (\n -> if n == 0 then Nothing else Just (n,n-1)) 10 -- = <10,9,8,7,6,5,4,3,2,1> --unfoldr :: VECTOR s ty a => (b -> Maybe (a, b)) -> b -> Vector s ty a -- | O(n) Construct a vector with at most n by repeatedly -- applying the generator function to the a seed. The generator function -- yields Just the next element and the new seed or -- Nothing if there are no more elements. -- --
-- unfoldrN 3 (\n -> Just (n,n-1)) 10 = <10,9,8> --unfoldrN :: VECTOR s ty a => Int -> (b -> Maybe (a, b)) -> b -> Vector s ty a -- | O(n) Construct a vector with n elements by repeatedly -- applying the generator function to the already constructed part of the -- vector. -- --
-- constructN 3 f = let a = f <> ; b = f <a> ; c = f <a,b> in f <a,b,c> --constructN :: VECTOR s ty a => Int -> (Vector s ty a -> a) -> Vector s ty a -- | O(n) Construct a vector with n elements from right to -- left by repeatedly applying the generator function to the already -- constructed part of the vector. -- --
-- constructrN 3 f = let a = f <> ; b = f<a> ; c = f <b,a> in f <c,b,a> --constructrN :: VECTOR s ty a => Int -> (Vector s ty a -> a) -> Vector s ty a -- | O(n) Yield a vector of the given length containing the values -- x, x+1 etc. This operation is usually more efficient -- than enumFromTo. -- --
-- enumFromN 5 3 = <5,6,7> --enumFromN :: (VECTOR s ty a, Num a) => a -> Int -> Vector s ty a -- | O(n) Yield a vector of the given length containing the values -- x, x+y, x+y+y etc. This operations is -- usually more efficient than enumFromThenTo. -- --
-- enumFromStepN 1 0.1 5 = <1,1.1,1.2,1.3,1.4> --enumFromStepN :: (VECTOR s ty a, Num a) => a -> a -> Int -> Vector s ty a -- | O(n) Enumerate values from x to y. -- -- WARNING: This operation can be very inefficient. If at all -- possible, use enumFromN instead. enumFromTo :: (VECTOR s ty a, Enum a) => a -> a -> Vector s ty a -- | O(n) Enumerate values from x to y with a -- specific step z. -- -- WARNING: This operation can be very inefficient. If at all -- possible, use enumFromStepN instead. enumFromThenTo :: (VECTOR s ty a, Enum a) => a -> a -> a -> Vector s ty a -- | O(n) Prepend an element cons :: VECTOR s ty a => a -> Vector s ty a -> Vector s ty a -- | O(n) Append an element snoc :: VECTOR s ty a => Vector s ty a -> a -> Vector s ty a -- | O(m+n) Concatenate two vectors (++) :: VECTOR s ty a => Vector s ty a -> Vector s ty a -> Vector s ty a infixr 5 ++ -- | O(n) Concatenate all vectors in the list concat :: VECTOR s ty a => [Vector s ty a] -> Vector s ty a -- | O(n) Yield the argument but force it not to retain any extra -- memory, possibly by copying it. -- -- This is especially useful when dealing with slices. For example: -- --
-- force (slice 0 2 <huge vector>) ---- -- Here, the slice retains a reference to the huge vector. Forcing it -- creates a copy of just the elements that belong to the slice and -- allows the huge vector to be garbage collected. force :: VECTOR s ty a => Vector s ty a -> Vector s ty a -- | O(m+n) For each pair (i,a) from the list, replace the -- vector element at position i by a. -- --
-- <5,9,2,7> // [(2,1),(0,3),(2,8)] = <3,9,8,7> --(//) :: VECTOR s ty a => Vector s ty a -> [(Int, a)] -> Vector s ty a -- | Same as (//) but without bounds checking. unsafeUpd :: VECTOR s ty a => Vector s ty a -> [(Int, a)] -> Vector s ty a -- | O(m+n) For each pair (i,b) from the list, replace the -- vector element a at position i by f a b. -- --
-- accum (+) <5,9,2> [(2,4),(1,6),(0,3),(1,7)] = <5+3, 9+6+7, 2+4> --accum :: VECTOR s ty a => (a -> b -> a) -> Vector s ty a -> [(Int, b)] -> Vector s ty a -- | Same as accum but without bounds checking. unsafeAccum :: VECTOR s ty a => (a -> b -> a) -> Vector s ty a -> [(Int, b)] -> Vector s ty a -- | O(n) Reverse a vector reverse :: VECTOR s ty a => Vector s ty a -> Vector s ty a -- | O(n) Map a function over a vector map :: (VECTOR s ty a, VECTOR s ty b) => (a -> b) -> Vector s ty a -> Vector s ty b -- | O(n) Apply a function to every element of a Vector s ty and its -- index imap :: (VECTOR s ty a, VECTOR s ty b) => (Int -> a -> b) -> Vector s ty a -> Vector s ty b -- | Map a function over a Vector s ty and concatenate the results. concatMap :: (VECTOR s tya a, VECTOR s tyb b) => (a -> Vector s tyb b) -> Vector s tya a -> Vector s tyb b -- | O(n) Apply the monadic action to all elements of the vector, -- yielding a vector of results mapM :: (Monad m, VECTOR s ty a, VECTOR s ty b) => (a -> m b) -> Vector s ty a -> m (Vector s ty b) -- | O(n) Apply the monadic action to all elements of a Vector s ty -- and ignore the results mapM_ :: (Monad m, VECTOR s ty a) => (a -> m b) -> Vector s ty a -> m () -- | O(n) Apply the monadic action to all elements of the vector, -- yielding a vector of results. Equvalent to flip mapM. forM :: (Monad m, VECTOR s ty a, VECTOR s ty b) => Vector s ty a -> (a -> m b) -> m (Vector s ty b) -- | O(n) Apply the monadic action to all elements of a Vector s ty -- and ignore the results. Equivalent to flip mapM_. forM_ :: (Monad m, VECTOR s ty a) => Vector s ty a -> (a -> m b) -> m () -- | O(min(m,n)) Zip two vectors with the given function. zipWith :: (VECTOR s tya a, VECTOR s tyb b, VECTOR s tyc c) => (a -> b -> c) -> Vector s tya a -> Vector s tyb b -> Vector s tyc c -- | Zip three vectors with the given function. zipWith3 :: (VECTOR s tya a, VECTOR s tyb b, VECTOR s tyc c, VECTOR s tyd d) => (a -> b -> c -> d) -> Vector s tya a -> Vector s tyb b -> Vector s tyc c -> Vector s tyd d zipWith4 :: (VECTOR s tya a, VECTOR s tyb b, VECTOR s tyc c, VECTOR s tyd d, VECTOR s tye e) => (a -> b -> c -> d -> e) -> Vector s tya a -> Vector s tyb b -> Vector s tyc c -> Vector s tyd d -> Vector s tye e zipWith5 :: (VECTOR s tya a, VECTOR s tyb b, VECTOR s tyc c, VECTOR s tyd d, VECTOR s tye e, VECTOR s tyf f) => (a -> b -> c -> d -> e -> f) -> Vector s tya a -> Vector s tyb b -> Vector s tyc c -> Vector s tyd d -> Vector s tye e -> Vector s tyf f zipWith6 :: (VECTOR s tya a, VECTOR s tyb b, VECTOR s tyc c, VECTOR s tyd d, VECTOR s tye e, VECTOR s tyf f, VECTOR s tyg g) => (a -> b -> c -> d -> e -> f -> g) -> Vector s tya a -> Vector s tyb b -> Vector s tyc c -> Vector s tyd d -> Vector s tye e -> Vector s tyf f -> Vector s tyg g -- | O(min(m,n)) Zip two vectors with a function that also takes the -- elements' indices. izipWith :: (VECTOR s tya a, VECTOR s tyb b, VECTOR s tyc c) => (Int -> a -> b -> c) -> Vector s tya a -> Vector s tyb b -> Vector s tyc c -- | Zip three vectors and their indices with the given function. izipWith3 :: (VECTOR s tya a, VECTOR s tyb b, VECTOR s tyc c, VECTOR s tyd d) => (Int -> a -> b -> c -> d) -> Vector s tya a -> Vector s tyb b -> Vector s tyc c -> Vector s tyd d izipWith4 :: (VECTOR s tya a, VECTOR s tyb b, VECTOR s tyc c, VECTOR s tyd d, VECTOR s tye e) => (Int -> a -> b -> c -> d -> e) -> Vector s tya a -> Vector s tyb b -> Vector s tyc c -> Vector s tyd d -> Vector s tye e izipWith5 :: (VECTOR s tya a, VECTOR s tyb b, VECTOR s tyc c, VECTOR s tyd d, VECTOR s tye e, VECTOR s tyf f) => (Int -> a -> b -> c -> d -> e -> f) -> Vector s tya a -> Vector s tyb b -> Vector s tyc c -> Vector s tyd d -> Vector s tye e -> Vector s tyf f izipWith6 :: (VECTOR s tya a, VECTOR s tyb b, VECTOR s tyc c, VECTOR s tyd d, VECTOR s tye e, VECTOR s tyf f, VECTOR s tyg g) => (Int -> a -> b -> c -> d -> e -> f -> g) -> Vector s tya a -> Vector s tyb b -> Vector s tyc c -> Vector s tyd d -> Vector s tye e -> Vector s tyf f -> Vector s tyg g -- | O(min(m,n)) Zip the two vectors with the monadic action and -- yield a vector of results zipWithM :: (MonadR m, VECTOR (Region m) tya a, VECTOR (Region m) tyb b, VECTOR (Region m) tyc c) => (a -> b -> m c) -> Vector (Region m) tya a -> Vector (Region m) tyb b -> m (Vector (Region m) tyc c) -- | O(min(m,n)) Zip the two vectors with the monadic action and -- ignore the results zipWithM_ :: (Monad m, VECTOR s tya a, VECTOR s tyb b) => (a -> b -> m c) -> Vector s tya a -> Vector s tyb b -> m () -- | O(n) Drop elements that do not satisfy the predicate filter :: VECTOR s ty a => (a -> Bool) -> Vector s ty a -> Vector s ty a -- | O(n) Drop elements that do not satisfy the predicate which is -- applied to values and their indices ifilter :: VECTOR s ty a => (Int -> a -> Bool) -> Vector s ty a -> Vector s ty a -- | O(n) Drop elements that do not satisfy the monadic predicate filterM :: (Monad m, VECTOR s ty a) => (a -> m Bool) -> Vector s ty a -> m (Vector s ty a) -- | O(n) Yield the longest prefix of elements satisfying the -- predicate with copying. takeWhile :: VECTOR s ty a => (a -> Bool) -> Vector s ty a -> Vector s ty a -- | O(n) Drop the longest prefix of elements that satisfy the -- predicate with copying. dropWhile :: VECTOR s ty a => (a -> Bool) -> Vector s ty a -> Vector s ty a -- | O(n) Split the vector in two parts, the first one containing -- those elements that satisfy the predicate and the second one those -- that don't. The relative order of the elements is preserved at the -- cost of a sometimes reduced performance compared to -- unstablePartition. partition :: VECTOR s ty a => (a -> Bool) -> Vector s ty a -> (Vector s ty a, Vector s ty a) -- | O(n) Split the vector in two parts, the first one containing -- those elements that satisfy the predicate and the second one those -- that don't. The order of the elements is not preserved but the -- operation is often faster than partition. unstablePartition :: VECTOR s ty a => (a -> Bool) -> Vector s ty a -> (Vector s ty a, Vector s ty a) -- | O(n) Split the vector into the longest prefix of elements that -- satisfy the predicate and the rest with copying. span :: VECTOR s ty a => (a -> Bool) -> Vector s ty a -> (Vector s ty a, Vector s ty a) -- | O(n) Split the vector into the longest prefix of elements that -- do not satisfy the predicate and the rest with copying. break :: VECTOR s ty a => (a -> Bool) -> Vector s ty a -> (Vector s ty a, Vector s ty a) -- | O(n) Check if the vector contains an element elem :: (VECTOR s ty a, Eq a) => a -> Vector s ty a -> Bool infix 4 `elem` -- | O(n) Check if the vector does not contain an element (inverse -- of elem) notElem :: (VECTOR s ty a, Eq a) => a -> Vector s ty a -> Bool infix 4 `notElem` -- | O(n) Yield Just the first element matching the -- predicate or Nothing if no such element exists. find :: VECTOR s ty a => (a -> Bool) -> Vector s ty a -> Maybe a -- | O(n) Yield Just the index of the first element -- matching the predicate or Nothing if no such element exists. findIndex :: VECTOR s ty a => (a -> Bool) -> Vector s ty a -> Maybe Int -- | O(n) Yield Just the index of the first occurence of -- the given element or Nothing if the vector does not contain -- the element. This is a specialised version of findIndex. elemIndex :: (VECTOR s ty a, Eq a) => a -> Vector s ty a -> Maybe Int -- | O(n) Left fold foldl :: VECTOR s ty b => (a -> b -> a) -> a -> Vector s ty b -> a -- | O(n) Left fold on non-empty vectors foldl1 :: VECTOR s ty a => (a -> a -> a) -> Vector s ty a -> a -- | O(n) Left fold with strict accumulator foldl' :: VECTOR s ty b => (a -> b -> a) -> a -> Vector s ty b -> a -- | O(n) Left fold on non-empty vectors with strict accumulator foldl1' :: VECTOR s ty a => (a -> a -> a) -> Vector s ty a -> a -- | O(n) Right fold foldr :: VECTOR s ty a => (a -> b -> b) -> b -> Vector s ty a -> b -- | O(n) Right fold on non-empty vectors foldr1 :: VECTOR s ty a => (a -> a -> a) -> Vector s ty a -> a -- | O(n) Right fold with a strict accumulator foldr' :: VECTOR s ty a => (a -> b -> b) -> b -> Vector s ty a -> b -- | O(n) Right fold on non-empty vectors with strict accumulator foldr1' :: VECTOR s ty a => (a -> a -> a) -> Vector s ty a -> a -- | O(n) Left fold (function applied to each element and its index) ifoldl :: VECTOR s ty b => (a -> Int -> b -> a) -> a -> Vector s ty b -> a -- | O(n) Left fold with strict accumulator (function applied to -- each element and its index) ifoldl' :: VECTOR s ty b => (a -> Int -> b -> a) -> a -> Vector s ty b -> a -- | O(n) Right fold (function applied to each element and its -- index) ifoldr :: VECTOR s ty a => (Int -> a -> b -> b) -> b -> Vector s ty a -> b -- | O(n) Right fold with strict accumulator (function applied to -- each element and its index) ifoldr' :: VECTOR s ty a => (Int -> a -> b -> b) -> b -> Vector s ty a -> b -- | O(n) Check if all elements satisfy the predicate. all :: VECTOR s ty a => (a -> Bool) -> Vector s ty a -> Bool -- | O(n) Check if any element satisfies the predicate. any :: VECTOR s ty a => (a -> Bool) -> Vector s ty a -> Bool -- | O(n) Compute the sum of the elements sum :: (VECTOR s ty a, Num a) => Vector s ty a -> a -- | O(n) Compute the produce of the elements product :: (VECTOR s ty a, Num a) => Vector s ty a -> a -- | O(n) Yield the maximum element of the vector. The vector may -- not be empty. maximum :: (VECTOR s ty a, Ord a) => Vector s ty a -> a -- | O(n) Yield the maximum element of the Vector s ty according to -- the given comparison function. The vector may not be empty. maximumBy :: VECTOR s ty a => (a -> a -> Ordering) -> Vector s ty a -> a -- | O(n) Yield the minimum element of the vector. The vector may -- not be empty. minimum :: (VECTOR s ty a, Ord a) => Vector s ty a -> a -- | O(n) Yield the minimum element of the Vector s ty according to -- the given comparison function. The vector may not be empty. minimumBy :: VECTOR s ty a => (a -> a -> Ordering) -> Vector s ty a -> a -- | O(n) Yield the index of the minimum element of the vector. The -- vector may not be empty. minIndex :: (VECTOR s ty a, Ord a) => Vector s ty a -> Int -- | O(n) Yield the index of the minimum element of the Vector s ty -- according to the given comparison function. The vector may not be -- empty. minIndexBy :: VECTOR s ty a => (a -> a -> Ordering) -> Vector s ty a -> Int -- | O(n) Yield the index of the maximum element of the vector. The -- vector may not be empty. maxIndex :: (VECTOR s ty a, Ord a) => Vector s ty a -> Int -- | O(n) Yield the index of the maximum element of the Vector s ty -- according to the given comparison function. The vector may not be -- empty. maxIndexBy :: VECTOR s ty a => (a -> a -> Ordering) -> Vector s ty a -> Int -- | O(n) Monadic fold foldM :: (Monad m, VECTOR s ty b) => (a -> b -> m a) -> a -> Vector s ty b -> m a -- | O(n) Monadic fold with strict accumulator foldM' :: (Monad m, VECTOR s ty b) => (a -> b -> m a) -> a -> Vector s ty b -> m a -- | O(n) Monadic fold over non-empty vectors fold1M :: (Monad m, VECTOR s ty a) => (a -> a -> m a) -> Vector s ty a -> m a -- | O(n) Monadic fold over non-empty vectors with strict -- accumulator fold1M' :: (Monad m, VECTOR s ty a) => (a -> a -> m a) -> Vector s ty a -> m a -- | O(n) Monadic fold that discards the result foldM_ :: (Monad m, VECTOR s ty b) => (a -> b -> m a) -> a -> Vector s ty b -> m () -- | O(n) Monadic fold with strict accumulator that discards the -- result foldM'_ :: (Monad m, VECTOR s ty b) => (a -> b -> m a) -> a -> Vector s ty b -> m () -- | O(n) Monadic fold over non-empty vectors that discards the -- result fold1M_ :: (Monad m, VECTOR s ty a) => (a -> a -> m a) -> Vector s ty a -> m () -- | O(n) Monadic fold over non-empty vectors with strict -- accumulator that discards the result fold1M'_ :: (Monad m, VECTOR s ty a) => (a -> a -> m a) -> Vector s ty a -> m () -- | O(n) Prescan -- --
-- prescanl f z = init . scanl f z ---- -- Example: prescanl (+) 0 <1,2,3,4> = <0,1,3,6> prescanl :: (VECTOR s ty a, VECTOR s ty b) => (a -> b -> a) -> a -> Vector s ty b -> Vector s ty a -- | O(n) Prescan with strict accumulator prescanl' :: (VECTOR s ty a, VECTOR s ty b) => (a -> b -> a) -> a -> Vector s ty b -> Vector s ty a -- | O(n) Scan -- --
-- postscanl f z = tail . scanl f z ---- -- Example: postscanl (+) 0 <1,2,3,4> = <1,3,6,10> postscanl :: (VECTOR s ty a, VECTOR s ty b) => (a -> b -> a) -> a -> Vector s ty b -> Vector s ty a -- | O(n) Scan with strict accumulator postscanl' :: (VECTOR s ty a, VECTOR s ty b) => (a -> b -> a) -> a -> Vector s ty b -> Vector s ty a -- | O(n) Haskell-style scan -- --
-- scanl f z <x1,...,xn> = <y1,...,y(n+1)> -- where y1 = z -- yi = f y(i-1) x(i-1) ---- -- Example: scanl (+) 0 <1,2,3,4> = <0,1,3,6,10> scanl :: (VECTOR s ty a, VECTOR s ty b) => (a -> b -> a) -> a -> Vector s ty b -> Vector s ty a -- | O(n) Haskell-style scan with strict accumulator scanl' :: (VECTOR s ty a, VECTOR s ty b) => (a -> b -> a) -> a -> Vector s ty b -> Vector s ty a -- | O(n) Scan over a non-empty vector -- --
-- scanl f <x1,...,xn> = <y1,...,yn> -- where y1 = x1 -- yi = f y(i-1) xi --scanl1 :: VECTOR s ty a => (a -> a -> a) -> Vector s ty a -> Vector s ty a -- | O(n) Scan over a non-empty vector with a strict accumulator scanl1' :: VECTOR s ty a => (a -> a -> a) -> Vector s ty a -> Vector s ty a -- | O(n) Right-to-left prescan -- --
-- prescanr f z = reverse . prescanl (flip f) z . reverse --prescanr :: (VECTOR s ty a, VECTOR s ty b) => (a -> b -> b) -> b -> Vector s ty a -> Vector s ty b -- | O(n) Right-to-left prescan with strict accumulator prescanr' :: (VECTOR s ty a, VECTOR s ty b) => (a -> b -> b) -> b -> Vector s ty a -> Vector s ty b -- | O(n) Right-to-left scan postscanr :: (VECTOR s ty a, VECTOR s ty b) => (a -> b -> b) -> b -> Vector s ty a -> Vector s ty b -- | O(n) Right-to-left scan with strict accumulator postscanr' :: (VECTOR s ty a, VECTOR s ty b) => (a -> b -> b) -> b -> Vector s ty a -> Vector s ty b -- | O(n) Right-to-left Haskell-style scan scanr :: (VECTOR s ty a, VECTOR s ty b) => (a -> b -> b) -> b -> Vector s ty a -> Vector s ty b -- | O(n) Right-to-left Haskell-style scan with strict accumulator scanr' :: (VECTOR s ty a, VECTOR s ty b) => (a -> b -> b) -> b -> Vector s ty a -> Vector s ty b -- | O(n) Right-to-left scan over a non-empty vector scanr1 :: VECTOR s ty a => (a -> a -> a) -> Vector s ty a -> Vector s ty a -- | O(n) Right-to-left scan over a non-empty vector with a strict -- accumulator scanr1' :: VECTOR s ty a => (a -> a -> a) -> Vector s ty a -> Vector s ty a -- | O(n) Convert a vector to a list toList :: VECTOR s ty a => Vector s ty a -> [a] -- | O(n) Convert a list to a vector fromList :: forall s ty a. VECTOR s ty a => [a] -> Vector s ty a -- | O(n) Convert the first n elements of a list to a -- vector -- --
-- fromListN n xs = fromList (take n xs) --fromListN :: forall s ty a. VECTOR s ty a => Int -> [a] -> Vector s ty a -- | O(n) Yield an immutable copy of the mutable vector. freeze :: (MonadR m, VECTOR (Region m) ty a) => MVector (Region m) ty a -> m (Vector (Region m) ty a) -- | O(n) Yield a mutable copy of the immutable vector. thaw :: (MonadR m, VECTOR (Region m) ty a) => Vector (Region m) ty a -> m (MVector (Region m) ty a) -- | O(n) Copy an immutable vector into a mutable one. The two -- vectors must have the same length. copy :: (MonadR m, VECTOR (Region m) ty a) => MVector (Region m) ty a -> Vector (Region m) ty a -> m () -- | O(1) Unsafe convert a mutable vector to an immutable one with -- copying. The mutable vector may not be used after this operation. unsafeFreeze :: (VECTOR (Region m) ty a, MonadR m) => MVector (Region m) ty a -> m (Vector (Region m) ty a) -- | O(1) Unsafely convert an immutable vector to a mutable one with -- copying. The immutable vector may not be used after this operation. unsafeThaw :: (MonadR m, VECTOR (Region m) ty a) => Vector (Region m) ty a -> m (MVector (Region m) ty a) -- | O(n) Copy an immutable vector into a mutable one. The two -- vectors must have the same length. This is not checked. unsafeCopy :: (MonadR m, VECTOR (Region m) ty a) => MVector (Region m) ty a -> Vector (Region m) ty a -> m () -- | O(n) Convert a character vector into a String. toString :: Vector s 'Char Word8 -> String -- | O(n) Convert a character vector into a strict -- ByteString. toByteString :: Vector s 'Char Word8 -> ByteString -- | This function is unsafe and ByteString should not be used outside of -- the function. Any change to bytestring will be reflected in the source -- vector, thus breaking referencial transparancy. unsafeWithByteString :: NFData a => Vector s 'Char Word8 -> (ByteString -> IO a) -> a instance (Data.Reflection.Reifies t (Control.Monad.R.Internal.AcquireIO s), Data.Vector.SEXP.Base.VECTOR s ty a) => Data.Vector.Generic.Base.Vector (Data.Vector.SEXP.W t ty s) a instance (GHC.Classes.Eq a, Data.Vector.SEXP.Base.VECTOR s ty a) => GHC.Classes.Eq (Data.Vector.SEXP.Vector s ty a) instance (GHC.Show.Show a, Data.Vector.SEXP.Base.VECTOR s ty a) => GHC.Show.Show (Data.Vector.SEXP.Vector s ty a) instance Data.Vector.SEXP.Base.VECTOR s ty a => GHC.Exts.IsList (Data.Vector.SEXP.Vector s ty a) -- | Provides a shallow view of a SEXP R value as an -- algebraic datatype. This is useful to define functions over R values -- in Haskell with pattern matching. For example: -- --
-- toPair :: SEXP a -> (SomeSEXP, SomeSEXP) -- toPair (hexp -> List _ (Just car) (Just cdr)) = (SomeSEXP car, SomeSEXP cdr) -- toPair (hexp -> Lang car (Just cdr)) = (SomeSEXP car, SomeSEXP cdr) -- toPair s = error $ "Cannot extract pair from object of type " ++ typeOf s ---- -- (See SomeSEXP for why we need to use it here.) -- -- The view is said to be shallow because it only unfolds the -- head of the R value into an algebraic datatype. In this way, functions -- producing views can be written non-recursively, hence inlined at all -- call sites and simplified away. When produced by a view function in a -- pattern match, allocation of the view can be compiled away and hence -- producing a view can be done at no runtime cost. In fact, pattern -- matching on a view in this way is more efficient than using the -- accessor functions defined in Foreign.R, because we avoid the -- overhead of calling one or more FFI functions entirely. -- -- HExp is the view and hexp is the view -- function that projects SEXPs into HExp views. module Language.R.HExp -- | A view of R's internal SEXP structure as an algebraic datatype. -- Because this is in fact a GADT, the use of named record fields is not -- possible here. Named record fields give rise to functions for whom it -- is not possible to assign a reasonable type (existentially quantified -- type variables would escape). -- -- Note further that Haddock does not currently support constructor -- comments when using the GADT syntax. data HExp :: * -> SEXPTYPE -> * [Nil] :: HExp s 'Nil [Symbol] :: (a :∈ [ 'Char, 'Nil]) => SEXP s a -> SEXP s b -> SEXP s c -> HExp s 'Symbol [List] :: (IsPairList b, c :∈ [ 'Symbol, 'Nil]) => SEXP s a -> SEXP s b -> SEXP s c -> HExp s 'List [Env] :: (IsPairList a, b :∈ [ 'Env, 'Nil], c :∈ [ 'Vector, 'Nil]) => SEXP s a -> SEXP s b -> SEXP s c -> HExp s 'Env [Closure] :: (IsPairList a) => SEXP s a -> SEXP s b -> SEXP s 'Env -> HExp s 'Closure [Promise] :: (IsExpression b, c :∈ [ 'Env, 'Nil]) => SEXP s a -> SEXP s b -> SEXP s c -> HExp s 'Promise [Lang] :: (IsExpression a, IsPairList b) => SEXP s a -> SEXP s b -> HExp s 'Lang [Special] :: {-# UNPACK #-} !Int32 -> HExp s 'Special [Builtin] :: {-# UNPACK #-} !Int32 -> HExp s 'Builtin [Char] :: {-# UNPACK #-} !(Vector s 'Char Word8) -> HExp s 'Char [Logical] :: {-# UNPACK #-} !(Vector s 'Logical Logical) -> HExp s 'Logical [Int] :: {-# UNPACK #-} !(Vector s 'Int Int32) -> HExp s 'Int [Real] :: {-# UNPACK #-} !(Vector s 'Real Double) -> HExp s 'Real [Complex] :: {-# UNPACK #-} !(Vector s 'Complex (Complex Double)) -> HExp s 'Complex [String] :: {-# UNPACK #-} !(Vector s 'String (SEXP s 'Char)) -> HExp s 'String [DotDotDot] :: (IsPairList a) => SEXP s a -> HExp s 'List [Vector] :: {-# UNPACK #-} !Int32 -> {-# UNPACK #-} !(Vector s 'Vector (SomeSEXP s)) -> HExp s 'Vector [Expr] :: {-# UNPACK #-} !Int32 -> {-# UNPACK #-} !(Vector s 'Expr (SomeSEXP s)) -> HExp s 'Expr [Bytecode] :: HExp s 'Bytecode [ExtPtr] :: Ptr () -> SEXP s b -> SEXP s 'Symbol -> HExp s 'ExtPtr [WeakRef] :: (a :∈ [ 'Env, 'ExtPtr, 'Nil], c :∈ [ 'Closure, 'Builtin, 'Special, 'Nil], d :∈ [ 'WeakRef, 'Nil]) => SEXP s a -> SEXP s b -> SEXP s c -> SEXP s d -> HExp s 'WeakRef [Raw] :: {-# UNPACK #-} !(Vector s 'Raw Word8) -> HExp s 'Raw [S4] :: SEXP s a -> HExp s 'S4 -- | Heterogeneous equality. (===) :: TestEquality f => f a -> f b -> Bool -- | A view function projecting a view of SEXP as an algebraic -- datatype, that can be analyzed through pattern matching. hexp :: SEXP s a -> HExp s a -- | Inverse hexp view to the real structure, note that for scalar types -- hexp will allocate new SEXP, and unhexp . hexp is not an -- identity function. however for vector types it will return original -- SEXP. unhexp :: MonadR m => HExp (Region m) a -> m (SEXP (Region m) a) -- | Project the vector out of SEXPs. vector :: IsVector a => SEXP s a -> Vector s a (ElemRep s a) instance Data.Type.Equality.TestEquality (Language.R.HExp.E s) instance Data.Type.Equality.TestEquality (Language.R.HExp.HExp s) instance GHC.Classes.Eq (Language.R.HExp.HExp s a) instance Foreign.Storable.Storable (Language.R.HExp.HExp s a) -- | Debugging facilities, in particular to analyze the internal structure -- of a SEXP as structured JSON. -- -- This module is intended to be imported qualified. module Language.R.Debug inspect :: SEXP s a -> String instance Data.Aeson.Types.ToJSON.ToJSON Foreign.R.Type.SEXPTYPE instance Data.Aeson.Types.ToJSON.ToJSON Foreign.R.Internal.SEXPInfo instance Data.Aeson.Types.ToJSON.ToJSON a => Data.Aeson.Types.ToJSON.ToJSON (Data.Complex.Complex a) instance Data.Aeson.Types.ToJSON.ToJSON (Foreign.R.Internal.SEXP s a) instance Data.Aeson.Types.ToJSON.ToJSON (Foreign.R.Internal.SomeSEXP s) -- | Interaction with an instance of R. The interface in this module allows -- for instantiating an arbitrary number of concurrent R sessions, even -- though currently the R library only allows for one global instance, -- for forward compatibility. -- -- The R monad defined here serves to give static guarantees that -- an instance is only ever used after it has been initialized and before -- it is finalized. Doing otherwise should result in a type error. This -- is done in the same way that the ST monad encapsulates side -- effects: by assigning a rank-2 type to the only run function for the -- monad. -- -- This module is intended to be imported qualified. module Language.R.Instance -- | The R monad, for sequencing actions interacting with a single -- instance of the R interpreter, much as the IO monad sequences -- actions interacting with the real world. The R monad embeds the -- IO monad, so all IO actions can be lifted to R -- actions. data R s a -- | Run an R action in the global R instance from the IO monad. This -- action provides no static guarantees that the R instance was indeed -- initialized and has not yet been finalized. Make sure to call it -- within the scope of withEmbeddedR. -- -- runRegion m fully evaluates the result of action m, -- to ensure that no thunks hold onto resources in a way that would -- extrude the scope of the region. This means that the result must be -- first-order data (i.e. not a function). runRegion :: NFData a => (forall s. R s a) -> IO a unsafeRunRegion :: NFData a => R s a -> IO a -- | Configuration options for the R runtime. Configurations form monoids, -- so arguments can be accumulated left-to-right through monoidal -- composition. data Config Config :: Last String -> [String] -> Last Bool -> Config -- | Program name. If Nothing then the value of getProgName -- will be used. [configProgName] :: Config -> Last String -- | Command-line arguments. [configArgs] :: Config -> [String] -- | Set to True if you're happy to let R install its own signal -- handlers during initialization. By default R sets following signal -- handlers: -- --
-- main = withEmbeddedR $ do {...}
--
--
-- Note that R does not currently support reinitialization after
-- finalization, so this function should be called only once during the
-- lifetime of the program (see
-- srcunixsystem.c:Rf_initialize() in the R source code).
withEmbeddedR :: Config -> IO a -> IO a
-- | Create a new embedded instance of the R interpreter. Only works from
-- the main thread of the program. That is, from the same thread of
-- execution that the program's main function is running on. In
-- GHCi, use -fno-ghci-sandbox to achieve this.
initialize :: Config -> IO ()
-- | Finalize an R instance.
finalize :: IO ()
instance Control.Monad.Catch.MonadThrow (Language.R.Instance.R s)
instance Control.Monad.Catch.MonadMask (Language.R.Instance.R s)
instance Control.Monad.Catch.MonadCatch (Language.R.Instance.R s)
instance Control.Monad.IO.Class.MonadIO (Language.R.Instance.R s)
instance GHC.Base.Monad (Language.R.Instance.R s)
instance GHC.Base.Functor (Language.R.Instance.R s)
instance GHC.Base.Applicative (Language.R.Instance.R s)
instance Data.Default.Class.Default Language.R.Instance.Config
instance Data.Semigroup.Semigroup Language.R.Instance.Config
instance GHC.Base.Monoid Language.R.Instance.Config
instance Control.Monad.Primitive.PrimMonad (Language.R.Instance.R s)
instance Control.Monad.R.Class.MonadR (Language.R.Instance.R s)
module Language.R.Internal.FunWrappers.TH
-- | Generate wrappers from n to m.
thWrappers :: Int -> Int -> Q [Dec]
-- | Generate wrapper.
--
-- Example for input 5:
--
-- -- foreign import ccall "wrapper" wrap5 -- :: ( SEXP a -> SEXP b -> SEXP c -- -> SEXP d -> SEXP e -> IO (SEXP f) -- ) -- -> IO (FunPtr ( SEXP a -> SEXP b -> SEXP c -- -> SEXP d -> SEXP e -> IO (SEXP f) -- ) -- ) --thWrapper :: Int -> Q Dec -- | Generate Literal Instance for wrapper. -- -- Example for input 6: instance ( Literal a a0, Literal b b0, -- Literal c c0, Literal d d0, Literal e e0 , Literal f f0, Literal g g0 -- ) => Literal (a -> b -> c -> d -> e -> f -> IO g) -- R.ExtPtr where mkSEXP = funToSEXP wrap6 fromSEXP = error -- "Unimplemented." thWrapperLiteral :: Int -> Q Dec thWrapperLiterals :: Int -> Int -> Q [Dec] -- | Helpers for passing functions pointers between Haskell and R. module Language.R.Internal.FunWrappers wrap0 :: IO SEXP0 -> IO (FunPtr (IO SEXP0)) wrap1 :: (SEXP0 -> IO SEXP0) -> IO (FunPtr (SEXP0 -> IO SEXP0)) wrap2 :: (SEXP0 -> SEXP0 -> IO SEXP0) -> IO (FunPtr (SEXP0 -> SEXP0 -> IO SEXP0)) wrap3 :: (SEXP0 -> SEXP0 -> SEXP0 -> IO SEXP0) -> IO (FunPtr (SEXP0 -> SEXP0 -> SEXP0 -> IO SEXP0)) wrap12 :: (SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> IO SEXP0) -> IO (FunPtr (SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> IO SEXP0)) wrap11 :: (SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> IO SEXP0) -> IO (FunPtr (SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> IO SEXP0)) wrap10 :: (SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> IO SEXP0) -> IO (FunPtr (SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> IO SEXP0)) wrap9 :: (SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> IO SEXP0) -> IO (FunPtr (SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> IO SEXP0)) wrap8 :: (SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> IO SEXP0) -> IO (FunPtr (SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> IO SEXP0)) wrap7 :: (SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> IO SEXP0) -> IO (FunPtr (SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> IO SEXP0)) wrap6 :: (SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> IO SEXP0) -> IO (FunPtr (SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> IO SEXP0)) wrap5 :: (SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> IO SEXP0) -> IO (FunPtr (SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> IO SEXP0)) wrap4 :: (SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> IO SEXP0) -> IO (FunPtr (SEXP0 -> SEXP0 -> SEXP0 -> SEXP0 -> IO SEXP0)) module Language.R.Literal -- | Values that can be converted to SEXP. class SingI ty => Literal a ty | a -> ty -- | Internal function for converting a literal to a SEXP value. You -- probably want to be using mkSEXP instead. mkSEXPIO :: Literal a ty => a -> IO (SEXP V ty) fromSEXP :: Literal a ty => SEXP s ty -> a -- | Internal function for converting a literal to a SEXP value. You -- probably want to be using mkSEXP instead. mkSEXPIO :: (Literal a ty, IsVector ty, Literal [a] ty) => a -> IO (SEXP V ty) fromSEXP :: (Literal a ty, IsVector ty, Literal [a] ty) => SEXP s ty -> a -- | Create a pairlist from an association list. Result is either a -- pairlist or nilValue if the input is the null list. These are -- two distinct forms. Hence why the type of this function is not more -- precise. toPairList :: MonadR m => [(String, SomeSEXP (Region m))] -> m (SomeSEXP (Region m)) -- | Create an association list from a pairlist. R Pairlists are -- nil-terminated chains of nested cons cells, as in LISP. fromPairList :: SomeSEXP s -> [(String, SomeSEXP s)] -- | Like fromSEXP, but with no static type satefy. Performs a -- dynamic (i.e. at runtime) check instead. fromSomeSEXP :: forall s a form. (Literal a form) => SomeSEXP s -> a -- | Create a SEXP value and protect it in current region mkSEXP :: (Literal a b, MonadR m) => a -> m (SEXP (Region m) b) -- | Like fromSomeSEXP, but behaves like the as.* family of -- functions in R, by performing a best effort conversion to the target -- form (e.g. rounds reals to integers, etc) for atomic types. dynSEXP :: forall a s ty. (Literal a ty) => SomeSEXP s -> a mkSEXPVector :: (Storable (ElemRep s a), IsVector a) => SSEXPTYPE a -> [IO (ElemRep s a)] -> SEXP s a mkSEXPVectorIO :: (Storable (ElemRep s a), IsVector a) => SSEXPTYPE a -> [IO (ElemRep s a)] -> IO (SEXP s a) mkProtectedSEXPVector :: IsVector b => SSEXPTYPE b -> [SEXP s a] -> SEXP s b mkProtectedSEXPVectorIO :: IsVector b => SSEXPTYPE b -> [SEXP s a] -> IO (SEXP s b) funToSEXP :: HFunWrap a b => (b -> IO (FunPtr b)) -> a -> IO (SEXP s 'ExtPtr) instance (Control.DeepSeq.NFData a1, Language.R.Literal.Literal a2 i1, Language.R.Literal.Literal a3 i2, Language.R.Literal.Literal a4 i3, Language.R.Literal.Literal a1 i4) => Language.R.Literal.Literal (a2 -> a3 -> a4 -> Language.R.Instance.R s a1) 'Foreign.R.Type.ExtPtr instance (Control.DeepSeq.NFData a1, Language.R.Literal.Literal a2 i1, Language.R.Literal.Literal a3 i2, Language.R.Literal.Literal a4 i3, Language.R.Literal.Literal a5 i4, Language.R.Literal.Literal a1 i5) => Language.R.Literal.Literal (a2 -> a3 -> a4 -> a5 -> Language.R.Instance.R s a1) 'Foreign.R.Type.ExtPtr instance (Control.DeepSeq.NFData a1, Language.R.Literal.Literal a2 i1, Language.R.Literal.Literal a3 i2, Language.R.Literal.Literal a4 i3, Language.R.Literal.Literal a5 i4, Language.R.Literal.Literal a6 i5, Language.R.Literal.Literal a1 i6) => Language.R.Literal.Literal (a2 -> a3 -> a4 -> a5 -> a6 -> Language.R.Instance.R s a1) 'Foreign.R.Type.ExtPtr instance (Control.DeepSeq.NFData a1, Language.R.Literal.Literal a2 i1, Language.R.Literal.Literal a3 i2, Language.R.Literal.Literal a4 i3, Language.R.Literal.Literal a5 i4, Language.R.Literal.Literal a6 i5, Language.R.Literal.Literal a7 i6, Language.R.Literal.Literal a1 i7) => Language.R.Literal.Literal (a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> Language.R.Instance.R s a1) 'Foreign.R.Type.ExtPtr instance (Control.DeepSeq.NFData a1, Language.R.Literal.Literal a2 i1, Language.R.Literal.Literal a3 i2, Language.R.Literal.Literal a4 i3, Language.R.Literal.Literal a5 i4, Language.R.Literal.Literal a6 i5, Language.R.Literal.Literal a7 i6, Language.R.Literal.Literal a8 i7, Language.R.Literal.Literal a1 i8) => Language.R.Literal.Literal (a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> Language.R.Instance.R s a1) 'Foreign.R.Type.ExtPtr instance (Control.DeepSeq.NFData a1, Language.R.Literal.Literal a2 i1, Language.R.Literal.Literal a3 i2, Language.R.Literal.Literal a4 i3, Language.R.Literal.Literal a5 i4, Language.R.Literal.Literal a6 i5, Language.R.Literal.Literal a7 i6, Language.R.Literal.Literal a8 i7, Language.R.Literal.Literal a9 i8, Language.R.Literal.Literal a1 i9) => Language.R.Literal.Literal (a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> a9 -> Language.R.Instance.R s a1) 'Foreign.R.Type.ExtPtr instance (Control.DeepSeq.NFData a1, Language.R.Literal.Literal a2 i1, Language.R.Literal.Literal a3 i2, Language.R.Literal.Literal a4 i3, Language.R.Literal.Literal a5 i4, Language.R.Literal.Literal a6 i5, Language.R.Literal.Literal a7 i6, Language.R.Literal.Literal a8 i7, Language.R.Literal.Literal a9 i8, Language.R.Literal.Literal a10 i9, Language.R.Literal.Literal a1 i10) => Language.R.Literal.Literal (a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> a9 -> a10 -> Language.R.Instance.R s a1) 'Foreign.R.Type.ExtPtr instance (Control.DeepSeq.NFData a1, Language.R.Literal.Literal a2 i1, Language.R.Literal.Literal a3 i2, Language.R.Literal.Literal a4 i3, Language.R.Literal.Literal a5 i4, Language.R.Literal.Literal a6 i5, Language.R.Literal.Literal a7 i6, Language.R.Literal.Literal a8 i7, Language.R.Literal.Literal a9 i8, Language.R.Literal.Literal a10 i9, Language.R.Literal.Literal a11 i10, Language.R.Literal.Literal a1 i11) => Language.R.Literal.Literal (a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> a9 -> a10 -> a11 -> Language.R.Instance.R s a1) 'Foreign.R.Type.ExtPtr instance (Control.DeepSeq.NFData a1, Language.R.Literal.Literal a2 i1, Language.R.Literal.Literal a3 i2, Language.R.Literal.Literal a4 i3, Language.R.Literal.Literal a5 i4, Language.R.Literal.Literal a6 i5, Language.R.Literal.Literal a7 i6, Language.R.Literal.Literal a8 i7, Language.R.Literal.Literal a9 i8, Language.R.Literal.Literal a10 i9, Language.R.Literal.Literal a11 i10, Language.R.Literal.Literal a12 i11, Language.R.Literal.Literal a1 i12) => Language.R.Literal.Literal (a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> a9 -> a10 -> a11 -> a12 -> Language.R.Instance.R s a1) 'Foreign.R.Type.ExtPtr instance (Control.DeepSeq.NFData a1, Language.R.Literal.Literal a2 i1, Language.R.Literal.Literal a3 i2, Language.R.Literal.Literal a4 i3, Language.R.Literal.Literal a5 i4, Language.R.Literal.Literal a6 i5, Language.R.Literal.Literal a7 i6, Language.R.Literal.Literal a8 i7, Language.R.Literal.Literal a9 i8, Language.R.Literal.Literal a10 i9, Language.R.Literal.Literal a11 i10, Language.R.Literal.Literal a12 i11, Language.R.Literal.Literal a13 i12, Language.R.Literal.Literal a1 i13) => Language.R.Literal.Literal (a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> a9 -> a10 -> a11 -> a12 -> a13 -> Language.R.Instance.R s a1) 'Foreign.R.Type.ExtPtr instance (Control.DeepSeq.NFData a, Language.R.Literal.Literal a la) => Language.R.Literal.HFunWrap (Language.R.Instance.R s a) (GHC.Types.IO Foreign.R.Context.SEXP0) instance (Language.R.Literal.Literal a la, Language.R.Literal.HFunWrap b wb) => Language.R.Literal.HFunWrap (a -> b) (Foreign.R.Context.SEXP0 -> wb) instance Language.R.Literal.Literal [Foreign.R.Context.Logical] 'Foreign.R.Type.Logical instance Language.R.Literal.Literal [GHC.Int.Int32] 'Foreign.R.Type.Int instance Language.R.Literal.Literal [GHC.Types.Double] 'Foreign.R.Type.Real instance Language.R.Literal.Literal [Data.Complex.Complex GHC.Types.Double] 'Foreign.R.Type.Complex instance Language.R.Literal.Literal [GHC.Base.String] 'Foreign.R.Type.String instance Language.R.Literal.Literal Data.Text.Internal.Text 'Foreign.R.Type.String instance Language.R.Literal.Literal Foreign.R.Context.Logical 'Foreign.R.Type.Logical instance Language.R.Literal.Literal GHC.Int.Int32 'Foreign.R.Type.Int instance Language.R.Literal.Literal GHC.Types.Double 'Foreign.R.Type.Real instance Language.R.Literal.Literal (Data.Complex.Complex GHC.Types.Double) 'Foreign.R.Type.Complex instance Language.R.Literal.Literal GHC.Base.String 'Foreign.R.Type.String instance Data.Vector.SEXP.Base.VECTOR Control.Memory.Region.V ty a => Language.R.Literal.Literal (Data.Vector.SEXP.Vector Control.Memory.Region.V ty a) ty instance Data.Vector.SEXP.Base.VECTOR Control.Memory.Region.V ty a => Language.R.Literal.Literal (Data.Vector.SEXP.Mutable.Internal.MVector Control.Memory.Region.V ty a) ty instance Data.Singletons.SingI a => Language.R.Literal.Literal (Foreign.R.Internal.SEXP s a) a instance Language.R.Literal.Literal (Foreign.R.Internal.SomeSEXP s) 'Foreign.R.Type.Any instance (Control.DeepSeq.NFData a, Language.R.Literal.Literal a b) => Language.R.Literal.Literal (Language.R.Instance.R s a) 'Foreign.R.Type.ExtPtr instance (Control.DeepSeq.NFData b, Language.R.Literal.Literal a a0, Language.R.Literal.Literal b b0) => Language.R.Literal.Literal (a -> Language.R.Instance.R s b) 'Foreign.R.Type.ExtPtr instance (Control.DeepSeq.NFData c, Language.R.Literal.Literal a a0, Language.R.Literal.Literal b b0, Language.R.Literal.Literal c c0) => Language.R.Literal.Literal (a -> b -> Language.R.Instance.R s c) 'Foreign.R.Type.ExtPtr -- | Wrappers for low-level R functions. module Language.R -- | Evaluate a (sequence of) expression(s) in the global environment. eval :: MonadR m => SEXP s a -> m (SomeSEXP (Region m)) -- | Silent version of eval function that discards it's result. eval_ :: MonadR m => SEXP s a -> m () -- | Evaluate a (sequence of) expression(s) in the given environment, -- returning the value of the last. evalEnv :: MonadR m => SEXP s a -> SEXP s 'Env -> m (SomeSEXP (Region m)) -- | Internalize a symbol name. install :: MonadR m => String -> m (SEXP V 'Symbol) -- | Cancel any ongoing R computation in the current process. After -- interruption an RError exception will be raised. -- -- This call is safe to run in any thread. If there is no R computation -- running, the next computaion will be immediately cancelled. Note that -- R will only interrupt computations at so-called "safe points" (in -- particular, not in the middle of a C call). cancel :: IO () -- | Throw an R error as an exception. throwR :: MonadR m => SEXP s 'Env -> m a -- | Throw an R exception with specified message. throwRMessage :: MonadR m => String -> m a -- | Parse file and perform some actions on parsed file. -- -- This function uses continuation because this is an easy way to make -- operations GC-safe. -- | Deprecated: Use [r| parse(file="pathtofile") |] instead. parseFile :: FilePath -> (SEXP s 'Expr -> IO a) -> IO a -- | Deprecated: Use [r| parse(text=...) |] instead. parseText :: String -> Bool -> IO (SEXP V 'Expr) -- | Create an R character string from a Haskell string. -- | Deprecated: Use mkSEXP instead string :: String -> IO (SEXP V 'Char) -- | Create an R string vector from a Haskell string. -- | Deprecated: Use mkSEXP instead strings :: String -> IO (SEXP V 'String) module Language.R.Internal -- | Call a pure unary R function of the given name in the global -- environment. r1 :: ByteString -> SEXP s a -> IO (SomeSEXP V) -- | Call a pure binary R function. See r1 for additional comments. r2 :: ByteString -> SEXP s a -> SEXP s b -> IO (SomeSEXP V) -- | Internalize a symbol name. installIO :: String -> IO (SEXP V 'Symbol) module Language.R.QQ -- | An R value, expressed as an R expression, in R's syntax. r :: QuasiQuoter -- | Quasiquoter for pure R code (no side effects) and that does not depend -- on the global environment (referential transparency). This means that -- all symbols must appear qualified with a package namespace (whose -- bindings are locked by default), the code must not affect R shared -- state in any way, including the global environment, and must not -- perform I/O. rsafe :: QuasiQuoter -- | | Copyright: (C) 2013 Amgen, Inc. -- -- DEPRECATED: use Language.R instead. module H.Prelude -- | The class of R interaction monads. For safety, in compiled code we -- normally use the R monad. For convenience, in a GHCi session, -- we normally use the IO monad directly (by means of a -- MonadR instance for IO, imported only in GHCi). class (Applicative m, MonadIO m, MonadCatch m, MonadMask m, PrimMonad m) => MonadR m where { data family ExecContext m :: *; } -- | Lift an IO action. io :: MonadR m => IO a -> m a -- | Acquire ownership in the current region of the given object. This -- means that the liveness of the object is guaranteed so long as the -- current region remains active (the R garbage collector will not -- attempt to free it). acquire :: (MonadR m, s ~ V) => SEXP s a -> m (SEXP (Region m) a) -- | Acquire ownership in the current region of the given object. This -- means that the liveness of the object is guaranteed so long as the -- current region remains active (the R garbage collector will not -- attempt to free it). acquire :: (MonadR m, MonadIO m, Region m ~ G) => SEXP s a -> m (SEXP (Region m) a) -- | Get the current execution context. getExecContext :: MonadR m => m (ExecContext m) -- | Provides no static guarantees that resources do not extrude the scope -- of their region. Acquired resources are not freed automatically upon -- exit. For internal use only. unsafeRunWithExecContext :: MonadR m => m a -> ExecContext m -> IO a type Region m = PrimState m -- | acquire for SomeSEXP. acquireSome :: (MonadR m) => SomeSEXP V -> m (SomeSEXP (Region m)) -- | A Matcher lets you match SEXP values against composable -- patterns, where cascading cases would otherwise be necessary -- otherwise. -- -- Example: -- --
-- -- Check that input is an S3 object of class "matrix" -- -- and return the value of the "dim" attribute. -- isMatrix = matchOnly $ do -- s3 ["matrix"] -- dim --module Language.R.Matcher -- | A composition of SEXP destructors. A Matcher is bound to -- the region where SomeSEXP is allocated, so extracted value will -- not leak out of the region scope. -- -- This matcher is a pure function, so if you need to allocate any object -- (for example for comparison or lookup) you should do it before running -- matcher. newtype Matcher s a Matcher :: (forall r. SomeSEXP s -> (a -> r) -> (MatcherError s -> r) -> r) -> Matcher s a [runMatcher] :: Matcher s a -> forall r. SomeSEXP s -> (a -> r) -> (MatcherError s -> r) -> r -- | Match a SomeSEXP, returning a MatchError if matching -- failed. -- -- Result is always fully evaluated, since otherwise it wouldn't be -- possible to guarantee that thunks in the return value will not escape -- the memory region. matchOnly :: (MonadR m, NFData a) => Matcher s a -> SomeSEXP s -> m (Either (MatcherError s) a) -- | Returns current SomeSEXP. Never fails. somesexp :: Matcher s (SomeSEXP s) -- | Returns current SEXP if it is of the requested type, fails -- otherwise, returns TypeMissmatch in that case. sexp :: SSEXPTYPE ty -> Matcher s (SEXP s ty) -- | Run a submatcher on another SomeSEXP. All exceptions in the -- internal matcher are propagated to the parent one. This combinator -- allows to inspect nested structures without exiting the matcher, so -- it's possible to effectively combine it with alternative function. with :: SomeSEXP s -> Matcher s a -> Matcher s a -- | hexp lifted to Matcher, applies hexp to the current value and -- allows you to run internal matcher on it. Is useful when you need to -- inspect data using high level functions from Language.R. hexp :: SSEXPTYPE ty -> (HExp s ty -> Matcher s a) -> Matcher s a -- | Succeeds if current SomeSEXP is Null. null :: Matcher s () -- | Succeeds if current SomeSEXP is S4 object. This check is more -- accurate then using guardType S4 as it uses internal R's -- function to check if the object is S4. s4 :: Matcher s () -- | Succeeds if SomeSEXP is an S3 object of the given type. In -- general case it's better to use getS3Class because it will run -- same check, but also will return the class(es) of the current -- expression. -- -- This test is not expressible in terms of the guardType, because -- guardType does not see additional information about S3 types. And any -- raw object can be a class instance. s3 :: [String] -> Matcher s () -- | Continue execution if SEXP have required type. This check tests basic -- types of the expression like if it's integer, or real or character -- vector and such. If you need to test object type use s3 or -- s4 directly. guardType :: SEXPTYPE -> Matcher s () -- | Returns type of the current SEXP. Can never fail. typeOf :: Matcher s SEXPTYPE -- | Return the class of the S3 object, fails otherwise. getS3Class :: Matcher s [String] -- | Returns any attribute by its name if it exists. Fails with -- NoSuchAttribute otherwise. someAttribute :: String -> Matcher s (SomeSEXP s) -- | Typed version of the someAttribute call. In addition to -- retrieving value it's dynamically type checked. attribute :: SSEXPTYPE a -> String -> Matcher s (SEXP s a) -- | Match all attributes, takes a matcher and applies it to the each -- attribute exists, returns list of the attribute name, together with -- matcher result. If matcher returns Nothing - result is -- omitted.. attributes :: Matcher s (Maybe a) -> Matcher s [(String, a)] -- | Find an attribute in attribute list if it exists. lookupAttribute :: String -> Matcher s (Maybe (SomeSEXP s)) -- | Get names attribute. names :: Matcher s [String] -- | Get dim attribute. dim :: Matcher s [Int] -- | Get dimnames attribute. dimnames :: Matcher s [[String]] -- | Get rownames attribute. rownames :: Matcher s [String] -- | Match a factor. Returns the levels of the factor. factor :: Matcher s [String] -- | Convert String SEXP to the list of Strings. charList :: SEXP s 'String -> [String] -- | Execute first matcher that will not fail. choice :: [Matcher s a] -> Matcher s a -- | Matches a List object. list :: Int -> Matcher s a -> Matcher s [a] instance GHC.Generics.Generic (Language.R.Matcher.MatcherError s) instance GHC.Show.Show (Language.R.Matcher.MatcherError s) instance GHC.Base.Monad (Language.R.Matcher.Matcher s) instance GHC.Base.Applicative (Language.R.Matcher.Matcher s) instance GHC.Base.Functor (Language.R.Matcher.Matcher s) instance GHC.Base.Alternative (Language.R.Matcher.Matcher s) instance Data.Semigroup.Semigroup (Language.R.Matcher.MatcherError s) instance GHC.Base.Monoid (Language.R.Matcher.MatcherError s) instance Control.DeepSeq.NFData (Language.R.Matcher.MatcherError s) -- | This class is not meant to be imported in any other circumstance than -- in a GHCi session. module H.Prelude.Interactive class PrintR a printR :: (PrintR a, MonadR m) => a -> m () -- | A form of the printR function that is more convenient in an -- interactive session. p :: (MonadR m, PrintR a) => m a -> m () -- | A form of the printR function that is more convenient in an -- interactive session. -- | Deprecated: Use p instead. printQuote :: (MonadR m, PrintR a) => m a -> m () instance H.Prelude.Interactive.PrintR (Foreign.R.Internal.SEXP s a) instance H.Prelude.Interactive.PrintR (Foreign.R.Internal.SomeSEXP s) instance Control.Monad.R.Class.MonadR GHC.Types.IO