Copyright | (C) 2013 Amgen Inc. |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
H.Prelude.Interactive
Contents
Description
This class is not meant to be imported in any other circumstance than in a GHCi session.
Synopsis
- vector :: forall (a :: SEXPTYPE) s. IsVector a => SEXP s a -> Vector a (ElemRep V a)
- data HExp a (b :: SEXPTYPE) where
- Nil :: forall a. HExp a 'Nil
- Symbol :: forall (a1 :: SEXPTYPE) a (b1 :: SEXPTYPE) (c :: SEXPTYPE). a1 :∈ '['Char, 'Nil] => SEXP a a1 -> SEXP a b1 -> SEXP a c -> HExp a 'Symbol
- List :: forall (b1 :: SEXPTYPE) (c :: SEXPTYPE) a (a1 :: SEXPTYPE). (IsPairList b1, c :∈ '['Symbol, 'Nil]) => SEXP a a1 -> SEXP a b1 -> SEXP a c -> HExp a 'List
- Env :: forall (a1 :: SEXPTYPE) (b1 :: SEXPTYPE) (c :: SEXPTYPE) a. (IsPairList a1, b1 :∈ '['Env, 'Nil], c :∈ '['Vector, 'Nil]) => SEXP a a1 -> SEXP a b1 -> SEXP a c -> HExp a 'Env
- Closure :: forall (a1 :: SEXPTYPE) a (b1 :: SEXPTYPE). IsPairList a1 => SEXP a a1 -> SEXP a b1 -> SEXP a 'Env -> HExp a 'Closure
- Promise :: forall (b1 :: SEXPTYPE) (c :: SEXPTYPE) a (a1 :: SEXPTYPE). (IsExpression b1, c :∈ '['Env, 'Nil]) => SEXP a a1 -> SEXP a b1 -> SEXP a c -> HExp a 'Promise
- Lang :: forall (a1 :: SEXPTYPE) (b1 :: SEXPTYPE) a. (IsExpression a1, IsPairList b1) => SEXP a a1 -> SEXP a b1 -> HExp a 'Lang
- Special :: forall a. HExp a 'Special
- Builtin :: forall a. HExp a 'Builtin
- Char :: forall a. !(Vector 'Char Word8) -> HExp a 'Char
- Logical :: forall a. !(Vector 'Logical Logical) -> HExp a 'Logical
- Int :: forall a. !(Vector 'Int Int32) -> HExp a 'Int
- Real :: forall a. !(Vector 'Real Double) -> HExp a 'Real
- Complex :: forall a. !(Vector 'Complex (Complex Double)) -> HExp a 'Complex
- String :: forall a. !(Vector 'String (SEXP V 'Char)) -> HExp a 'String
- DotDotDot :: forall (a1 :: SEXPTYPE) a. IsPairList a1 => SEXP a a1 -> HExp a 'List
- Vector :: forall a. !Int32 -> !(Vector 'Vector (SomeSEXP V)) -> HExp a 'Vector
- Expr :: forall a. !Int32 -> !(Vector 'Expr (SomeSEXP V)) -> HExp a 'Expr
- Bytecode :: forall a. HExp a 'Bytecode
- ExtPtr :: forall (c :: SEXPTYPE) a (b1 :: SEXPTYPE). c :∈ '['Symbol, 'Nil] => Ptr () -> SEXP a b1 -> SEXP a c -> HExp a 'ExtPtr
- WeakRef :: forall (a1 :: SEXPTYPE) (c :: SEXPTYPE) (d :: SEXPTYPE) a (b1 :: SEXPTYPE). (a1 :∈ '['Env, 'ExtPtr, 'Nil], c :∈ '['Closure, 'Builtin, 'Special, 'Nil], d :∈ '['WeakRef, 'Nil]) => SEXP a a1 -> SEXP a b1 -> SEXP a c -> SEXP a d -> HExp a 'WeakRef
- Raw :: forall a. !(Vector 'Raw Word8) -> HExp a 'Raw
- S4 :: forall (a1 :: SEXPTYPE) a. a1 :∈ '['Symbol, 'Nil] => SEXP a a1 -> HExp a 'S4
- (===) :: forall {k} f (a :: k) (b :: k). TestEquality f => f a -> f b -> Bool
- data R s a
- string :: String -> IO (SEXP V 'Char)
- typeOf :: forall s (a :: SEXPTYPE). SEXP s a -> SEXPTYPE
- type IsList (a :: SEXPTYPE) = (SingI a, a :∈ '['Char, 'Logical, 'Int, 'Real, 'Complex, 'String, 'Vector, 'Expr, 'WeakRef, 'Raw, 'List])
- asTypeOf :: forall s (a :: SEXPTYPE). SomeSEXP s -> SEXP s a -> SEXP s a
- unsafeCoerce :: forall s (a :: SEXPTYPE) (b :: SEXPTYPE). SEXP s a -> SEXP s b
- data SSEXPTYPE (a :: SEXPTYPE) where
- SNil :: SSEXPTYPE 'Nil
- SSymbol :: SSEXPTYPE 'Symbol
- SList :: SSEXPTYPE 'List
- SClosure :: SSEXPTYPE 'Closure
- SEnv :: SSEXPTYPE 'Env
- SPromise :: SSEXPTYPE 'Promise
- SLang :: SSEXPTYPE 'Lang
- SSpecial :: SSEXPTYPE 'Special
- SBuiltin :: SSEXPTYPE 'Builtin
- SChar :: SSEXPTYPE 'Char
- SLogical :: SSEXPTYPE 'Logical
- SInt :: SSEXPTYPE 'Int
- SReal :: SSEXPTYPE 'Real
- SComplex :: SSEXPTYPE 'Complex
- SString :: SSEXPTYPE 'String
- SDotDotDot :: SSEXPTYPE 'DotDotDot
- SAny :: SSEXPTYPE 'Any
- SVector :: SSEXPTYPE 'Vector
- SExpr :: SSEXPTYPE 'Expr
- SBytecode :: SSEXPTYPE 'Bytecode
- SExtPtr :: SSEXPTYPE 'ExtPtr
- SWeakRef :: SSEXPTYPE 'WeakRef
- SRaw :: SSEXPTYPE 'Raw
- SS4 :: SSEXPTYPE 'S4
- SNew :: SSEXPTYPE 'New
- SFree :: SSEXPTYPE 'Free
- SFun :: SSEXPTYPE 'Fun
- cast :: forall (a :: SEXPTYPE) s. SSEXPTYPE a -> SomeSEXP s -> SEXP s a
- finalize :: IO ()
- type family Sing :: k -> Type
- type Region (m :: Type -> Type) = PrimState m
- data SEXP s (a :: SEXPTYPE)
- class SingI ty => Literal a (ty :: SEXPTYPE) | a -> ty where
- data SomeSEXP s = SomeSEXP !(SEXP s a)
- unSomeSEXP :: SomeSEXP s -> (forall (a :: SEXPTYPE). SEXP s a -> r) -> r
- install :: MonadR m => String -> m (SEXP V 'Symbol)
- eval :: forall m s (a :: SEXPTYPE). MonadR m => SEXP s a -> m (SomeSEXP (Region m))
- isRInteractive :: Ptr CInt
- nilValue :: SEXP G 'Nil
- unboundValue :: SEXP G 'Symbol
- missingArg :: SEXP G 'Symbol
- baseEnv :: SEXP G 'Env
- emptyEnv :: SEXP G 'Env
- globalEnv :: SEXP G 'Env
- data Logical
- data RError = RError String
- type PairList = 'List
- type IsVector (a :: SEXPTYPE) = (SingI a, a :∈ '['Char, 'Logical, 'Int, 'Real, 'Complex, 'String, 'Vector, 'Expr, 'WeakRef, 'Raw])
- type IsGenericVector (a :: SEXPTYPE) = (SingI a, a :∈ '['Vector, 'Expr, 'WeakRef])
- type IsPairList (a :: SEXPTYPE) = (SingI a, a :∈ '['List, 'Nil])
- type IsExpression (a :: SEXPTYPE) = (SingI a, a :∈ '['Lang, 'Expr, 'Symbol])
- refresh :: MonadR m => m ()
- eval_ :: forall m s (a :: SEXPTYPE). MonadR m => SEXP s a -> m ()
- evalEnv :: forall m s (a :: SEXPTYPE). MonadR m => SEXP s a -> SEXP s 'Env -> m (SomeSEXP (Region m))
- cancel :: IO ()
- throwR :: MonadR m => SEXP s 'Env -> m a
- throwRMessage :: MonadR m => String -> m a
- parseFile :: FilePath -> (SEXP s 'Expr -> IO a) -> IO a
- parseText :: String -> Bool -> IO (SEXP V 'Expr)
- strings :: String -> IO (SEXP V 'String)
- automatic :: forall m s (a :: SEXPTYPE). MonadR m => SEXP s a -> m (SEXP G a)
- automaticSome :: MonadR m => SomeSEXP s -> m (SomeSEXP G)
- signalHandlersPtr :: Ptr CInt
- inputHandlers :: Ptr InputHandler
- pokeRVariables :: RVariables -> IO ()
- hexp :: forall s (a :: SEXPTYPE). SEXP s a -> HExp s a
- runRegion :: NFData a => (forall s. R s a) -> IO a
- unsafeRunRegion :: NFData a => R s a -> IO a
- data Config = Config {}
- defaultConfig :: Config
- initialize :: Config -> IO ()
- toPairList :: MonadR m => [(String, SomeSEXP (Region m))] -> m (SomeSEXP (Region m))
- fromPairList :: SomeSEXP s -> [(String, SomeSEXP s)]
- fromSomeSEXP :: forall s a (form :: SEXPTYPE). Literal a form => SomeSEXP s -> a
- mkSEXP :: forall a (b :: SEXPTYPE) m. (Literal a b, MonadR m) => a -> m (SEXP (Region m) b)
- dynSEXP :: forall a s (ty :: SEXPTYPE). Literal a ty => SomeSEXP s -> a
- mkSEXPVector :: forall s (a :: SEXPTYPE). (Storable (ElemRep s a), IsVector a) => SSEXPTYPE a -> [IO (ElemRep s a)] -> SEXP s a
- mkSEXPVectorIO :: forall s (a :: SEXPTYPE). (Storable (ElemRep s a), IsVector a) => SSEXPTYPE a -> [IO (ElemRep s a)] -> IO (SEXP s a)
- mkProtectedSEXPVector :: forall (b :: SEXPTYPE) s (a :: SEXPTYPE). IsVector b => SSEXPTYPE b -> [SEXP s a] -> SEXP s b
- mkProtectedSEXPVectorIO :: forall (b :: SEXPTYPE) s (a :: SEXPTYPE). IsVector b => SSEXPTYPE b -> [SEXP s a] -> IO (SEXP s b)
- funToSEXP :: HFunWrap a b => (b -> IO (FunPtr b)) -> a -> IO (SEXP s 'ExtPtr)
- r :: QuasiQuoter
- rsafe :: QuasiQuoter
- collectAntis :: String -> IO (Either String [String])
- class (Applicative m, MonadIO m, MonadCatch m, MonadMask m, PrimMonad m) => MonadR (m :: Type -> Type) where
- data ExecContext (m :: Type -> Type)
- io :: IO a -> m a
- acquire :: forall s (a :: SEXPTYPE). s ~ V => SEXP s a -> m (SEXP (Region m) a)
- getExecContext :: m (ExecContext m)
- unsafeRunWithExecContext :: m a -> ExecContext m -> IO a
- acquireSome :: MonadR m => SomeSEXP V -> m (SomeSEXP (Region m))
- data family ExecContext (m :: Type -> Type)
- class PrintR a where
- p :: (MonadR m, PrintR a) => m a -> m ()
- printQuote :: (MonadR m, PrintR a) => m a -> m ()
Documentation
vector :: forall (a :: SEXPTYPE) s. IsVector a => SEXP s a -> Vector a (ElemRep V a) Source #
Project the vector out of SEXP
s.
data HExp a (b :: SEXPTYPE) where Source #
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).
See https://cran.r-project.org/doc/manuals/r-release/R-ints.html#SEXPTYPEs.
Constructors
Nil :: forall a. HExp a 'Nil | The NULL value ( |
Symbol | A symbol ( |
Fields
| |
List | A list ( |
Env | An environment ( |
Closure | A closure ( |
Promise | A promise ( |
Lang | Language objects ( |
Fields
| |
Special :: forall a. HExp a 'Special | A special (built-in) function call ( |
Builtin :: forall a. HExp a 'Builtin | A |
Char :: forall a. !(Vector 'Char Word8) -> HExp a 'Char | An internal character string ( |
Logical :: forall a. !(Vector 'Logical Logical) -> HExp a 'Logical | A logical vector ( |
Int :: forall a. !(Vector 'Int Int32) -> HExp a 'Int | An integer vector ( |
Real :: forall a. !(Vector 'Real Double) -> HExp a 'Real | A numeric vector ( |
Complex :: forall a. !(Vector 'Complex (Complex Double)) -> HExp a 'Complex | A complex vector ( |
String :: forall a. !(Vector 'String (SEXP V 'Char)) -> HExp a 'String | A character vector ( |
DotDotDot | A special type of |
Fields
| |
Vector | A list/generic vector ( |
Expr | An expression vector ( |
Bytecode :: forall a. HExp a 'Bytecode | A ‘byte-code’ object generated by R ( |
ExtPtr | An external pointer ( |
WeakRef | A weak reference ( |
Fields
| |
Raw :: forall a. !(Vector 'Raw Word8) -> HExp a 'Raw | A raw vector ( |
S4 | An S4 class which does not consist solely of a simple type such as an atomic vector or function ( |
(===) :: forall {k} f (a :: k) (b :: k). TestEquality f => f a -> f b -> Bool Source #
Heterogeneous equality.
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.
Instances
MonadIO (R s) Source # | |||||
Defined in Language.R.Instance | |||||
MonadCatch (R s) Source # | |||||
Defined in Language.R.Instance | |||||
MonadMask (R s) Source # | |||||
Defined in Language.R.Instance Methods mask :: HasCallStack => ((forall a. R s a -> R s a) -> R s b) -> R s b # uninterruptibleMask :: HasCallStack => ((forall a. R s a -> R s a) -> R s b) -> R s b # generalBracket :: HasCallStack => R s a -> (a -> ExitCase b -> R s c) -> (a -> R s b) -> R s (b, c) # | |||||
MonadThrow (R s) Source # | |||||
Defined in Language.R.Instance Methods throwM :: (HasCallStack, Exception e) => e -> R s a # | |||||
Applicative (R s) Source # | |||||
Functor (R s) Source # | |||||
Monad (R s) Source # | |||||
MonadFail (R s) Source # | |||||
Defined in Language.R.Instance | |||||
MonadR (R s) Source # | |||||
Defined in Language.R.Instance Associated Types
| |||||
PrimMonad (R s) Source # | |||||
(NFData a, Literal a b) => Literal (R s a) 'ExtPtr Source # | |||||
(NFData b, Literal a a0, Literal b b0) => Literal (a -> R s b) 'ExtPtr Source # | |||||
(NFData c, Literal a a0, Literal b b0, Literal c c0) => Literal (a -> b -> R s c) 'ExtPtr Source # | |||||
(NFData a1, Literal a2 i1, Literal a3 i2, Literal a4 i3, Literal a1 i4) => Literal (a2 -> a3 -> a4 -> R s a1) 'ExtPtr Source # | |||||
(NFData a1, Literal a2 i1, Literal a3 i2, Literal a4 i3, Literal a5 i4, Literal a1 i5) => Literal (a2 -> a3 -> a4 -> a5 -> R s a1) 'ExtPtr Source # | |||||
(NFData a1, Literal a2 i1, Literal a3 i2, Literal a4 i3, Literal a5 i4, Literal a6 i5, Literal a1 i6) => Literal (a2 -> a3 -> a4 -> a5 -> a6 -> R s a1) 'ExtPtr Source # | |||||
(NFData a1, Literal a2 i1, Literal a3 i2, Literal a4 i3, Literal a5 i4, Literal a6 i5, Literal a7 i6, Literal a1 i7) => Literal (a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> R s a1) 'ExtPtr Source # | |||||
(NFData a1, Literal a2 i1, Literal a3 i2, Literal a4 i3, Literal a5 i4, Literal a6 i5, Literal a7 i6, Literal a8 i7, Literal a1 i8) => Literal (a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> R s a1) 'ExtPtr Source # | |||||
(NFData a1, Literal a2 i1, Literal a3 i2, Literal a4 i3, Literal a5 i4, Literal a6 i5, Literal a7 i6, Literal a8 i7, Literal a9 i8, Literal a1 i9) => Literal (a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> a9 -> R s a1) 'ExtPtr Source # | |||||
(NFData a1, Literal a2 i1, Literal a3 i2, Literal a4 i3, Literal a5 i4, Literal a6 i5, Literal a7 i6, Literal a8 i7, Literal a9 i8, Literal a10 i9, Literal a1 i10) => Literal (a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> a9 -> a10 -> R s a1) 'ExtPtr Source # | |||||
(NFData a1, Literal a2 i1, Literal a3 i2, Literal a4 i3, Literal a5 i4, Literal a6 i5, Literal a7 i6, Literal a8 i7, Literal a9 i8, Literal a10 i9, Literal a11 i10, Literal a1 i11) => Literal (a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> a9 -> a10 -> a11 -> R s a1) 'ExtPtr Source # | |||||
(NFData a1, Literal a2 i1, Literal a3 i2, Literal a4 i3, Literal a5 i4, Literal a6 i5, Literal a7 i6, Literal a8 i7, Literal a9 i8, Literal a10 i9, Literal a11 i10, Literal a12 i11, Literal a1 i12) => Literal (a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> a9 -> a10 -> a11 -> a12 -> R s a1) 'ExtPtr Source # | |||||
(NFData a1, Literal a2 i1, Literal a3 i2, Literal a4 i3, Literal a5 i4, Literal a6 i5, Literal a7 i6, Literal a8 i7, Literal a9 i8, Literal a10 i9, Literal a11 i10, Literal a12 i11, Literal a13 i12, Literal a1 i13) => Literal (a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> a9 -> a10 -> a11 -> a12 -> a13 -> R s a1) 'ExtPtr Source # | |||||
newtype ExecContext (R s) Source # | |||||
Defined in Language.R.Instance | |||||
type PrimState (R s) Source # | |||||
Defined in Language.R.Instance |
string :: String -> IO (SEXP V 'Char) Source #
Deprecated: Use mkSEXP instead
Create an R character string from a Haskell string.
typeOf :: forall s (a :: SEXPTYPE). SEXP s a -> SEXPTYPE Source #
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.
type IsList (a :: SEXPTYPE) = (SingI a, a :∈ '['Char, 'Logical, 'Int, 'Real, 'Complex, 'String, 'Vector, 'Expr, 'WeakRef, 'Raw, 'List]) Source #
IsList a
holds iff R's is.list()
returns TRUE
.
asTypeOf :: forall s (a :: SEXPTYPE). SomeSEXP s -> SEXP s a -> SEXP s a Source #
Cast form of first argument to that of the second argument.
unsafeCoerce :: forall s (a :: SEXPTYPE) (b :: SEXPTYPE). SEXP s a -> SEXP s b Source #
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.
data SSEXPTYPE (a :: SEXPTYPE) where Source #
Constructors
SNil :: SSEXPTYPE 'Nil | |
SSymbol :: SSEXPTYPE 'Symbol | |
SList :: SSEXPTYPE 'List | |
SClosure :: SSEXPTYPE 'Closure | |
SEnv :: SSEXPTYPE 'Env | |
SPromise :: SSEXPTYPE 'Promise | |
SLang :: SSEXPTYPE 'Lang | |
SSpecial :: SSEXPTYPE 'Special | |
SBuiltin :: SSEXPTYPE 'Builtin | |
SChar :: SSEXPTYPE 'Char | |
SLogical :: SSEXPTYPE 'Logical | |
SInt :: SSEXPTYPE 'Int | |
SReal :: SSEXPTYPE 'Real | |
SComplex :: SSEXPTYPE 'Complex | |
SString :: SSEXPTYPE 'String | |
SDotDotDot :: SSEXPTYPE 'DotDotDot | |
SAny :: SSEXPTYPE 'Any | |
SVector :: SSEXPTYPE 'Vector | |
SExpr :: SSEXPTYPE 'Expr | |
SBytecode :: SSEXPTYPE 'Bytecode | |
SExtPtr :: SSEXPTYPE 'ExtPtr | |
SWeakRef :: SSEXPTYPE 'WeakRef | |
SRaw :: SSEXPTYPE 'Raw | |
SS4 :: SSEXPTYPE 'S4 | |
SNew :: SSEXPTYPE 'New | |
SFree :: SSEXPTYPE 'Free | |
SFun :: SSEXPTYPE 'Fun |
cast :: forall (a :: SEXPTYPE) s. SSEXPTYPE a -> SomeSEXP s -> SEXP s a Source #
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.
type family Sing :: k -> Type #
The singleton kind-indexed type family.
Instances
type Sing Source # | |
Defined in Foreign.R.Type | |
type Sing | |
Defined in Data.Singletons | |
type Sing | |
Defined in Data.Singletons | |
type Sing | |
Defined in Data.Singletons.Sigma |
data SEXP s (a :: SEXPTYPE) Source #
The basic type of all R expressions, classified by the form of the expression, and the memory region in which it has been allocated.
Instances
ToJSON (SEXP s a) Source # | |
NFData (SEXP s a) Source # | |
Defined in Foreign.R.Internal | |
Storable (SEXP s a) Source # | |
Defined in Foreign.R.Internal | |
Show (SEXP s a) Source # | |
Eq (SEXP s a) Source # | |
Ord (SEXP s a) Source # | |
Defined in Foreign.R.Internal | |
PrintR (SEXP s a) Source # | |
SingI a => Literal (SEXP s a) a Source # | |
class SingI ty => Literal a (ty :: SEXPTYPE) | a -> ty where Source #
Values that can be converted to SEXP
.
Minimal complete definition
Nothing
Methods
Instances
Literal Int32 'Int Source # | |
Literal Logical 'Logical Source # | |
Literal Text 'String Source # | |
Literal String 'String Source # | |
Literal Double 'Real Source # | |
Literal (Complex Double) 'Complex Source # | |
Literal (SomeSEXP s) 'Any Source # | |
Literal [Complex Double] 'Complex Source # | |
Literal [Int32] 'Int Source # | |
Literal [Logical] 'Logical Source # | |
Literal [String] 'String Source # | |
Literal [Double] 'Real Source # | |
SVECTOR ty a => Literal (Vector ty a) ty Source # | |
SingI a => Literal (SEXP s a) a Source # | |
(NFData a, Literal a b) => Literal (R s a) 'ExtPtr Source # | |
(NFData b, Literal a a0, Literal b b0) => Literal (a -> R s b) 'ExtPtr Source # | |
(NFData c, Literal a a0, Literal b b0, Literal c c0) => Literal (a -> b -> R s c) 'ExtPtr Source # | |
(NFData a1, Literal a2 i1, Literal a3 i2, Literal a4 i3, Literal a1 i4) => Literal (a2 -> a3 -> a4 -> R s a1) 'ExtPtr Source # | |
(NFData a1, Literal a2 i1, Literal a3 i2, Literal a4 i3, Literal a5 i4, Literal a1 i5) => Literal (a2 -> a3 -> a4 -> a5 -> R s a1) 'ExtPtr Source # | |
(NFData a1, Literal a2 i1, Literal a3 i2, Literal a4 i3, Literal a5 i4, Literal a6 i5, Literal a1 i6) => Literal (a2 -> a3 -> a4 -> a5 -> a6 -> R s a1) 'ExtPtr Source # | |
(NFData a1, Literal a2 i1, Literal a3 i2, Literal a4 i3, Literal a5 i4, Literal a6 i5, Literal a7 i6, Literal a1 i7) => Literal (a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> R s a1) 'ExtPtr Source # | |
(NFData a1, Literal a2 i1, Literal a3 i2, Literal a4 i3, Literal a5 i4, Literal a6 i5, Literal a7 i6, Literal a8 i7, Literal a1 i8) => Literal (a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> R s a1) 'ExtPtr Source # | |
(NFData a1, Literal a2 i1, Literal a3 i2, Literal a4 i3, Literal a5 i4, Literal a6 i5, Literal a7 i6, Literal a8 i7, Literal a9 i8, Literal a1 i9) => Literal (a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> a9 -> R s a1) 'ExtPtr Source # | |
(NFData a1, Literal a2 i1, Literal a3 i2, Literal a4 i3, Literal a5 i4, Literal a6 i5, Literal a7 i6, Literal a8 i7, Literal a9 i8, Literal a10 i9, Literal a1 i10) => Literal (a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> a9 -> a10 -> R s a1) 'ExtPtr Source # | |
(NFData a1, Literal a2 i1, Literal a3 i2, Literal a4 i3, Literal a5 i4, Literal a6 i5, Literal a7 i6, Literal a8 i7, Literal a9 i8, Literal a10 i9, Literal a11 i10, Literal a1 i11) => Literal (a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> a9 -> a10 -> a11 -> R s a1) 'ExtPtr Source # | |
(NFData a1, Literal a2 i1, Literal a3 i2, Literal a4 i3, Literal a5 i4, Literal a6 i5, Literal a7 i6, Literal a8 i7, Literal a9 i8, Literal a10 i9, Literal a11 i10, Literal a12 i11, Literal a1 i12) => Literal (a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> a9 -> a10 -> a11 -> a12 -> R s a1) 'ExtPtr Source # | |
(NFData a1, Literal a2 i1, Literal a3 i2, Literal a4 i3, Literal a5 i4, Literal a6 i5, Literal a7 i6, Literal a8 i7, Literal a9 i8, Literal a10 i9, Literal a11 i10, Literal a12 i11, Literal a13 i12, Literal a1 i13) => Literal (a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> a9 -> a10 -> a11 -> a12 -> a13 -> R s a1) 'ExtPtr Source # | |
VECTOR V ty a => Literal (MVector V ty a) ty Source # | |
A SEXP
of unknown form.
Instances
ToJSON (SomeSEXP s) Source # | |
NFData (SomeSEXP s) Source # | |
Defined in Foreign.R.Internal | |
Storable (SomeSEXP s) Source # | |
Defined in Foreign.R.Internal Methods alignment :: SomeSEXP s -> Int # peekElemOff :: Ptr (SomeSEXP s) -> Int -> IO (SomeSEXP s) # pokeElemOff :: Ptr (SomeSEXP s) -> Int -> SomeSEXP s -> IO () # peekByteOff :: Ptr b -> Int -> IO (SomeSEXP s) # pokeByteOff :: Ptr b -> Int -> SomeSEXP s -> IO () # | |
Show (SomeSEXP s) Source # | |
PrintR (SomeSEXP s) Source # | |
Literal (SomeSEXP s) 'Any Source # | |
eval :: forall m s (a :: SEXPTYPE). MonadR m => SEXP s a -> m (SomeSEXP (Region m)) Source #
Evaluate a (sequence of) expression(s) in the global environment.
isRInteractive :: Ptr CInt Source #
unboundValue :: SEXP G 'Symbol Source #
Special value to which all symbols unbound in the current environment resolve to.
missingArg :: SEXP G 'Symbol Source #
Value substituted for all missing actual arguments of a function call.
R uses three-valued logic.
Instances
Storable Logical Source # | |
Show Logical Source # | |
Eq Logical Source # | |
Ord Logical Source # | |
Literal Logical 'Logical Source # | |
Literal [Logical] 'Logical Source # | |
Instances
Exception RError Source # | |
Defined in Foreign.R.Error Methods toException :: RError -> SomeException # fromException :: SomeException -> Maybe RError # displayException :: RError -> String # backtraceDesired :: RError -> Bool # | |
Show RError Source # | |
type PairList = 'List Source #
Used where the R documentation speaks of "pairlists", which are really just regular lists.
type IsVector (a :: SEXPTYPE) = (SingI a, a :∈ '['Char, 'Logical, 'Int, 'Real, 'Complex, 'String, 'Vector, 'Expr, 'WeakRef, 'Raw]) Source #
Constraint synonym grouping all vector forms into one class. IsVector a
holds iff R's is.vector()
returns TRUE
.
type IsGenericVector (a :: SEXPTYPE) = (SingI a, a :∈ '['Vector, 'Expr, 'WeakRef]) Source #
Non-atomic vector forms. See src/main/memory.c:SET_VECTOR_ELT
in the R source distribution.
type IsPairList (a :: SEXPTYPE) = (SingI a, a :∈ '['List, 'Nil]) Source #
IsPairList a
holds iff R's is.pairlist()
returns TRUE
.
refresh :: MonadR m => m () Source #
Manually trigger processing all pending events. Useful when at an interactive prompt and no event loop is running.
eval_ :: forall m s (a :: SEXPTYPE). MonadR m => SEXP s a -> m () Source #
Silent version of eval
function that discards it's result.
evalEnv :: forall m s (a :: SEXPTYPE). MonadR m => SEXP s a -> SEXP s 'Env -> m (SomeSEXP (Region m)) Source #
Evaluate a (sequence of) expression(s) in the given environment, returning the value of the last.
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).
Throw an R error as an exception.
throwRMessage :: MonadR m => String -> m a Source #
Throw an R exception with specified message.
parseFile :: FilePath -> (SEXP s 'Expr -> IO a) -> IO a Source #
Deprecated: Use [r| parse(file="pathtofile") |] instead.
Parse file and perform some actions on parsed file.
This function uses continuation because this is an easy way to make operations GC-safe.
Arguments
:: String | Text to parse |
-> Bool | Whether to annotate the AST with source locations. |
-> IO (SEXP V 'Expr) |
Deprecated: Use [r| parse(text=...) |] instead.
strings :: String -> IO (SEXP V 'String) Source #
Deprecated: Use mkSEXP instead
Create an R string vector from a Haskell string.
automatic :: forall m s (a :: SEXPTYPE). MonadR m => SEXP s a -> m (SEXP G a) Source #
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.
pokeRVariables :: RVariables -> IO () Source #
hexp :: forall s (a :: SEXPTYPE). SEXP s a -> HExp s a Source #
A view function projecting a view of SEXP
as an algebraic datatype, that can be analyzed through pattern matching.
runRegion :: NFData a => (forall s. R s a) -> IO a Source #
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).
throws
Error
. Generaly any R function may throw RError
that is safe to be cached and computation can proceed. However RError
will cancel entire R block. So in order to catch exception in more fine grained way one has to use function tryCatch
inside R block.
Configuration options for the R runtime. Configurations form monoids, so arguments can be accumulated left-to-right through monoidal composition.
Constructors
Config | |
Fields
|
defaultConfig :: Config Source #
Default argument to pass to initialize
.
initialize :: Config -> IO () Source #
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.
toPairList :: MonadR m => [(String, SomeSEXP (Region m))] -> m (SomeSEXP (Region m)) Source #
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.
fromPairList :: SomeSEXP s -> [(String, SomeSEXP s)] Source #
Create an association list from a pairlist. R Pairlists are nil-terminated chains of nested cons cells, as in LISP.
fromSomeSEXP :: forall s a (form :: SEXPTYPE). Literal a form => SomeSEXP s -> a Source #
Like fromSEXP
, but with no static type satefy. Performs a dynamic (i.e. at runtime) check instead.
mkSEXP :: forall a (b :: SEXPTYPE) m. (Literal a b, MonadR m) => a -> m (SEXP (Region m) b) Source #
Create a SEXP value and protect it in current region
dynSEXP :: forall a s (ty :: SEXPTYPE). Literal a ty => SomeSEXP s -> a Source #
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.
mkSEXPVector :: forall s (a :: SEXPTYPE). (Storable (ElemRep s a), IsVector a) => SSEXPTYPE a -> [IO (ElemRep s a)] -> SEXP s a Source #
mkSEXPVectorIO :: forall s (a :: SEXPTYPE). (Storable (ElemRep s a), IsVector a) => SSEXPTYPE a -> [IO (ElemRep s a)] -> IO (SEXP s a) Source #
mkProtectedSEXPVector :: forall (b :: SEXPTYPE) s (a :: SEXPTYPE). IsVector b => SSEXPTYPE b -> [SEXP s a] -> SEXP s b Source #
mkProtectedSEXPVectorIO :: forall (b :: SEXPTYPE) s (a :: SEXPTYPE). IsVector b => SSEXPTYPE b -> [SEXP s a] -> IO (SEXP s b) Source #
r :: QuasiQuoter Source #
An R value, expressed as an R expression, in R's syntax.
rsafe :: QuasiQuoter Source #
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.
Arguments
:: String | the R code that may contain antiquotations, which are identifiers ending with |
-> IO (Either String [String]) | either an error message from R, or a list of unique antiquoted identifiers |
Map backwards slashes to forward slashes.
Find all occurences of antiquotations.
This function works by parsing the user's R code in a separate R process. As a nice side-effect, it will detect and return any syntax errors in the quasi-quoted R code.
This function is exposed only for testing; you probably don't need to call it in the user code.
class (Applicative m, MonadIO m, MonadCatch m, MonadMask m, PrimMonad m) => MonadR (m :: Type -> Type) where Source #
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).
Minimal complete definition
Associated Types
data ExecContext (m :: Type -> Type) Source #
A reification of an R execution context, i.e. a "session".
Methods
Lift an IO
action.
acquire :: forall s (a :: SEXPTYPE). s ~ V => SEXP s a -> m (SEXP (Region m) a) Source #
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).
default acquire :: forall s (a :: SEXPTYPE). (MonadIO m, Region m ~ G) => SEXP s a -> m (SEXP (Region m) a) Source #
getExecContext :: m (ExecContext m) Source #
Get the current execution context.
unsafeRunWithExecContext :: m a -> ExecContext m -> IO a Source #
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.
Instances
MonadR IO Source # | |||||
Defined in H.Prelude.Interactive Associated Types
| |||||
MonadR (R s) Source # | |||||
Defined in Language.R.Instance Associated Types
|
data family ExecContext (m :: Type -> Type) Source #
A reification of an R execution context, i.e. a "session".
Instances
data ExecContext IO Source # | |
Defined in H.Prelude.Interactive | |
newtype ExecContext (R s) Source # | |
Defined in Language.R.Instance |
p :: (MonadR m, PrintR a) => m a -> m () Source #
A form of the printR
function that is more convenient in an interactive session.
printQuote :: (MonadR m, PrintR a) => m a -> m () Source #
Orphan instances
MonadR IO Source # | |||||
Associated Types
|