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

Parse/Print roundtrip loses shebang unless file path is in the form of "dir/file.hs" #92

Closed
zliu41 opened this issue Sep 13, 2020 · 0 comments · Fixed by #94
Closed

Comments

@zliu41
Copy link
Collaborator

zliu41 commented Sep 13, 2020

First reported in ndmitchell/hlint#1122 by @pbrisbin

Suppose the content of Foo.hs is

#!/usr/bin/env stack
{- stack --resolver lts-16.10 script -}
module Main (main) where
main :: IO ()
main = putStrLn "hi"

In the following program, only the first way of parsing Foo.hs preserves the shebang.

import Language.Haskell.GHC.ExactPrint.Parsers
import Language.Haskell.GHC.ExactPrint.Print

main :: IO ()
main = do
  Right (as, m) <- parseModule "test/Foo.hs"   -- preserves shebang
  Right (as, m) <- parseModule "./test/Foo.hs" -- loses shebang
  Right (as, m) <- parseModule "Foo.hs"        -- loses shebang
  Right (as, m) <- parseModule "./Foo.hs"      -- loses shebang
  Right (as, m) <- parseModule "/tmp/Foo.hs"   -- loses shebang
  putStrLn $ exactPrint m as
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.

1 participant