jswebtools / language-ecmascript

Haskell library: ECMAScript parser, pretty-printer and additional tools
Other
46 stars 26 forks source link

Doesn't build with GHC-8.8 #85

Closed phadej closed 4 years ago

phadej commented 4 years ago

I made revisions (about revisions) to correct version bounds https://hackage.haskell.org/package/language-ecmascript-0.19/revisions/

src/Language/ECMAScript3/Parser.hs:797:31: error:
    • Could not deduce (MonadFail m) arising from a use of ‘fail’
      from the context: MonadIO m
        bound by the type signature for:
                   parseJavaScriptFromFile :: forall (m :: * -> *).
                                              MonadIO m =>
                                              String -> m [Statement SourcePos]
        at src/Language/ECMAScript3/Parser.hs:(792,1)-(793,50)
      Possible fix:
        add (MonadFail m) to the context of
          the type signature for:
            parseJavaScriptFromFile :: forall (m :: * -> *).
                                       MonadIO m =>
                                       String -> m [Statement SourcePos]
    • In the expression: fail (show err)
      In a case alternative: Left err -> fail (show err)
      In a stmt of a 'do' block:
        case parse parseScript filename chars of
          Left err -> fail (show err)
          Right (Script _ stmts) -> return stmts
    |
797 |     Left err               -> fail (show err)
    | 
achudnov commented 4 years ago

I haven't followed the recent GHC/base versions, but, judging by the error message, I'm assuming fail is no longer part of the definition of Monad?

phadej commented 4 years ago

If I don't miss some other issues: the easiest, and non (strictly) breaking change is to change

-- | Read a JavaScript program from file an parse it into a list of
-- statements
parseJavaScriptFromFile :: MonadIO m => String -- ^ file name
                        -> m [Statement SourcePos]
parseJavaScriptFromFile filename = do
  chars <- liftIO $ readFile filename
  case parse parseScript filename chars of
    Left err               -> fail (show err)
    Right (Script _ stmts) -> return stmts

into

-- | Read a JavaScript program from file an parse it into a list of
-- statements
parseJavaScriptFromFile :: MonadIO m => String -- ^ file name
                        -> m [Statement SourcePos]
parseJavaScriptFromFile filename = do
  chars <- liftIO $ readFile filename
  case parse parseScript filename chars of
    Left err               -> liftIO (throwIO (userError (show err))) -- or some custom exception
    Right (Script _ stmts) -> return stmts

fail for IO throws userError anyway, so the behavior will be quite the same.

achudnov commented 4 years ago

The change looks good to me. Could you submit a PR with it? If not I'll patch and release myself later today.

phadej commented 4 years ago

Sorry, but I have no time to spare more than to just report. For me the proper bounds on Hackage is enough, and that's done.

swamp-agr commented 4 years ago

Hi @achudnov,

Could you please publish new version on Hackage?

achudnov commented 4 years ago

I’ll try to do it this weekend. The Travis config is broken, so I’ve been unable to test on earlier compiler versions.

On Feb 6, 2020, at 3:41 PM, Andrey Prokopenko notifications@github.com wrote:

 Hi @achudnov,

Could you please publish new version on Hackage?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

achudnov commented 4 years ago

@dmjio for assistance with the Travis config.

achudnov commented 4 years ago

Fixed in 0.19.0.1 on Hackage