haskell scala interoperability
Asked Answered
P

2

5

I am a Scala beginner and coming from Object Oriented Paradigm. While understanding Functional programming part of Scala, I was directed to Haskell - the pure Functional programming language.

Exploring SO question-answers, I found that Java - Haskell has interoperability.

I am curious to know that similarly does Scala-Haskell interoperability exist or not?

Can a function library written in Haskell be used in Scala application?

As per answer given by Don Stewart: It is possible.

Integration of Haskell Function Library in Scala application will be straight and easy or will require complicated tweaks?

With integrated Haskell Function Library, the Scala application will run on JVM or will require different arrangement?

Precipitin answered 22/6, 2012 at 19:19 Comment(1)
If there's Java–Haskell interop, then using Scala in Haskell should be no different to using Java. Scala compiles to regular Java classes, albeit with some extra runtime support from Scala "builtins".Grenade
W
4

I found that Java - Haskell has interoperability. I am curious to know that similarly does Scala-Haskell interoperability exist or not?

Well given that interoperability is transitive, and given that (hj_interop : Haskell <-> Java) and (js_interop : Java <-> Scala), we therefore conclude that Haskell <-> Scala.

If you want Haskell -> Scala, then just take Haskell -> Java from hj_interop, and Java -> Scala from js_interop. If you want Scala -> Haskell, then just take Scala -> Java from js_interop, and Java -> Haskell from hj_interop.

This isn't a very hand-holdy explanation of how to accomplish Haskell - Scala interoperability, but given existing interoperatilities, you just compose them in the obvious way. Scala does not provide any direct, convenient interoperability with Haskell that I am aware of, other than providing scalaz to add an extra Haskell-y feel to Scala. Haskell does not provide any direct, convenient interoperability with Scala that I am aware of.

Wifely answered 22/6, 2012 at 22:35 Comment(3)
What can be the performance issues, if Scala -> Haskell is achieved by , by using Scala -> Java from js_interop, and Java -> Haskell from hs_interop. Here the main purpose is to get benefit of haskell's heavy Functionall Programming Strengths.Precipitin
scala <-> java interop has effectively zero cost. All that said, if you want to write Haskell-like code in scala, just install scalaz and write a lot more type signatures. :)Fluster
You might be interested to the Frege project ( code.google.com/p/frege ), which puts a very Haskell-like language on the JVM. I admit the Java interoperability has still room for improvement, but is built in, and the compiler emits very funny Java source files.Bloodstone
B
4

It is possible, but I am not aware of any examples.

Barytone answered 22/6, 2012 at 19:21 Comment(2)
It will be complicated if you try and link the JVM and GHC rts together. It will be easy if you communicate through a protocol, e.g. JSON.Barytone
I mean...in some ways, I almost want to ask if it'd be easier to compile C-- and the like to Java bytecode, though linking the RTS back in would make things...interesting.Vestpocket
W
4

I found that Java - Haskell has interoperability. I am curious to know that similarly does Scala-Haskell interoperability exist or not?

Well given that interoperability is transitive, and given that (hj_interop : Haskell <-> Java) and (js_interop : Java <-> Scala), we therefore conclude that Haskell <-> Scala.

If you want Haskell -> Scala, then just take Haskell -> Java from hj_interop, and Java -> Scala from js_interop. If you want Scala -> Haskell, then just take Scala -> Java from js_interop, and Java -> Haskell from hj_interop.

This isn't a very hand-holdy explanation of how to accomplish Haskell - Scala interoperability, but given existing interoperatilities, you just compose them in the obvious way. Scala does not provide any direct, convenient interoperability with Haskell that I am aware of, other than providing scalaz to add an extra Haskell-y feel to Scala. Haskell does not provide any direct, convenient interoperability with Scala that I am aware of.

Wifely answered 22/6, 2012 at 22:35 Comment(3)
What can be the performance issues, if Scala -> Haskell is achieved by , by using Scala -> Java from js_interop, and Java -> Haskell from hs_interop. Here the main purpose is to get benefit of haskell's heavy Functionall Programming Strengths.Precipitin
scala <-> java interop has effectively zero cost. All that said, if you want to write Haskell-like code in scala, just install scalaz and write a lot more type signatures. :)Fluster
You might be interested to the Frege project ( code.google.com/p/frege ), which puts a very Haskell-like language on the JVM. I admit the Java interoperability has still room for improvement, but is built in, and the compiler emits very funny Java source files.Bloodstone

© 2022 - 2024 — McMap. All rights reserved.