inline-java: Java interop via inline Java code in Haskell modules.

[ bsd3, deprecated, ffi, java, jvm, library ] [ Propose Tags ]

Please see

[Skip to Readme]
Versions [RSS] [faq] 0.1, 0.5, 0.5.1, 0.6, 0.6.1, 0.6.2, 0.6.3, 0.6.4, 0.6.5, 0.7.0, 0.7.1, 0.7.2, 0.8.0, 0.8.1, 0.8.2, 0.8.3, 0.8.4, 0.9.0, 0.9.1, 0.10.0 (info)
Dependencies base (>=4.9.1 && <5), binary (>=0.7), bytestring (>=0.10), containers (>=0.5), distributed-closure (>=0.3), inline-c (>=0.5), singletons (>=2.0), text (>=1.2), thread-local-storage (>=0.1), vector (>=0.11) [details]
License BSD-3-Clause
Copyright 2015-2016 EURL Tweag.
Author Tweag I/O
Revised Revision 1 made by HerbertValerioRiedel at 2016-12-27T12:57:10Z
Category FFI, JVM, Java
Home page
Source repo head: git clone
Uploaded by AlpMestanogullari at 2016-04-25T12:39:44Z
Distributions NixOS:0.10.0
Downloads 10126 total (24 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs not available [build log]
All reported builds failed as of 2016-11-26 [all 2 reports]


  • Foreign
    • Foreign.JNI
  • Language
    • Language.Java


Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

For package maintainers and hackage trustees


Readme for inline-java-0.1

[back to package description]

inline-java: Call any JVM function from Haskell

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 implemented in GHC. inline-java lets you call any JVM function directly, from Haskell, without the need to write your own foreign import declarations using the FFI. In the style of inline-c for C and inline-r for calling R, inline-java lets you name any function to call inline in your code.

This is an early tech preview, not production ready.

Quasiquotation to make inline calls in Java syntax not yet implemented. But calls in Haskell syntax supported.


Graphical Hello World using Java Swing:

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}

import Data.Text (Text)
import Language.Java

newtype JOptionPane = JOptionPane (J ('Class "javax.swing.JOptionPane"))
instance Coercible JOptionPane ('Class "javax.swing.JOptionPane")

main :: IO ()
main = withJVM [] $ do
    message <- reflect ("Hello World!" :: Text)
      (classOf (undefined :: JOptionPane))
      [JObject nullComponent, JObject (upcast message)]
    nullComponent :: J ('Class "java.awt.Component")
    nullComponent = jnull


Copyright (c) 2015-2016 EURL Tweag.

All rights reserved.

Sparkle is free software, and may be redistributed under the terms specified in the LICENSE file.


Tweag I/O

Sparkle is maintained by Tweag I/O.

Have questions? Need help? Tweet at @tweagio.