packages feed

inline-java 0.6 → 0.6.1

raw patch · 4 files changed

+16/−16 lines, 4 filesdep ~jnidep ~jvm

Dependency ranges changed: jni, jvm

Files

README.md view
@@ -4,9 +4,9 @@  **NOTE: you'll need GHC >= 8.0.2 to compile and use this package. Use** ```-stack --nix --stack-yaml stack-HEAD.yaml build+stack --nix build ```-**ahead of a new GHC release to build using GHC HEAD.**+**ahead of a new GHC release to build using GHC 8.0.2-rc2.**  The Haskell standard includes a native foreign function interface (FFI). It can be a pain to use and in any case only C support is
inline-java.cabal view
@@ -1,5 +1,5 @@ name:                inline-java-version:             0.6+version:             0.6.1 synopsis:            Java interop via inline Java code in Haskell modules. description:         Please see README.md. homepage:            http://github.com/tweag/inline-java#readme
src/Language/Java/Inline.hs view
@@ -50,8 +50,8 @@   ) where  import Control.Monad (forM_, unless)-import Control.Monad.Fix (mfix) import qualified Data.ByteString.Char8 as BS+import Data.Char (isAlphaNum) import Data.Generics (everything, mkQ) import Data.List (intercalate, isPrefixOf, isSuffixOf) import Data.Maybe (fromJust)@@ -170,8 +170,9 @@   | nm == 'Array = unliftJType ty >>= \case SomeSing jty -> return $ SomeSing (SArray jty) unliftJType (TH.AppT (TH.AppT (TH.PromotedT _nm) _ty) _tys) =     error "unliftJType (Generic): Unimplemented."-unliftJType (TH.AppT (TH.ConT nm) lit@(TH.LitT (TH.StrTyLit _))) =-    unliftJType $ TH.AppT (TH.PromotedT nm) lit+-- Sometimes TH uses ConT for PromotedT. Pretend it's always PromotedT.+unliftJType (TH.AppT (TH.ConT nm) ty) =+    unliftJType $ TH.AppT (TH.PromotedT nm) ty unliftJType (TH.PromotedT nm)   | nm == 'Void = return $ SomeSing SVoid unliftJType ty = fail $ "unliftJType: cannot unlift " ++ show (TH.ppr ty)@@ -319,9 +320,7 @@  mangle :: TH.Module -> String mangle (TH.Module (TH.PkgName pkgname) (TH.ModName mname)) =-    "Inline__" ++ pkgname ++ "_" ++ map (\case '.' -> '_'; x -> x) mname--data Some = forall ty. Some (IO (J ty))+    "Inline__" ++ filter isAlphaNum pkgname ++ "_" ++ map (\case '.' -> '_'; x -> x) mname  blockOrExpQQ :: String -> Q TH.Exp blockOrExpQQ txt@(words -> toks) -- ignore whitespace
tests/Language/Java/InlineSpec.hs view
@@ -6,6 +6,7 @@  import Data.Int import Foreign.JNI.Types (JObject)+import Language.Java import Language.Java.Inline import Test.Hspec @@ -13,31 +14,31 @@ spec = do     describe "Java quasiquoter" $ do       it "Evaluates simple expressions" $ do-        [java| 1 + 1 |] `shouldReturn` (2 :: Int32)+        ([java| 1 + 1 |] >>= reify) `shouldReturn` (2 :: Int32)        it "Evaluates simple blocks" $ do-        [java| {+        ([java| {              int x = 1;              int y = 2;              return x + y;-           } |] `shouldReturn` (3 :: Int32)+           } |] >>= reify) `shouldReturn` (3 :: Int32)        it "Supports antiquotation variables" $ do         let x = 1 :: Int32-        [java| $x + 1 |] `shouldReturn` (2 :: Int32)+        ([java| $x + 1 |] >>= reify) `shouldReturn` (2 :: Int32)        it "Supports multiple antiquotation variables" $ do         let foo = 1 :: Int32             bar = 2 :: Int32-        [java| $foo + $bar |] `shouldReturn` (3 :: Int32)+        ([java| $foo + $bar |] >>= reify) `shouldReturn` (3 :: Int32)        it "Supports antiquotation variables in blocks" $ do         let z = 1 :: Int32-        [java| { return $z + 1; } |] `shouldReturn` (2 :: Int32)+        ([java| { return $z + 1; } |] >>= reify) `shouldReturn` (2 :: Int32)        it "Supports anonymous classes" $ do         _ :: JObject <- [java| new Object() {} |]         return ()        it "Supports multiple anonymous classes" $ do-        [java| new Object() {}.equals(new Object() {}) |] `shouldReturn` False+        ([java| new Object() {}.equals(new Object() {}) |] >>= reify) `shouldReturn` False