Skip to content

Using haskell.nix with stack’s nix integration is unsafe due to patches #400

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

Closed
kirelagin opened this issue Jan 15, 2020 · 3 comments · Fixed by #402
Closed

Using haskell.nix with stack’s nix integration is unsafe due to patches #400

kirelagin opened this issue Jan 15, 2020 · 3 comments · Fixed by #402

Comments

@kirelagin
Copy link
Contributor

This is a heads-up issue in case someone will be banging their head against the wall as I did today.

haskell.nix backports GHC MR !948. It’s easy to see that this change is breaking the interface of template-haskell. In particular, it breaks singletons:

        • Couldn't match type ‘Integer’ with ‘Int’
          Expected type: q Int
            Actual type: q Uniq
        • In the expression: return n
          In a case alternative: NameU n -> return n
          In a stmt of a 'do' block:
            case flav of
              NameU n -> return n
              _ -> error "Internal error: `qNewName` didn't return a NameU"
       |
    99 |     NameU n -> return n
       |  

haskell.nix also patches singletons to fix this.

However, if you are using stack with Nix integration and the shell file relies on haskell.nix, you’ll get a compiler with the former patch backported, but the singletons patch will not be applied, as stack builds dependencies itself.

I’m not sure there is any moral to this story except for “be careful” and “let’s replace stack and all other similar tools by Nix ASAP”.

@kirelagin
Copy link
Contributor Author

By the way, the singletons patch pretty much negates the original fix as the supposedly unique names can again overflow in Int. Here is a better one (and it’s also how it has been fixed in singletons upstream): serokell/singletons@78bfaa7

@angerman
Copy link
Collaborator

@kirelagin right. this is a bit of an annoyance. It's somewhat fundamental to make ghcjs work properly. I hope we won't have breakage this bad in the future. For now the best option is likely to just provide an - extra-pkg to stack that has a patched singletons. The difference between the upstream ghc and the patched ghc in haskell.nix (and patched cabal to some degree) is something troubeling, but for now unavoidable I believe :-(

Your patch looks correct, and I'll update the one in haskell.nix! Thank you!

@luite
Copy link

luite commented Jan 15, 2020

I agree, the upstream fix is better. Truncating to an Int reintroduces the problem. Using the Uniq type synonym was the intended way of making packages compatible across template-haskell versions.

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.

3 participants