add experimental Haskell bindings
[sbp.git] / src / HaskellDemo.hs
diff --git a/src/HaskellDemo.hs b/src/HaskellDemo.hs
new file mode 100644 (file)
index 0000000..7b545e6
--- /dev/null
@@ -0,0 +1,48 @@
+-- This is written in Haskell.
+{--
+JVM-Bridge -- bridge from FP languages and others to the Java VM
+Copyright (C) 2001 Ashley Yakeley <ashley@semantic.org>
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+--}
+
+module Main where
+        {
+        import Header_Java;
+        import Class_edu_berkeley_sbp_misc_HaskellHelper;
+        import Class_java_lang_Object;
+        import Class_java_lang_Class;
+        import Class_java_lang_String;
+
+        import Class_edu_berkeley_sbp_Tree;
+
+        import JVM_edu_berkeley_sbp_misc_HaskellHelper;
+        import TypedString;
+        import JVMBridge;
+        import JavaText;
+
+        main :: IO ();
+        main = runWithClasspath ["edu.berkeley.sbp.jar"]
+                ((do
+                    class_JHaskellHelper
+                    s1   <- new_JString_ArrayJchar $ toJavaString "tests/meta.g"
+                    s2   <- new_JString_ArrayJchar $ toJavaString "tests/testcase.g"
+                    tree <- main_JHaskellHelper_JString_JString (s1, s2)
+                    strx <- toString_JObject ((castTLRef tree) :: Jjava_lang_Object) ()
+                    str  <- getStringUTF strx
+                    callIO $ putStrLn $ showUTF8 str
+                    return ()
+                 ) :: JVM ())
+        }