antalsz / hs-to-coq

Convert Haskell source code to Coq source code
https://hs-to-coq.readthedocs.io
MIT License
279 stars 27 forks source link

Encoding problems in happy #91

Closed WhatisRT closed 6 years ago

WhatisRT commented 6 years ago

While building hs-to-coq on an ubuntu image, I encountered the following error:

hs-to-coq-0.0.0.0: build (lib + exe)
Preprocessing library for hs-to-coq-0.0.0.0..
happy: src/lib/HsToCoq/ConvertHaskell/Parameters/Parsers.y: hGetContents: invalid argument (invalid byte sequence)

--  While building custom Setup.hs for package hs-to-coq-0.0.0.0 using:
      /root/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_mPHDZzAJ_2.2.0.0_ghc-8.4.1 --builddir=.stack-work/dist/x86_64-linux/Cabal-2.2.0.0 build lib:hs-to-coq exe:hs-to-coq --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1

The error hGetContents: invalid argument (invalid byte sequence) pops up with other Haskell projects and seems to imply that a wrong encoding is used. The exact same commit builds fine on my mac.

nomeata commented 6 years ago

What happens if you set

export LANG=C.UTF8

before building?

WhatisRT commented 6 years ago

I still get the same error

nomeata commented 6 years ago

The problem usually stems from using a non-utf8 locale. Is your ubuntu image maybe very bare? Maybe install the Ubuntu package locales-all?

nh2 commented 6 years ago

@nomeata It's likely the ellipsis on this line

https://github.com/antalsz/hs-to-coq/blob/f2994c196829cde9eaf028235a60a370bd004338/src/lib/HsToCoq/ConvertHaskell/Parameters/Parsers.y#L270

and/or the accent on a on this line

https://github.com/antalsz/hs-to-coq/blob/f2994c196829cde9eaf028235a60a370bd004338/src/lib/HsToCoq/ConvertHaskell/Parameters/Parsers.y#L266

and likely happy doesn't follow https://www.snoyman.com/blog/2016/12/beware-of-readfile

WhatisRT commented 6 years ago

With the help of @nh2 we found out that installing locales-all and setting LANG to en_US.utf8 solves the problem in this case. Thanks everybody!

nh2 commented 6 years ago

@nomeata We should also probably fix that in happy.

WhatisRT commented 6 years ago

I can also confirm that after the latest commit, it works without installing and setting the locale.