jvm 0.1 → 0.1.1
raw patch · 2 files changed
+14/−6 lines, 2 files
Files
- jvm.cabal +1/−1
- src/Language/Java.hs +13/−5
jvm.cabal view
@@ -1,5 +1,5 @@ name: jvm-version: 0.1+version: 0.1.1 synopsis: Call JVM methods from Haskell. description: Please see README.md. homepage: http://github.com/tweag/inline-java/tree/master/jvm#readme
src/Language/Java.hs view
@@ -29,6 +29,7 @@ -- __NOTE:__ To use any function in this module, you'll need an initialized JVM in the -- current process, using 'withJVM' or otherwise. +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE FlexibleContexts #-}@@ -61,7 +62,7 @@ import Control.Distributed.Closure import Control.Distributed.Closure.TH-import Control.Monad ((<=<), forM, forM_)+import Control.Monad import Data.Char (chr, ord) import qualified Data.Coerce as Coerce import Data.Int@@ -73,11 +74,13 @@ import Data.String (fromString) import qualified Data.Text.Foreign as Text import Data.Text (Text)+#if ! __GLASGOW_HASKELL__ == 800 import qualified Data.Vector.Storable as Vector import Data.Vector.Storable (Vector) import qualified Data.Vector.Storable.Mutable as MVector import Data.Vector.Storable.Mutable (IOVector) import Foreign (FunPtr, Ptr, Storable, newForeignPtr, withForeignPtr)+#endif import Foreign.C (CChar) import Foreign.JNI import Foreign.JNI.Types@@ -150,13 +153,13 @@ -- | Get the Java class of an object or anything 'Coercible' to one. classOf- :: ( Coerce.Coercible a (J ('Class sym))- , Coercible a ('Class sym)+ :: ( Coercible a ('Class sym) , KnownSymbol sym ) => a -> Sing sym-classOf _ = sing+-- Silence redundant constraint warning.+classOf x = coerce x `seq` sing -- | Creates a new instance of the class whose name is resolved from the return -- type. For instance,@@ -169,7 +172,6 @@ :: forall a sym. ( Coerce.Coercible a (J ('Class sym)) , Coercible a ('Class sym)- , KnownSymbol sym ) => [JValue] -> IO a@@ -286,6 +288,7 @@ class (Interp (Uncurry a) ~ ty, SingI ty) => Reflect a ty where reflect :: a -> IO (J ty) +#if ! __GLASGOW_HASKELL__ == 800 foreign import ccall "wrapper" wrapFinalizer :: (Ptr a -> IO ()) -> IO (FunPtr (Ptr a -> IO ()))@@ -314,6 +317,7 @@ jobj <- newfun (fromIntegral n) withForeignPtr fptr $ fill jobj 0 (fromIntegral n) return jobj+#endif withStatic [d| type instance Interp (J ty) = ty@@ -442,6 +446,9 @@ Text.useAsPtr x $ \ptr len -> newString ptr (fromIntegral len) +-- Instances can't be compiled on GHC 8.0.1 due to+-- https://ghc.haskell.org/trac/ghc/ticket/12082.+#if ! __GLASGOW_HASKELL__ == 800 type instance Interp (IOVector Int32) = 'Array ('Prim "int") instance Reify (IOVector Int32) ('Array ('Prim "int")) where@@ -457,6 +464,7 @@ instance Reflect (Vector Int32) ('Array ('Prim "int")) where reflect = reflect <=< Vector.thaw+#endif type instance Interp [a] = 'Array (Interp (Uncurry a))