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

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

Please see README.md.


[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
Maintainer alp.mestanogullari@tweag.io
Revised Revision 1 made by HerbertValerioRiedel at 2016-12-27T12:57:10Z
Category FFI, JVM, Java
Home page http://github.com/tweag/inline-java#readme
Source repo head: git clone https://github.com/tweag/inline-java
Uploaded by AlpMestanogullari at 2016-04-25T12:39:44Z
Distributions NixOS:0.10.0
Downloads 10208 total (81 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]

Modules

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

Downloads

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

Candidates


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.

Example

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)
    callStatic
      (classOf (undefined :: JOptionPane))
      "showMessageDialog"
      [JObject nullComponent, JObject (upcast message)]
  where
    nullComponent :: J ('Class "java.awt.Component")
    nullComponent = jnull

License

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.

About

Tweag I/O

Sparkle is maintained by Tweag I/O.

Have questions? Need help? Tweet at @tweagio.