inline-java-0.9.1: Java interop via inline Java code in Haskell modules.
Safe HaskellNone
LanguageHaskell2010

Language.Java.Inline.Internal

Description

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"))
instance Coercible Object

clone :: Object -> IO Object
clone obj = [java| $obj.clone() |]

equals :: Object -> Object -> IO Bool
equals obj1 obj2 = [java| $obj1.equals($obj2) |]

...
Synopsis

Documentation

data QQConfig Source #

Customizes how quasiquotations are desugared.

Constructors

QQConfig 

Fields

  • qqMarker :: Name

    This is the name of the function to use to indicate to the plugin the presence of a java quasiquotation.

  • qqCallStatic :: [ExpQ] -> ExpQ

    This produces the call invoke the Java stub. It takes the list of arguments that should be passed to the call.

  • qqWrapMarker :: ExpQ -> ExpQ

    This is given as argument the invocation of the Java stub, and is expected to prepend it with code that ensures that the stub is previously loaded in the JVM.

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.