7b545e60146d8f501a1022efa50c2c78d0a30d76
[sbp.git] / src / HaskellDemo.hs
1 -- This is written in Haskell.
2 {--
3 JVM-Bridge -- bridge from FP languages and others to the Java VM
4 Copyright (C) 2001 Ashley Yakeley <ashley@semantic.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 --}
20
21 module Main where
22         {
23         import Header_Java;
24         import Class_edu_berkeley_sbp_misc_HaskellHelper;
25         import Class_java_lang_Object;
26         import Class_java_lang_Class;
27         import Class_java_lang_String;
28
29         import Class_edu_berkeley_sbp_Tree;
30
31         import JVM_edu_berkeley_sbp_misc_HaskellHelper;
32         import TypedString;
33         import JVMBridge;
34         import JavaText;
35
36         main :: IO ();
37         main = runWithClasspath ["edu.berkeley.sbp.jar"]
38                 ((do
39                     class_JHaskellHelper
40                     s1   <- new_JString_ArrayJchar $ toJavaString "tests/meta.g"
41                     s2   <- new_JString_ArrayJchar $ toJavaString "tests/testcase.g"
42                     tree <- main_JHaskellHelper_JString_JString (s1, s2)
43                     strx <- toString_JObject ((castTLRef tree) :: Jjava_lang_Object) ()
44                     str  <- getStringUTF strx
45                     callIO $ putStrLn $ showUTF8 str
46                     return ()
47                  ) :: JVM ())
48         }