I am trying to run the very first example in this tutorial:
module Main where
{-# LANGUAGE QuasiQuotes #-}
{-# OPTIONS_GHC -fplugin=Language.Java.Inline.Plugin #-}
import Language.Java (withJVM)
import Language.Java.Inline
main :: IO ()
main = withJVM [] [java| { System.out.println("Hello Java!"); } |]
and I get this error:
app\Main.hs:8:26: error: parse error on input `{'
|
8 | main = withJVM [] [java| { System.out.println("Hello Java!"); } |]
| ^
What am I doing wrong?
The
{-# LANGUAGE … #-}and{-# OPTIONS_GHC … #-}pragmas need to be defined before themodule Maindeclaration. Otherwise it will not enable theQuasiQuoteslanguage extension, and thus not understand the quasiquotes used in the program.If you install the
inline-javaand put the language pragmas before themodule Main:It should normally interpret the quasiquotes properly.