Integrating Haskell into a J2EE environment

Hi All, I am new to Haskell and this mailing list. We have a system that uses a custom high-level language to express high-level business rules. Expressions in the high-level language get compiled to Java bytecode. We express the grammar using BNF notation as required by the javacc parser tool. This is then converted to an AST using jjtree and from there we build the final Java code. Our language could be considered a domain-specific language (DSL) and is used by our business users to express very high-level business logic. The language currently is very limited - we support boolean logic, function invocations and if-then statements. We want to convert it into a more powerful scripting language so that even lower level business logic can be expressed in it. I came across a few papers that talk about writing a DSL with Haskell as the underlying support language. How is this done. Is it possible to create a sort of domain specific business scripting language easily. How does that then compile to Haskell code. And how can the Haskell code be invoked from Java. Essentially, I am thinking if I could use a Haskell like DSL language to express our business rule logic and then be able to integrate into and invoke the logic from a J2EE app server environment. Has anybody done anything like this with Haskell. -- Shoeb

You're going to spend alot of time marshalling between Java and Haskell values, and you'll either have to do it via JNI or by using pipes [as in System.exec("haskellprogram param param param")], both of which are ugly for a Java app. Have you looked at Jython and JRuby? Jython is an implementation of a Python interpreter in 100% Java, and JRuby implements a Ruby interpreter in 100% Java. Those might get the job done faster than having to delve into the native layer. (Not to mention learning how to use Haskell in order to implement what you want--not a trivial task in itself!) Take care, --doug On Oct 5, 2004, at 4:33 PM, Bhinderwala, Shoeb wrote: Hi All, I am new to Haskell and this mailing list. We have a system that uses a custom high-level language to express high-level business rules. Expressions in the high-level language get compiled to Java bytecode. We express the grammar using BNF notation as required by the javacc parser tool. This is then converted to an AST using jjtree and from there we build the final Java code. Our language could be considered a domain-specific language (DSL) and is used by our business users to express very high-level business logic. The language currently is very limited - we support boolean logic, function invocations and if-then statements. We want to convert it into a more powerful scripting language so that even lower level business logic can be expressed in it. I came across a few papers that talk about writing a DSL with Haskell as the underlying support language. How is this done. Is it possible to create a sort of domain specific business scripting language easily. How does that then compile to Haskell code. And how can the Haskell code be invoked from Java. Essentially, I am thinking if I could use a Haskell like DSL language to express our business rule logic and then be able to integrate into and invoke the logic from a J2EE app server environment. Has anybody done anything like this with Haskell. -- Shoeb _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe This communication is confidential and may be legally privileged. If you are not the intended recipient, (i) please do not read or disclose to others, (ii) please notify the sender by reply mail, and (iii) please delete this communication from your system. Failure to follow this process may be unlawful. Thank you for your cooperation.

I wouldn't write off Haskell so quickly. All of what Shoeb describes concerning DSL issues might be much more easily solved in Haskell, and will certainly be more flexible than a hard-wired approach. The J2EE interface might be ugly, but if the functionality needed is not too great it might not be too bad. Generally speaking, these kinds of apps -- in this case "a DSL for high-level business rules" -- sounds like just the sort of thing that Haskell is good for. -Paul Doug Kirk wrote:
You're going to spend alot of time marshalling between Java and Haskell values, and you'll either have to do it via JNI or by using pipes [as in System.exec("haskellprogram param param param")], both of which are ugly for a Java app.
Have you looked at Jython and JRuby? Jython is an implementation of a Python interpreter in 100% Java, and JRuby implements a Ruby interpreter in 100% Java.
Those might get the job done faster than having to delve into the native layer. (Not to mention learning how to use Haskell in order to implement what you want--not a trivial task in itself!)
Take care, --doug
On Oct 5, 2004, at 4:33 PM, Bhinderwala, Shoeb wrote:
Hi All,
I am new to Haskell and this mailing list.
We have a system that uses a custom high-level language to express high-level business rules. Expressions in the high-level language get compiled to Java bytecode. We express the grammar using BNF notation as required by the javacc parser tool. This is then converted to an AST using jjtree and from there we build the final Java code. Our language could be considered a domain-specific language (DSL) and is used by our business users to express very high-level business logic. The language currently is very limited - we support boolean logic, function invocations and if-then statements. We want to convert it into a more powerful scripting language so that even lower level business logic can be expressed in it.
I came across a few papers that talk about writing a DSL with Haskell as the underlying support language. How is this done. Is it possible to create a sort of domain specific business scripting language easily. How does that then compile to Haskell code. And how can the Haskell code be invoked from Java.
Essentially, I am thinking if I could use a Haskell like DSL language to express our business rule logic and then be able to integrate into and invoke the logic from a J2EE app server environment. Has anybody done anything like this with Haskell.
-- Shoeb _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
This communication is confidential and may be legally privileged. If you are not the intended recipient, (i) please do not read or disclose to others, (ii) please notify the sender by reply mail, and (iii) please delete this communication from your system. Failure to follow this process may be unlawful. Thank you for your cooperation. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Professor Paul Hudak Chair, Dept of Computer Science Office: (203) 432-1235 Yale University FAX: (203) 432-0593 P.O. Box 208285 email: paul.hudak@yale.edu New Haven, CT 06520-8285 WWW: www.cs.yale.edu/~hudak

Yes, I agree, and didn't mean to write off Haskell (at which, I'm completely a newbie, trying to learn, and thankful for your book!). However, I'm a Java pro, and there are many technical issues on the Java side that scream at me to keep out of the native arena, especially in a J2EE container environment, where funny things can happen with hot reloads (dumping old ClassLoaders for new ones), clustering, and the like. So it wasn't out of denigration of Haskell that I made my recommendation; far from it...from what I've seen Haskell is perfect for implementing DSL's. Rather, from the Java side is where it becomes problematic. There have been many problems integrating with native libraries from within a J2EE container, and I try to seek the most cost-effective way (I'm an independent consultant) to get the problem solved for my customers. --doug On Oct 6, 2004, at 2:59 PM, Paul Hudak wrote: I wouldn't write off Haskell so quickly. All of what Shoeb describes concerning DSL issues might be much more easily solved in Haskell, and will certainly be more flexible than a hard-wired approach. The J2EE interface might be ugly, but if the functionality needed is not too great it might not be too bad. Generally speaking, these kinds of apps -- in this case "a DSL for high-level business rules" -- sounds like just the sort of thing that Haskell is good for. -Paul Doug Kirk wrote:
You're going to spend alot of time marshalling between Java and Haskell values, and you'll either have to do it via JNI or by using pipes [as in System.exec("haskellprogram param param param")], both of which are ugly for a Java app. Have you looked at Jython and JRuby? Jython is an implementation of a Python interpreter in 100% Java, and JRuby implements a Ruby interpreter in 100% Java. Those might get the job done faster than having to delve into the native layer. (Not to mention learning how to use Haskell in order to implement what you want--not a trivial task in itself!) Take care, --doug On Oct 5, 2004, at 4:33 PM, Bhinderwala, Shoeb wrote: Hi All, I am new to Haskell and this mailing list. We have a system that uses a custom high-level language to express high-level business rules. Expressions in the high-level language get compiled to Java bytecode. We express the grammar using BNF notation as required by the javacc parser tool. This is then converted to an AST using jjtree and from there we build the final Java code. Our language could be considered a domain-specific language (DSL) and is used by our business users to express very high-level business logic. The language currently is very limited - we support boolean logic, function invocations and if-then statements. We want to convert it into a more powerful scripting language so that even lower level business logic can be expressed in it. I came across a few papers that talk about writing a DSL with Haskell as the underlying support language. How is this done. Is it possible to create a sort of domain specific business scripting language easily. How does that then compile to Haskell code. And how can the Haskell code be invoked from Java. Essentially, I am thinking if I could use a Haskell like DSL language to express our business rule logic and then be able to integrate into and invoke the logic from a J2EE app server environment. Has anybody done anything like this with Haskell. -- Shoeb _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe This communication is confidential and may be legally privileged. If you are not the intended recipient, (i) please do not read or disclose to others, (ii) please notify the sender by reply mail, and (iii) please delete this communication from your system. Failure to follow this process may be unlawful. Thank you for your cooperation. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Professor Paul Hudak Chair, Dept of Computer Science Office: (203) 432-1235 Yale University FAX: (203) 432-0593 P.O. Box 208285 email: paul.hudak@yale.edu New Haven, CT 06520-8285 WWW: www.cs.yale.edu/~hudak This communication is confidential and may be legally privileged. If you are not the intended recipient, (i) please do not read or disclose to others, (ii) please notify the sender by reply mail, and (iii) please delete this communication from your system. Failure to follow this process may be unlawful. Thank you for your cooperation.

I'm surprised that nobody has yet mentioned the ICFP2000 paper "Composing Contracts: An Adventure in Financial Engineering" by SPJ, Jean-Marc Eber, and Julian Seward. It seems to me that it could provide quite relevant reading. Björn Lisper Paul Hudak:
I wouldn't write off Haskell so quickly. All of what Shoeb describes concerning DSL issues might be much more easily solved in Haskell, and will certainly be more flexible than a hard-wired approach. The J2EE interface might be ugly, but if the functionality needed is not too great it might not be too bad. Generally speaking, these kinds of apps -- in this case "a DSL for high-level business rules" -- sounds like just the sort of thing that Haskell is good for.
-Paul
Doug Kirk wrote:
You're going to spend alot of time marshalling between Java and Haskell values, and you'll either have to do it via JNI or by using pipes [as in System.exec("haskellprogram param param param")], both of which are ugly for a Java app.
Have you looked at Jython and JRuby? Jython is an implementation of a Python interpreter in 100% Java, and JRuby implements a Ruby interpreter in 100% Java.
Those might get the job done faster than having to delve into the native layer. (Not to mention learning how to use Haskell in order to implement what you want--not a trivial task in itself!)
Take care, --doug
On Oct 5, 2004, at 4:33 PM, Bhinderwala, Shoeb wrote:
Hi All,
I am new to Haskell and this mailing list.
We have a system that uses a custom high-level language to express high-level business rules. Expressions in the high-level language get compiled to Java bytecode. We express the grammar using BNF notation as required by the javacc parser tool. This is then converted to an AST using jjtree and from there we build the final Java code. Our language could be considered a domain-specific language (DSL) and is used by our business users to express very high-level business logic. The language currently is very limited - we support boolean logic, function invocations and if-then statements. We want to convert it into a more powerful scripting language so that even lower level business logic can be expressed in it.
I came across a few papers that talk about writing a DSL with Haskell as the underlying support language. How is this done. Is it possible to create a sort of domain specific business scripting language easily. How does that then compile to Haskell code. And how can the Haskell code be invoked from Java.
Essentially, I am thinking if I could use a Haskell like DSL language to express our business rule logic and then be able to integrate into and invoke the logic from a J2EE app server environment. Has anybody done anything like this with Haskell.
-- Shoeb _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
This communication is confidential and may be legally privileged. If you are not the intended recipient, (i) please do not read or disclose to others, (ii) please notify the sender by reply mail, and (iii) please delete this communication from your system. Failure to follow this process may be unlawful. Thank you for your cooperation. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Professor Paul Hudak Chair, Dept of Computer Science Office: (203) 432-1235 Yale University FAX: (203) 432-0593 P.O. Box 208285 email: paul.hudak@yale.edu New Haven, CT 06520-8285 WWW: www.cs.yale.edu/~hudak
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Tuesday 05 October 2004 23:33, Bhinderwala, Shoeb wrote:
I came across a few papers that talk about writing a DSL with Haskell as the underlying support language. How is this done. Is it possible to create a sort of domain specific business scripting language easily. How does that then compile to Haskell code. And how can the Haskell code be invoked from Java.
You usually write a DSL in haskell as a library, using monads or arrows if it is the case, and exploiting monads and arrows syntax facilities. Names in libraries represent operations of the DSL, and do not (of course) necessarily compute results, but can do many things, including generating source code for another language - you can find a lot of information on the web, e.g. http://www.cs.uu.nl/~daan/download/papers/dsec.ps http://homepages.cwi.nl/~arie/papers/dslbib/ One of the most known examples is FRAN (or the more up-to-date Yampa), but there actually are a lot of applications from very different domains. bye Vincenzo
participants (5)
-
Bhinderwala, Shoeb
-
Bjorn Lisper
-
Doug Kirk
-
Paul Hudak
-
Vincenzo Ciancia