Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot find symbol »class β« in generated java code #285

Closed
mabre opened this issue Jun 12, 2016 · 1 comment
Closed

cannot find symbol »class β« in generated java code #285

mabre opened this issue Jun 12, 2016 · 1 comment

Comments

@mabre
Copy link

mabre commented Jun 12, 2016

Frege 3.24.100 does not generate valid java code for this frege code, unless one of the type signatures is provided or new_acc seq`` is removed. Frege 3.23.451 and ghc can compile run the code.

module Lexer 
where

main :: IO ()
main = case alexScan "lorem" 42 of
            Nothing -> print 1

-- alexScan :: String -> Integer -> Maybe String
alexScan "foo" sc = Nothing
alexScan input sc = alexScanUser undefined input sc

-- alexMonadScan :: String
alexMonadScan = do
  case alexScan "foo" 1 of 
    Nothing -> "eof"

-- alexScanUser :: a -> String -> Integer -> Maybe b
alexScanUser user input sc
  = case alex_scan_tkn input "" of
      ("", input') -> Nothing

-- alex_scan_tkn :: String -> String -> (String, String)
alex_scan_tkn input last_acc =
  let new_acc = alexMonadScan in
    new_acc `seq` (last_acc, input)
calling: javac -cp /home/markus/Downloads/frege/frege3.24.100.jar:. -d . -sourcepath . -encoding UTF-8 ./Lexer.java 
./Lexer.java:108: error: cannot find symbol
                      PreludeBase.<β>undefined(), Thunk.<String/*<Character>*/>lazy(arg$1), arg$2
                                   ^
  symbol:   class β
  location: class Lexer
./Lexer.java:107: error: cannot find symbol
            (Lazy<PreludeBase.TMaybe<α>>)(() -> Lexer.<β, α>alexScanUser(
                                                       ^
  symbol:   class β
  location: class Lexer
2 errors
E CannotFindSymbol.hs:27: java compiler errors are most
    likely caused by erroneous native definitions
@Ingo60
Copy link
Member

Ingo60 commented Jun 12, 2016

Java doesn't allow unknown types coming out of nowhere, instead all such types must be declared in advance.

Since the type of undefined in the application of alexScanUser doesn't influence the type of the function alexScan there is no such type.

Workaround would be to just pass something that does have a known type. Since the argument is not used, any type would do. Even

(undefined::Bool)

does work.

@Ingo60 Ingo60 added the wontfix label Mar 25, 2018
@Ingo60 Ingo60 closed this as completed Mar 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants