-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make package names more similar to the rule name.
As of #222, both the package name and ID are z-encoded. However, GHC only needs the package *ID* to be unique, as long as you call `-package-id` instead of `-package`. As a result we can simplify how package-names are encoded: we can keep them the same as the rule name, other than fixing underscores. In addition to (I think) making error messages nicer, this paves the way for some improvements in Hazel (or similar tools), now that the rule and package names can be identical: - It helps support the PackageImports extension. - GHC >= 8.0 generates the Cabal macros (e.g., `MIN_VERSION_*`) automatically. Prebuilt dependencies are still passed with `-package` since their IDs
- Loading branch information
Showing
12 changed files
with
121 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Tests around our use of package names. | ||
package(default_testonly = 1) | ||
|
||
load( | ||
"@io_tweag_rules_haskell//haskell:haskell.bzl", | ||
"haskell_library", | ||
"haskell_test", | ||
) | ||
|
||
haskell_library( | ||
# A package with the character "Z" in it shouldn't change its name | ||
name = "lib-aZ", | ||
srcs = ["Lib.hs"], | ||
prebuilt_dependencies = ["base"], | ||
version = "1.2.3.4", | ||
) | ||
|
||
haskell_test( | ||
name = "bin", | ||
srcs = ["Main.hs"], | ||
main_file = "Main.hs", | ||
prebuilt_dependencies = ["base"], | ||
deps = [":lib-aZ"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Lib (foo) where | ||
|
||
foo :: Integer | ||
foo = 42 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{-# LANGUAGE CPP #-} | ||
{-# LANGUAGE PackageImports #-} | ||
module Main (main) where | ||
|
||
import Control.Monad (when) | ||
|
||
-- Test the PackageImports extension. | ||
import "lib-aZ" Lib (foo) | ||
|
||
-- Test macros that GHC creates automatically based on the package version. | ||
versionHighEnoughTest, versionTooLowTest :: Bool | ||
#if MIN_VERSION_lib_aZ(1,2,3) | ||
versionHighEnoughTest = True | ||
#else | ||
versionHighEnoughTest = False | ||
#endif | ||
|
||
#if MIN_VERSION_lib_aZ(1,2,4) | ||
versionTooLowTest = False | ||
#else | ||
versionTooLowTest = True | ||
#endif | ||
|
||
check :: (Show a, Eq a) => a -> a -> IO () | ||
check x y = when (x /= y) $ error $ "Failed check: " ++ show (x, y) | ||
|
||
main :: IO () | ||
main = do | ||
check foo 42 | ||
check VERSION_lib_aZ "1.2.3.4" | ||
check versionHighEnoughTest True | ||
check versionTooLowTest True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
module Main (main) where | ||
|
||
import QuuxLib (message) | ||
|
||
main :: IO () | ||
main = putStrLn "Hello GHCi!" | ||
main = putStrLn message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module QuuxLib (message) where | ||
|
||
message :: String | ||
message = "Hello GHCi!" |