packages feed

inline-java 0.7.0 → 0.7.1

raw patch · 5 files changed

+33/−24 lines, 5 filesdep ~jnidep ~jvm

Dependency ranges changed: jni, jvm

Files

CHANGELOG.md view
@@ -6,6 +6,11 @@  ## Next release +### Added++### Changed++ ## [0.7.0] - 2017-08-31  ### Added
README.md view
@@ -4,9 +4,6 @@  **NOTE 1: you'll need GHC >= 8.0.2 to compile and use this package.** -**NOTE 2: you'll need Stack HEAD (future v1.6) to compile with GHC >=-8.2.1. It is recommended to stick to GHC-8.0.2 for now.**- The Haskell standard includes a native foreign function interface (FFI). Using it can be a bit involved and only C support is implemented in GHC. `inline-java` lets you call any JVM function
inline-java.cabal view
@@ -1,5 +1,5 @@ name:                inline-java-version:             0.7.0+version:             0.7.1 synopsis:            Java interop via inline Java code in Haskell modules. description:         Please see README.md. homepage:            http://github.com/tweag/inline-java#readme@@ -36,20 +36,20 @@     Language.Java.Inline.Magic   build-depends:     -- Can't build at all with GHC < 8.0.2.-    base > 4.9.0.0 && < 5,+    base >4.9.0.0 && <5,     bytestring >=0.10,-    Cabal >= 1.24.2,+    Cabal >=1.24.2,     directory >=1.2,-    filepath >= 1,-    ghc >= 8.0.2 && < 8.3,-    jni >= 0.4,-    jvm >= 0.3,-    language-java >= 0.2,-    mtl >= 2.2.1,-    process >= 1.2,+    filepath >=1,+    ghc >=8.0.2 && <8.3,+    jni >=0.4 && <0.6,+    jvm >=0.4 && <0.5,+    language-java >=0.2,+    mtl >=2.2.1,+    process >=1.2,     text >=1.2,-    template-haskell >= 2.10,-    temporary >= 1.2+    template-haskell >=2.10,+    temporary >=1.2   default-language: Haskell2010  test-suite spec
src/Language/Java/Inline/Magic.hsc view
@@ -5,6 +5,7 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveLift #-}+{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE LambdaCase #-}@@ -37,7 +38,7 @@ import GHC.Stack (HasCallStack, withFrozenCallStack) import GHC.TypeLits (Nat, Symbol) import qualified Language.Haskell.TH.Syntax as TH-import Language.Java (Coercible)+import Language.Java (Coercible, Ty)  #include "bctable.h" @@ -96,7 +97,7 @@      (line :: Nat)       -- line number of the quasiquotation      args_tuple          -- uncoerced argument types      b.                  -- uncoerced result type-     (Coercibles args_tuple args_tys, Coercible b tyres, HasCallStack)+     (tyres ~ Ty b, Coercibles args_tuple args_tys, Coercible b, HasCallStack)   => Proxy input   -> Proxy mname   -> Proxy antiqs@@ -112,4 +113,4 @@  class Coercibles xs (tys :: k) | xs -> tys instance Coercibles () ()-instance (Coercible x ty, Coercibles xs tys) => Coercibles (x, xs) '(ty, tys)+instance (ty ~ Ty x, Coercible x, Coercibles xs tys) => Coercibles (x, xs) '(ty, tys)
src/Language/Java/Inline/Plugin.hs view
@@ -23,6 +23,7 @@ import qualified Data.Text as Text import qualified Data.Text.Encoding as Text import ErrUtils (ghcExit)+import FamInstEnv (normaliseType) import Foreign.JNI.Types (JType(..)) import GhcPlugins import IfaceEnv (lookupOrigNameCache)@@ -61,7 +62,9 @@   where     install :: [CommandLineOption] -> [CoreToDo] -> CoreM [CoreToDo]     install args todo = do+#if !MIN_VERSION_ghc(8,2,1)       reinitializeGlobals+#endif       return (CoreDoPluginPass "inline-java" (qqPass args) : todo)      qqPass :: [CommandLineOption] -> ModGuts -> CoreM ModGuts@@ -73,7 +76,7 @@         Just qqMarkerName -> do           (binds, qqOccs) <- collectQQMarkers qqMarkerName (mg_binds guts)           let jimports = getModuleAnnotations guts :: [JavaImport]-          dcs <- buildJava qqOccs jimports+          dcs <- buildJava guts qqOccs jimports                    >>= maybeDumpJava args                    >>= buildBytecode           return guts@@ -136,8 +139,8 @@ -- -- Where @inline_method_i@ is the method corresponding to the @ith@ -- quasiquotation.-buildJava :: [QQOcc] -> [JavaImport] -> CoreM Builder-buildJava qqOccs jimports = do+buildJava :: ModGuts -> [QQOcc] -> [JavaImport] -> CoreM Builder+buildJava guts qqOccs jimports = do     let importsJava = mconcat           [ mconcat [ "import ", Builder.stringUtf8 jimp                     , "; // .hs:", Builder.integerDec n@@ -145,9 +148,12 @@                     ]           | JavaImport jimp n <- jimports           ]+    p_fam_env <- getPackageFamInstEnv+    let fam_envs = (p_fam_env, mg_fam_inst_env guts)     methods <- forM qqOccs $ \QQOcc {..} -> do+      let (_, normty) = normaliseType fam_envs Nominal (expandTypeSynonyms qqOccResTy)       jTypeNames <- findJTypeNames-      resty <- case toJavaType jTypeNames (expandTypeSynonyms qqOccResTy) of+      resty <- case toJavaType jTypeNames normty of         Just resty -> return resty         Nothing -> failWith $ hsep           [ parens (text "line" <+> integer qqOccLineNumber) <> ":"@@ -350,14 +356,14 @@      expMarkers :: CoreExpr -> QQJavaM CoreExpr     expMarkers (App (App (App (App (App (App (App (App (App (App (App (App (App-                 (App (App (App (App (App (App (Var fid) _)+                 (App (App (App (App (App (App (App (Var fid) _)                  (Type (parseArgTys -> Just tyargs)))                  (Type tyres))                  (Type (LitTy (StrTyLit fs_input))))                  (Type (LitTy (StrTyLit fs_mname))))                  (Type (LitTy (StrTyLit fs_antiqs))))                  (Type (LitTy (NumTyLit lineNumber))))-                 _) _) _) _) _) _) _) _) _) _) _)+                 _) _) _) _) _) _) _) _) _) _) _) _)                  e                )         | qqMarkerName == idName fid = do