-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | J in Haskell -- -- Haskell library for calling J @package j @version 0.2.2.0 -- | Marshal a limited subset of J arrays into Repa arrays. -- --

Tutorial

-- -- Suppose we wish to perform linear regression. In J we could do: -- --
--   xs := 1 2 3
--   ys := 2 4 6
--   
--   reg_result =: ys %. xs ^/ i.2
--   
-- -- To do this with Haskell data: -- --
--   do
--      jenv <- jinit libLinux
--   
--      let hsArr0 = R.fromListUnboxed (R.ix1 3) [1.0,2.0,3.0]
--          hsArr1 = R.fromListUnboxed (R.ix1 3) [2.0,4.0,6.0]
--          jArr0 = JDoubleArr $ R.copyS $ R.map (realToFrac :: Double -> CDouble) hsArr0
--          jArr1 = JDoubleArr $ R.copyS $ R.map (realToFrac :: Double -> CDouble) hsArr1
--   
--      setJData jenv "xs" jArr0
--      setJData jenv "ys" jArr1
--   
--      bsDispatch jenv "reg_result =: ys %. xs ^/ i.2"
--   
--      JDoubleArr res <- getJData jenv "reg_result"
--      R.toList res
--   
-- -- There are three steps to do the calculation, plus one to get a J -- environment. -- --
    --
  1. Use jinit with the appropriate file path for your -- platform
  2. --
  3. Marshal Haskell values and send them to the J environment. To do -- so, we use setJData, which takes a JData containing a -- repa array or a string.
  4. --
  5. Perform calculations within the J environment. Here, we use -- bsDispatch to compute some results and assign them within -- J
  6. --
  7. Marshal J values back to Haskell. We use getJData.
  8. --
-- -- Since marshaling data between J and Haskell is expensive, it's best to -- do as much computation as possible in J. -- --

Loading Profile

-- -- If you would like to use user libraries, you need to use jLoad -- on the JEnv. As an example: -- --
--   do
--       jenv <- jinit libLinux
--       jLoad jenv (linuxProfile "9.02")
--       bsDispatch jenv "load'tables/csv'"
--   
--   
-- -- This will load the CSV addon, assuming it is installed. -- --

FFI

-- -- If you want to marshal data yourself, say to use a Vector, -- look at JEnv. module Language.J data JEnv JEnv :: Ptr J -> JDoType -> JGetMType -> JGetRType -> JSetAType -> JEnv [context] :: JEnv -> Ptr J [evaluator] :: JEnv -> JDoType [reader] :: JEnv -> JGetMType [out] :: JEnv -> JGetRType [setter] :: JEnv -> JSetAType -- | Get a J environment -- -- Passing the resultant JEnv between threads can cause unexpected -- bugs. jinit :: RawFilePath -> IO JEnv -- | Load user profile. -- --
--   since 0.1.2.0
--   
jLoad :: JEnv -> Profile -> IO () data Profile Profile :: ByteString -> ByteString -> ByteString -> Profile -- |
--   profile.ijs
--   
[profPath] :: Profile -> ByteString [binPath] :: Profile -> ByteString [dllName] :: Profile -> ByteString linuxProfile :: ByteString -> Profile macProfile :: JVersion -> Profile windowsProfile :: JVersion -> Profile -- | Expected RawFilePath to the library on a Linux machine. libLinux :: RawFilePath -- | Expected RawFilePath to the library on Mac. libMac :: JVersion -> RawFilePath profLinux :: ByteString -> ByteString -- | Send some J code to the environment. bsDispatch :: JEnv -> ByteString -> IO () -- | Read last output -- -- For debugging bsOut :: JEnv -> IO ByteString type JVersion = [Int] -- | J data backed by repa array data JData sh JIntArr :: !Array F sh CLLong -> JData sh JDoubleArr :: !Array F sh CDouble -> JData sh JComplexArr :: !Array F sh (Complex CDouble) -> JData sh JBoolArr :: !Array F sh CChar -> JData sh JString :: !ByteString -> JData sh -- | <math> in the array size -- -- Throws JErr for unspported conversion types. getJData :: Shape sh => JEnv -> ByteString -> IO (JData sh) -- | <math> in the array size setJData :: Shape sh => JEnv -> ByteString -> JData sh -> IO CInt data JErr TypeError :: JErr UnsupportedType :: JErr -- | Copy into a Vector Int, if possible. -- -- Throws a JErr on type error. -- -- <math> tryIntVect :: JData DIM1 -> Vector Int -- | <math> copyIntVect :: Vector Int -> JData DIM1 -- | Abstract context data J type JDoType = Ptr J -> CString -> IO CInt type JGetMType = Ptr J -> CString -> Ptr CLLong -> Ptr CLLong -> Ptr (Ptr CLLong) -> Ptr (Ptr CChar) -> IO CInt type JGetRType = Ptr J -> IO CString type JSetAType = Ptr J -> CLLong -> CString -> CLLong -> Ptr () -> IO CInt instance GHC.Exception.Type.Exception Language.J.JErr instance GHC.Show.Show Language.J.JErr