robdockins / param-tlc

Example project demonstrating the use of the parameterized-utils library
BSD 3-Clause "New" or "Revised" License
6 stars 3 forks source link

Build error: Not in scope: ‘ifThenElse’ #1

Closed jtdaugherty closed 6 years ago

jtdaugherty commented 6 years ago

On GHC 8.0.1, cabal-install 2.0.0.1:

[3 of 3] Compiling TLC.TypeCheck    ( src/TLC/TypeCheck.hs, /Users/cygnus/src/param-tlc/dist-newstyle/build/x86_64-osx/ghc-8.0.1/param-tlc-0.1/build/TLC/TypeCheck.o )

src/TLC/TypeCheck.hs:65:28: error: Not in scope: ‘ifThenElse’

src/TLC/TypeCheck.hs:65:28: error: Not in scope: ‘ifThenElse’

src/TLC/TypeCheck.hs:65:28: error: Not in scope: ‘ifThenElse’

src/TLC/TypeCheck.hs:65:28: error: Not in scope: ‘ifThenElse’

src/TLC/TypeCheck.hs:65:28: error: Not in scope: ‘ifThenElse’

src/TLC/TypeCheck.hs:65:28: error: Not in scope: ‘ifThenElse’
robdockins commented 6 years ago

Hunh... I don't get that with GHC 8.2

This is related to the RebindableSyntax extension. You can turn it off and I think it should compile then; you'll just get slightly worse error messages from the typechecker.

I'm not sure why the standard ifThenElse combinator isn't in scope already...

jtdaugherty commented 6 years ago

I'm going to try GHC 8.2. With RebindableSyntax disabled, I now get:

src/TLC/TypeCheck.hs:153:15: error:
    • Ambiguous type variable ‘m0’ arising from a use of ‘throwError’
      prevents the constraint ‘(MonadError String m0)’ from being solved.
      Relevant bindings include
        fail :: String -> m0 a0 (bound at src/TLC/TypeCheck.hs:153:4)
      Probable fix: use a type annotation to specify what ‘m0’ should be.
      These potential instances exist:
        instance [safe] MonadError e (Either e)
          -- Defined in ‘Control.Monad.Error.Class’
        instance [safe] Monad m => MonadError e (ExceptT e m)
          -- Defined in ‘Control.Monad.Error.Class’
        ...plus 11 instances involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the expression:
        throwError $ unlines ["Error during typechecking", show tm, msg]
      In an equation for ‘fail’:
          fail msg
            = throwError $ unlines ["Error during typechecking", show tm, msg]
      In an equation for ‘verifyTyping’:
          verifyTyping scope env tm
            = case tm of {
                TmVar nm
                  -> case elemIndex nm scope of {
                       Just i -> ...
                       Nothing -> throwError $ unwords ... }
                TmInt n -> return $ TCResult AST.IntRepr (AST.TmInt n)
                TmBool b -> return $ TCResult AST.BoolRepr (AST.TmBool b)
                TmLe x y
                  -> do { TCResult AST.IntRepr x' <- verifyTyping scope env x;
                          .... }
                TmAdd x y
                  -> do { TCResult AST.IntRepr x' <- verifyTyping scope env x;
                          .... }
                TmNeg x
                  -> do { TCResult xtp x' <- verifyTyping scope env x;
                          .... }
                TmIte c x y
                  -> do { TCResult AST.BoolRepr c' <- verifyTyping scope env c;
                          .... }
                TmApp x y
                  -> do { TCResult (AST.ArrowRepr argTy outTy) x' <- verifyTyping
                                                                       scope env x;
                          .... }
                TmAbs nm tp x
                  -> do { Some argTy <- return $ typeToRepr tp;
                          .... }
                TmFix nm tp x
                  -> do { Some argTy <- return $ typeToRepr tp;
                          .... } }
            where
                fail msg = throwError $ unlines ["Error during typechecking", ....]
jtdaugherty commented 6 years ago

I get the above error also on GHC 8.2.2.

robdockins commented 6 years ago

Even stranger... I just rebuilt with 8.0.2 and I can't reproduce this error

jtdaugherty commented 6 years ago

I am running

robdockins commented 6 years ago

In the meantime, you can probably just comment out the fail definition. It has an ambuguous type because its not being used with RebindableSyntax turned off

jtdaugherty commented 6 years ago

Oh, sorry - I forgot to re-enable that once I moved to 8.2.2. Once I reinstated that extension, it built. Thanks!