Safe Haskell | None |
---|---|
Language | Haskell2010 |
Inline Java quasiquotation
See the GHC manual for an introduction to quasiquotation. The quasiquoter exported in this module allows embedding arbitrary Java expressions and blocks of statements inside Haskell code. You can call any Java method and define arbitrary inline code using Java syntax. No FFI required.
Here is the same example as in Language.Java, but with inline Java calls:
{-# LANGUAGE DataKinds #-} {-# LANGUAGE QuasiQuotes #-} module Object where import Language.Java as J import Language.Java.Inline newtype Object = Object (J
('Class
"java.lang.Object")) instanceCoercible
Object clone :: Object -> IO Object clone obj = [java| $obj.clone() |] equals :: Object -> Object -> IO Bool equals obj1 obj2 = [java| $obj1.equals($obj2) |] ...
Synopsis
- javaWithConfig :: QQConfig -> QuasiQuoter
- data QQConfig = QQConfig {
- qqMarker :: Name
- qqCallStatic :: [ExpQ] -> ExpQ
- qqWrapMarker :: ExpQ -> ExpQ
- imports :: String -> Q [Dec]
- loadJavaWrappers :: IO ()
Documentation
javaWithConfig :: QQConfig -> QuasiQuoter Source #
Customizes how quasiquotations are desugared.
QQConfig | |
|
imports :: String -> Q [Dec] Source #
Declares import statements to be included in the java compilation unit. e.g.
imports "java.util.*"
loadJavaWrappers :: IO () Source #
Idempotent action that loads all wrappers in every module of the current program into the JVM. You shouldn't need to call this yourself.