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

nbt-0.7 is not compiling (use of 'fail' in Data/NBT.hs) #12

Open
DolphinTechCodes opened this issue Jun 16, 2020 · 4 comments · May be fixed by #14
Open

nbt-0.7 is not compiling (use of 'fail' in Data/NBT.hs) #12

DolphinTechCodes opened this issue Jun 16, 2020 · 4 comments · May be fixed by #14

Comments

@DolphinTechCodes
Copy link

I am trying to compile nbt-0.7 with ghc 8.8.3 (stac lts-16.1) and get the following error:

Preprocessing library for nbt-0.7..
nbt   > Building library for nbt-0.7..
nbt   > [1 of 1] Compiling Data.NBT
nbt   >          
nbt   > /tmp/stack-d638f12c11d32bcc/nbt-0.7/src/Data/NBT.hs:113:53: error:
nbt   >     • No instance for (MonadFail Data.Serialize.Put.PutM)
nbt   >         arising from a use of ‘fail’
nbt   >     • In the expression: fail "Attempted to write heterogeneous list"
nbt   >       In a case alternative:
nbt   >           x : xs
nbt   >             | all (\ e -> typeOf e == ty) xs -> return ty
nbt   >             | otherwise -> fail "Attempted to write heterogeneous list"
nbt   >             where
nbt   >                 ty = typeOf x
nbt   >       In a stmt of a 'do' block:
nbt   >         ty <- case elems ts of
nbt   >                 [] -> return EndType
nbt   >                 x : xs
nbt   >                   | all (\ e -> typeOf e == ty) xs -> return ty
nbt   >                   | otherwise -> fail "Attempted to write heterogeneous list"
nbt   >                   where
nbt   >                       ty = typeOf x
nbt   >     |    
nbt   > 113 |                  | otherwise                     -> fail "Attempted to write heterogeneous list"
nbt   >     |                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
nbt   >          

I tracked the problem down and fount that the new version of GHC has dropped the fail function for Monads. See the proposal. A suiting fix would be replacing fail with error as that was the default behaviour of the PutM monad instance.

@acfoltzer
Copy link
Owner

Thank you! I will try to take a look this weekend.

@stepcut
Copy link

stepcut commented Feb 20, 2021

There are two uses of fail in that file. The one in the Get monad should be ok, since there is a MonadFail Get instance. But the Put one needs to be changed to error.

I can submit a pull request, but it is just a one-liner, plus version bump.

@stepcut
Copy link

stepcut commented Mar 9, 2021

If you add me as a maintainer here and on hackage, I can upload a new version. I maintain this library,

https://github.com/stepcut/minecraft-data

And it currently does not build on anything higher than GHC 8.6 due to nbt not building.

@davidgarland
Copy link

Any chance of this being resolved? I don't have any particular rush (I had just wanted to play with NBT and noticed a package already existed, and so looked here and noticed it had an error) but this seems like a fairly small issue to just allow to be a showstopper.

@msakai msakai linked a pull request Jan 26, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants