packages feed

inline-r 1.0.1 → 1.0.2

raw patch · 8 files changed

+149/−105 lines, 8 filesdep −prettydep −strictdep −tasty-goldendep ~aesondep ~bytestringdep ~containers

Dependencies removed: pretty, strict, tasty-golden, th-lift, th-orphans, transformers

Dependency ranges changed: aeson, bytestring, containers, data-default-class, deepseq, filepath, mtl, primitive, singletons-th, tasty, tasty-quickcheck, template-haskell, text, vector

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ # Change Log +## 1.0.2 - 2025-07-11++* Support R 4.5+ ## 1.0.1 - 2023-05-22 * Populate `R_LIBS` environment variable when starting R (#393) * Map backslashes to forwardslashes in temp file names under Windows (#399)
cbits/missing_r.c view
@@ -33,3 +33,62 @@ int isRInitialized = 2;  HsStablePtr rVariables;+++// List the prototypes of functions and variables that inline-r+// uses from R. The purpose of this is to catch changes in the+// C interface when upgrading R.+#include <Rembedded.h>+int Rf_initEmbeddedR(int, char**);+void Rf_endEmbeddedR(int);++#ifndef mingw32_HOST_OS+#include <R_ext/eventloop.h>+static void test_R_PolledEvents(){ void (*a)(void) = R_PolledEvents; };+static void test_R_wait_usec(){ int *a = &R_wait_usec; };++static void test_R_InputHandlers(){ InputHandler *a = R_InputHandlers; };+fd_set *R_checkActivity(int usec, int ignore_stdin);+void R_runHandlers(InputHandler *handlers, fd_set *mask);+InputHandler *addInputHandler(InputHandler *handlers, int fd, InputHandlerProc handler, int activity);+int removeInputHandler(InputHandler **handlers, InputHandler *it);++#include <Rinterface.h>+static void test_R_Interactive(){+    Rboolean *a = &R_Interactive;+    int i=0;+    *a=i;+};+static void test_R_SignalHandlers(){ int *a = &R_SignalHandlers; };+#endif++int TYPEOF(SEXP x);+static void test_R_NilValue(){ SEXP *a = &R_NilValue; };+static void test_R_UnboundValue(){ SEXP *a = &R_UnboundValue; };+static void test_R_MissingArg(){ SEXP *a = &R_MissingArg; };+static void test_R_BaseEnv(){ SEXP *a = &R_BaseEnv; };+static void test_R_EmptyEnv(){ SEXP *a = &R_EmptyEnv; };+static void test_R_GlobalEnv(){ SEXP *a = &R_GlobalEnv; };++#include <R_ext/GraphicsEngine.h>+static void test_R_interrupts_pending(){ int *a = &R_interrupts_pending; };+int OBJECT(SEXP x);+int NAMED(SEXP x);+int LEVELS(SEXP x);+int RDEBUG(SEXP x);+SEXP ATTRIB(SEXP x);+void SET_ATTRIB(SEXP, SEXP);+SEXP Rf_getAttrib(SEXP, SEXP);+Rboolean Rf_isS4(SEXP x);++#include <R_ext/Parse.h>+static void test_ParseStatus() { ParseStatus a = (int)0; };+SEXP R_ParseVector(SEXP, int, ParseStatus*, SEXP);++// These variables are not in header files!+extern void (*Rg_PolledEvents)(void);+static void test_Rg_PolledEvents(){ void (*a)(void) = Rg_PolledEvents; };+extern int Rg_wait_usec;+static void test_Rg_wait_usec(){ int *a = &Rg_wait_usec; };+extern int R_PPStackTop;+static void test_R_PPStackTop(){ int *a = &R_PPStackTop; };
inline-r.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: inline-r-version: 1.0.1+version: 1.0.2 license: BSD-3-Clause license-file: LICENSE author: Mathieu Boespflug, Facundo Dominguez, Alexander Vershilov@@ -39,7 +39,29 @@   location: git://github.com/tweag/HaskellR.git   subdir: inline-r +common common-config+  ghc-options: -Werror=unused-packages -Wall+  default-language: Haskell2010++common common-test-and-benchmark-config+  import: common-config+  ghc-options: -threaded+  hs-source-dirs: tests++common common-test-suite-deps+  build-depends:+    inline-r,+    base >=4.6 && <5,+    tasty-hunit >=0.4.1 && <0.11,++common common-benchmark-deps+  build-depends:+    inline-r,+    base >=4.6 && <5,+    criterion >=0.8 && <1.7,+ library+  import: common-config   exposed-modules:     Control.Memory.Region     Data.Vector.SEXP@@ -79,26 +101,22 @@     Internal.Error   build-depends:     base >=4.7 && <5,-    aeson >=0.6 && <2.2,-    bytestring >=0.10 && <0.12,-    containers >=0.5 && <0.7,-    data-default-class >=0.1.2.0 && <0.2,-    deepseq >=1.3 && <1.5,+    aeson >=0.6 && <2.3,+    bytestring >=0.10 && <0.13,+    containers >=0.5 && <0.8,+    data-default-class >=0.1.2.0 && <0.3,+    deepseq >=1.3 && <1.6,     exceptions >=0.6 && <1.1,     heredoc >=0.2 && <0.3,     inline-c >=0.6 && <0.10,     mtl >=2.1 && <2.4,-    pretty >=1.1 && <1.2,-    primitive >=0.5 && <0.9,+    primitive >=0.5 && <0.10,     process >=1.2 && <1.7,     reflection >=2 && <2.2,     setenv >=0.1.1 && <0.2,-    template-haskell >=2.8 && <2.21,+    template-haskell >=2.8 && <2.23,     temporary >=1.2 && <1.4,-    text >=0.11 && <2.1,-    th-lift >=0.6 && <0.9,-    th-orphans >=0.8 && <0.14,-    transformers >=0.3 && <0.7,+    text >=0.11 && <2.2,     vector >=0.10 && <0.14,   if impl(ghc <9)     build-depends:@@ -106,12 +124,12 @@   else     build-depends:       singletons >=3 && <3.1,-      singletons-th >=3 && <3.3,+      singletons-th >=3 && <3.5,   hs-source-dirs: src   includes: cbits/missing_r.h   c-sources: cbits/missing_r.c+  cc-options: -Werror=incompatible-pointer-types   include-dirs: cbits-  default-language: Haskell2010   other-extensions:     CPP     ForeignFunctionInterface@@ -125,31 +143,26 @@   ghc-options: -freduction-depth=32   --- We don't use ticks for promoted constructors, because we use   --- promoted constructors heavily and because they confuse hsc2hs.-  ghc-options: -Wall -fno-warn-unticked-promoted-constructors+  ghc-options: -fno-warn-unticked-promoted-constructors  test-suite tests-  main-is: tests.hs+  import:+    common-test-and-benchmark-config,+    common-test-suite-deps,   type: exitcode-stdio-1.0+  main-is: tests.hs   build-depends:-    inline-r,-    base >=4.6 && <5,-    bytestring >=0.10 && <0.12,+    bytestring >=0.10 && <0.13,     directory >=1.2 && <1.4,-    filepath >=1.3 && <1.5,     heredoc >=0.2 && <0.3,     ieee754 >=0.7 && <0.9,-    mtl >=2.0 && <2.4,-    process >=1.2 && <1.7,     quickcheck-assertions >=0.1.1 && <0.4,     singletons >=0.10 && <3.1,-    strict >=0.3.2 && <0.6,-    tasty >=0.11 && <1.5,+    tasty >=0.11 && <1.6,     tasty-expected-failure >=0.11 && <0.13,-    tasty-golden >=2.3 && <2.4,     tasty-hunit >=0.4.1 && <0.11,-    tasty-quickcheck >=0.4.1 && <0.11,+    tasty-quickcheck >=0.4.1 && <0.12,     temporary >=1.2 && <1.4,-    text >=0.11 && <2.1,     vector >=0.12.3.1 && <0.14,   if !os(windows)     build-depends: unix >=2.5 && <2.9,@@ -161,92 +174,68 @@     Test.Regions     Test.Vector     Test.Matcher-  ghc-options: -Wall -threaded-  hs-source-dirs: tests-  default-language: Haskell2010  test-suite test-qq-  main-is: test-qq.hs+  import:+    common-test-and-benchmark-config,+    common-test-suite-deps,   type: exitcode-stdio-1.0+  main-is: test-qq.hs   build-depends:-    inline-r,-    base >=4.6 && <5,     mtl >=2.0 && <2.4,-    process >=1.2 && <1.7,-    tasty-hunit >=0.4.1 && <0.11,     singletons >=0.9 && <3.1,-    text >=0.11 && <2.1,-  ghc-options: -Wall -threaded-  hs-source-dirs: tests-  default-language: Haskell2010+    text >=0.11 && <2.2,  test-suite test-shootout-  main-is: test-shootout.hs+  import:+    common-test-and-benchmark-config,+    common-test-suite-deps,   type: exitcode-stdio-1.0+  main-is: test-shootout.hs   other-modules: Test.Scripts   build-depends:-    inline-r,-    base >=4.6 && <5,-    filepath >=1.3 && <1.5,+    filepath >=1.3 && <1.6,     process >=1.2 && <1.7,     silently >=1.2 && <1.3,-    tasty >=0.3 && <1.5,-    tasty-hunit >=0.4.1 && <0.11,-    template-haskell >=2.8 && <2.21,-  ghc-options: -Wall -threaded-  hs-source-dirs: tests-  default-language: Haskell2010+    tasty >=0.11 && <1.6,+    template-haskell >=2.8 && <2.23,   if os(windows)     buildable: False  test-suite test-env1-  main-is: test-env1.hs+  import:+    common-test-and-benchmark-config,+    common-test-suite-deps,   type: exitcode-stdio-1.0+  main-is: test-env1.hs   build-depends:-    inline-r,-    base >=4.6 && <5,-    tasty >=0.3 && <1.5,-    tasty-hunit >=0.4.1 && <0.11,-  ghc-options: -Wall -threaded-  hs-source-dirs: tests-  default-language: Haskell2010+    tasty >=0.11 && <1.6,  test-suite test-env2-  main-is: test-env2.hs+  import:+    common-test-and-benchmark-config,+    common-test-suite-deps,   type: exitcode-stdio-1.0+  main-is: test-env2.hs   build-depends:-    inline-r,-    base >=4.6 && <5,-    tasty >=0.3 && <1.5,-    tasty-hunit >=0.4.1 && <0.11,-  ghc-options: -Wall -threaded-  hs-source-dirs: tests-  default-language: Haskell2010+    tasty >=0.11 && <1.6,  benchmark bench-qq+  import:+    common-test-and-benchmark-config,+    common-benchmark-deps,   main-is: bench-qq.hs   type: exitcode-stdio-1.0   build-depends:-    inline-r,-    base >=4.6 && <5,-    criterion >=0.8 && <1.7,-    filepath >=1.3 && <1.5,-    process >=1.2 && <1.7,-    template-haskell >=2.8 && <2.21,-  ghc-options: -Wall -threaded-  hs-source-dirs: tests-  default-language: Haskell2010+    filepath >=1.3 && <1.6,+    template-haskell >=2.8 && <2.22,  benchmark bench-hexp+  import:+    common-test-and-benchmark-config,+    common-benchmark-deps,   main-is: bench-hexp.hs   type: exitcode-stdio-1.0   build-depends:-    inline-r,-    base >=4.6 && <5,-    criterion >=0.8 && <1.7,-    primitive >=0.5 && <0.9,-    vector >=0.10 && <0.14,+    primitive >=0.5 && <0.10,     singletons >=2.7 && <3.1,-  ghc-options: -Wall -threaded-  hs-source-dirs: tests-  default-language: Haskell2010
src/Foreign/R/EventLoop.hsc view
@@ -72,7 +72,7 @@ -- | @R_wait_usec@ global variable. foreign import ccall "&R_wait_usec" pollingPeriod :: Ptr CInt --- | @R_PolledEvents@ global variable.+-- | @Rg_PolledEvents@ global variable. foreign import ccall "&Rg_PolledEvents" graphicsPolledEvents :: Ptr (FunPtr (IO ()))  -- | @R_wait_usec@ global variable.
src/Foreign/R/Internal.hs view
@@ -2,7 +2,7 @@ -- Copyright: (C) 2013 Amgen, Inc. -- -- Low-level bindings to core R datatypes and functions which depend on--- computing offsets of C struct field. We use hsc2hs for this purpose.+-- computing offsets of C struct field.  {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE DataKinds #-}@@ -187,10 +187,7 @@       , infoObj   :: Bool        -- ^ Is this an object with a class attribute.       , infoNamed :: Int         -- ^ Control copying information.       , infoGp    :: Int         -- ^ General purpose data.-      , infoMark  :: Bool        -- ^ Mark object as 'in use' in GC.       , infoDebug :: Bool        -- ^ Debug marker.-      , infoTrace :: Bool        -- ^ Trace marker.-      , infoSpare :: Bool        -- ^ Alignment (not in use).       } deriving ( Show )  -- | Extract the header from the given 'SEXP'.@@ -201,22 +198,16 @@       <*> ((/=0)              <$> cOBJECT s)       <*> (fromIntegral       <$> cNAMED s)       <*> (fromIntegral       <$> cLEVELS s)-      <*> ((/=0)              <$> cMARK s)       <*> ((/=0)              <$> cRDEBUG s)-      <*> ((/=0)              <$> cRTRACE s)-      <*> ((/=0)              <$> cRSTEP s)   where     s = unsexp ts  -- These accessors are necessary because hsc2hs cannot determine the offset of--- C struct bit-fields. https://ghc.haskell.org/trac/ghc/ticket/12149+-- C struct bit-fields. https://gitlab.haskell.org/ghc/ghc/-/issues/12149 foreign import ccall unsafe "OBJECT" cOBJECT :: SEXP0 -> IO CInt foreign import ccall unsafe "NAMED" cNAMED :: SEXP0 -> IO CInt foreign import ccall unsafe "LEVELS" cLEVELS :: SEXP0 -> IO CInt-foreign import ccall unsafe "MARK" cMARK :: SEXP0 -> IO CInt foreign import ccall unsafe "RDEBUG" cRDEBUG :: SEXP0 -> IO CInt-foreign import ccall unsafe "RTRACE" cRTRACE :: SEXP0 -> IO CInt-foreign import ccall unsafe "RSTEP" cRSTEP :: SEXP0 -> IO CInt  ------------------------------------------------------------------------------- -- Attribute header                                                          --
src/Language/R/Debug.hs view
@@ -47,10 +47,7 @@       , "obj"   .= R.infoObj x       , "named" .= R.infoNamed x       , "gp"    .= R.infoGp x-      , "mark"  .= R.infoMark x       , "debug" .= R.infoDebug x-      , "trace" .= R.infoTrace x-      , "spare" .= R.infoSpare x       ]  instance ToJSON a => ToJSON (Complex a) where
src/Language/R/HExp.hs view
@@ -336,12 +336,12 @@                   <*> (coerceAnySome <$> R.cdr su)       R.Special   -> coerce $ return Special       R.Builtin   -> coerce $ return Builtin-      R.Char      -> unsafeCoerce $ Char    (Vector.unsafeFromSEXP su)-      R.Logical   -> unsafeCoerce $ Logical (Vector.unsafeFromSEXP su)-      R.Int       -> unsafeCoerce $ Int     (Vector.unsafeFromSEXP su)-      R.Real      -> unsafeCoerce $ Real    (Vector.unsafeFromSEXP su)-      R.Complex   -> unsafeCoerce $ Complex (Vector.unsafeFromSEXP su)-      R.String    -> unsafeCoerce $ String  (Vector.unsafeFromSEXP su)+      R.Char      -> coerce $ return $ Char    (Vector.unsafeFromSEXP su)+      R.Logical   -> coerce $ return $ Logical (Vector.unsafeFromSEXP su)+      R.Int       -> coerce $ return $ Int     (Vector.unsafeFromSEXP su)+      R.Real      -> coerce $ return $ Real    (Vector.unsafeFromSEXP su)+      R.Complex   -> coerce $ return $ Complex (Vector.unsafeFromSEXP su)+      R.String    -> coerce $ return $ String  (Vector.unsafeFromSEXP su)       R.DotDotDot -> unimplemented $ "peekHExp: " ++ show (R.typeOf s)       R.Vector    -> coerce $         Vector    <$> (fromIntegral <$> R.trueLength (coerceAny su))@@ -363,7 +363,7 @@                        peekElemOff (castPtr $ R.unsafeSEXPToVectorPtr s) 2)                   <*> (coerceAny <$> R.sexp <$>                        peekElemOff (castPtr $ R.unsafeSEXPToVectorPtr s) 3)-      R.Raw       -> unsafeCoerce $ Raw (Vector.unsafeFromSEXP su)+      R.Raw       -> coerce $ return $ Raw (Vector.unsafeFromSEXP su)       R.S4        -> coerce $         S4        <$> (coerceAnySome <$> R.tag su)       _           -> unimplemented $ "peekHExp: " ++ show (R.typeOf s)
tests/Test/Event.hs view
@@ -82,7 +82,11 @@       withSystemTempFile "inline-r-" $ \path h -> do         hPutStrLn h "hello"         hClose h+#if MIN_VERSION_unix(2,8,0)+        fd <- openFd path ReadOnly defaultFileFlags{ nonBlock = True }+#else         fd <- openFd path ReadOnly Nothing defaultFileFlags{ nonBlock = True }+#endif         action fd         closeFd fd #endif