├── .bazelci ├── README.md └── presubmit.yml ├── .bazelignore ├── .bazelrc ├── .bazelrc.bzlmod ├── .bazelrc.common ├── .bazelversion ├── .bcr ├── config.yml ├── metadata.template.json ├── presubmit.yml └── source.template.json ├── .gitattributes ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── feature_request.md │ └── release.md ├── actions │ ├── free_disk_space_on_linux │ │ └── action.yaml │ ├── install_apt_pkgs │ │ └── action.yaml │ └── set_tcp_keepalive_time │ │ └── action.yaml ├── dependabot.yml ├── extract_from_ghc_bindist.py ├── renovate.json ├── settings.yml ├── update-ghc.py └── workflows │ ├── changelog.awk │ ├── patch-test.yaml │ ├── prepare-release.yaml │ ├── publish.yaml │ ├── release_prep.sh │ ├── update-ghc.yaml │ └── workflow.yaml ├── .gitignore ├── .mergify.yml ├── .netlify └── build.sh ├── .readthedocs.yaml ├── AUTHORS ├── BUILD.bazel ├── CHANGELOG.md ├── CONTRIBUTING.md ├── CONTRIBUTORS ├── LICENSE ├── MAINTAINERS.md ├── MODULE.bazel ├── README.md ├── WORKSPACE ├── WORKSPACE.bzlmod ├── buildifier └── BUILD.bazel ├── constants.bzl ├── debug └── linking_utils │ ├── BUILD.bazel │ ├── README.md │ └── ldd.py ├── docs ├── .gitignore ├── BUILD.bazel ├── conf.py ├── haskell-use-cases.rst ├── haskell.rst ├── index.rst ├── main.css ├── pandoc │ ├── BUILD.bazel │ └── pandoc.bzl ├── prebuild.sh ├── readthedocs_requirements.txt ├── serve.py ├── templates │ ├── index.html │ ├── main.html │ ├── markdown │ │ ├── aspect.vm │ │ ├── func.vm │ │ ├── header.vm │ │ ├── provider.vm │ │ └── rule.vm │ ├── metadata │ │ ├── aspect.vm │ │ ├── func.vm │ │ ├── header.vm │ │ ├── provider.vm │ │ └── rule.vm │ └── nav.html └── why-bazel.rst ├── examples ├── .bazelignore ├── .bazelrc ├── .bazelrc.auth ├── .bazelrc.bzlmod ├── .bazelrc.common ├── .bazelrc.local ├── .gitignore ├── BUILD.bazel ├── MODULE.bazel ├── README.md ├── WORKSPACE ├── WORKSPACE.bzlmod ├── arm │ ├── .bazelrc │ ├── .bazelrc.bzlmod │ ├── .bazelrc.common │ ├── BUILD.bazel │ ├── BUILD.zlib.bazel │ ├── Example.hs │ ├── Example2.hs │ ├── LibExample.hs │ ├── README.md │ ├── WORKSPACE │ ├── arm-cross.nix │ ├── nixpkgs │ ├── qemu-shell.nix │ └── shell.nix ├── basic_modules │ ├── BUILD.bazel │ ├── README.md │ └── src │ │ ├── A.hs │ │ ├── B.hs │ │ └── C.hs ├── cat_hs │ ├── BUILD.bazel │ ├── README.md │ ├── exec │ │ └── cat_hs │ │ │ ├── BUILD.bazel │ │ │ └── src │ │ │ └── Main.hs │ └── lib │ │ ├── args │ │ ├── BUILD.bazel │ │ ├── src │ │ │ └── Args.hs │ │ └── test │ │ │ └── Main.hs │ │ └── cat │ │ ├── BUILD.bazel │ │ ├── src │ │ └── Cat.hs │ │ └── test │ │ └── Main.hs ├── nixpkgs ├── non_module_deps.bzl ├── primitive │ ├── .github │ │ └── workflows │ │ │ └── ci.yml │ ├── .gitignore │ ├── BUILD.bazel │ ├── Control │ │ └── Monad │ │ │ └── Primitive.hs │ ├── Data │ │ ├── Primitive.hs │ │ └── Primitive │ │ │ ├── Array.hs │ │ │ ├── ByteArray.hs │ │ │ ├── Internal │ │ │ ├── Operations.hs │ │ │ └── Read.hs │ │ │ ├── MVar.hs │ │ │ ├── MachDeps.hs │ │ │ ├── MutVar.hs │ │ │ ├── PrimArray.hs │ │ │ ├── PrimVar.hs │ │ │ ├── Ptr.hs │ │ │ ├── SmallArray.hs │ │ │ └── Types.hs │ ├── LICENSE │ ├── README.md │ ├── bench │ │ ├── Array │ │ │ └── Traverse │ │ │ │ ├── Closure.hs │ │ │ │ ├── Compose.hs │ │ │ │ └── Unsafe.hs │ │ ├── ByteArray │ │ │ └── Compare.hs │ │ ├── PrimArray │ │ │ ├── Compare.hs │ │ │ └── Traverse.hs │ │ └── main.hs │ ├── cabal.project │ ├── cbits │ │ ├── primitive-memops.c │ │ └── primitive-memops.h │ ├── changelog.md │ ├── primitive.cabal │ └── test │ │ ├── LICENSE │ │ ├── Main.hs │ │ ├── README.md │ │ └── src │ │ └── PrimLaws.hs ├── rts │ ├── BUILD.bazel │ ├── One.hs │ └── main.c ├── shell.nix ├── split.patch ├── transformers │ ├── BUILD.bazel │ ├── Control │ │ ├── Applicative │ │ │ ├── Backwards.hs │ │ │ └── Lift.hs │ │ └── Monad │ │ │ ├── Signatures.hs │ │ │ └── Trans │ │ │ ├── Accum.hs │ │ │ ├── Class.hs │ │ │ ├── Cont.hs │ │ │ ├── Error.hs │ │ │ ├── Except.hs │ │ │ ├── Identity.hs │ │ │ ├── List.hs │ │ │ ├── Maybe.hs │ │ │ ├── RWS.hs │ │ │ ├── RWS │ │ │ ├── CPS.hs │ │ │ ├── Lazy.hs │ │ │ └── Strict.hs │ │ │ ├── Reader.hs │ │ │ ├── Select.hs │ │ │ ├── State.hs │ │ │ ├── State │ │ │ ├── Lazy.hs │ │ │ └── Strict.hs │ │ │ ├── Writer.hs │ │ │ └── Writer │ │ │ ├── CPS.hs │ │ │ ├── Lazy.hs │ │ │ └── Strict.hs │ ├── Data │ │ └── Functor │ │ │ ├── Constant.hs │ │ │ └── Reverse.hs │ ├── LICENSE │ ├── changelog │ └── legacy │ │ ├── pre709 │ │ └── Data │ │ │ └── Functor │ │ │ └── Identity.hs │ │ └── pre711 │ │ ├── Control │ │ └── Monad │ │ │ └── IO │ │ │ └── Class.hs │ │ └── Data │ │ └── Functor │ │ ├── Classes.hs │ │ ├── Compose.hs │ │ ├── Product.hs │ │ └── Sum.hs └── vector │ ├── BUILD.bazel │ ├── Data │ ├── Vector.hs │ └── Vector │ │ ├── Fusion │ │ ├── Bundle.hs │ │ ├── Bundle │ │ │ ├── Monadic.hs │ │ │ └── Size.hs │ │ ├── Stream │ │ │ └── Monadic.hs │ │ └── Util.hs │ │ ├── Generic.hs │ │ ├── Generic │ │ ├── Base.hs │ │ ├── Mutable.hs │ │ ├── Mutable │ │ │ └── Base.hs │ │ └── New.hs │ │ ├── Internal │ │ └── Check.hs │ │ ├── Mutable.hs │ │ ├── Primitive.hs │ │ ├── Primitive │ │ └── Mutable.hs │ │ ├── Storable.hs │ │ ├── Storable │ │ ├── Internal.hs │ │ └── Mutable.hs │ │ ├── Unboxed.hs │ │ └── Unboxed │ │ ├── Base.hs │ │ └── Mutable.hs │ ├── LICENSE │ ├── benchmarks │ ├── Algo │ │ ├── AwShCC.hs │ │ ├── HybCC.hs │ │ ├── Leaffix.hs │ │ ├── ListRank.hs │ │ ├── Quickhull.hs │ │ ├── Rootfix.hs │ │ ├── Spectral.hs │ │ └── Tridiag.hs │ ├── LICENSE │ ├── Main.hs │ ├── Setup.hs │ ├── TestData │ │ ├── Graph.hs │ │ ├── ParenTree.hs │ │ └── Random.hs │ └── vector-benchmarks.cabal │ ├── changelog │ ├── include │ └── vector.h │ ├── internal │ ├── GenUnboxTuple.hs │ └── unbox-tuple-instances │ └── tests │ ├── Boilerplater.hs │ ├── LICENSE │ ├── Main.hs │ ├── Setup.hs │ ├── Tests │ ├── Bundle.hs │ ├── Move.hs │ ├── Vector.hs │ └── Vector │ │ └── UnitTests.hs │ └── Utilities.hs ├── extensions ├── BUILD.bazel ├── ghc_version.bzl ├── haskell_toolchains.bzl ├── rules_haskell_dependencies.bzl └── stack_snapshot.bzl ├── haskell ├── BUILD.bazel ├── ahc.BUILD.tpl ├── assets │ ├── ghc_9_2_1_mac.patch │ ├── ghci_script │ └── relpath.sh ├── asterius │ ├── BUILD.bazel │ ├── asterius_config.bzl │ ├── asterius_dependencies.bzl │ ├── asterius_webpack_config.js.tpl │ ├── defs.bzl │ ├── extension.bzl │ ├── install_node_maybe_nix.bzl.tpl │ ├── npm │ │ ├── BUILD.bazel │ │ ├── package.json │ │ └── pnpm-lock.yaml │ └── repositories.bzl ├── c2hs.bzl ├── c2hs │ └── BUILD.bazel ├── cabal.bzl ├── cabal_wrapper.bzl ├── cc.bzl ├── cc_toolchain_config.bzl ├── defs.bzl ├── doctest.bzl ├── experimental │ ├── BUILD.bazel │ ├── defs.bzl │ ├── private │ │ ├── BUILD.bazel │ │ └── module.bzl │ └── providers.bzl ├── gen_ghc_bindist.py ├── ghc.BUILD.tpl ├── ghc.bzl ├── ghc_bindist.bzl ├── haddock.bzl ├── nixpkgs.bzl ├── platforms │ ├── BUILD.bazel │ └── list.bzl ├── plugins.bzl ├── private │ ├── actions │ │ ├── compile.bzl │ │ ├── info.bzl │ │ ├── link.bzl │ │ ├── package.bzl │ │ ├── process_hsc_file.bzl │ │ └── runghc.bzl │ ├── bazel_platforms.bzl │ ├── cabal_wrapper.py │ ├── cc_libraries.bzl │ ├── cc_wrapper.bzl │ ├── cc_wrapper.py.tpl │ ├── cc_wrapper_windows.sh.tpl │ ├── context.bzl │ ├── coverage_wrapper.sh.tpl │ ├── dependencies.bzl │ ├── dict.bzl │ ├── expansions.bzl │ ├── generate_cabal_paths_module.py │ ├── ghc_bindist_generated.json │ ├── ghc_ci.bzl │ ├── ghc_wrapper.sh │ ├── ghci_repl_wrapper.sh │ ├── haskell_impl.bzl │ ├── haskell_runfiles.tpl │ ├── hie_bios_wrapper.sh │ ├── java.bzl │ ├── list.bzl │ ├── mode.bzl │ ├── package_configuration.py │ ├── packages.bzl │ ├── path_utils.bzl │ ├── pkg_id.bzl │ ├── pkgdb_to_bzl.bzl │ ├── pkgdb_to_bzl.py │ ├── plugins.bzl │ ├── runghc.bzl │ ├── set.bzl │ ├── stack_snapshot_pin.sh.tpl │ ├── validate_attrs.bzl │ ├── version_macros.bzl │ ├── version_macros.py │ ├── versions.bzl │ └── workspace_utils.bzl ├── protobuf.bzl ├── providers.bzl ├── repl.bzl ├── repositories.bzl ├── toolchain.bzl └── toolchain_info.bzl ├── logo ├── horizontal.png ├── horizontal.svg ├── logomark.png ├── logomark.svg ├── vertical.png └── vertical.svg ├── netlify.toml ├── nixpkgs ├── BUILD.bazel ├── NOTUSED └── default.nix ├── non_module_dev_deps.bzl ├── protobuf └── BUILD.bazel ├── registry ├── bazel_registry.json └── modules │ ├── rules_haskell │ ├── 1.0 │ │ ├── MODULE.bazel │ │ └── source.json │ └── metadata.json │ ├── rules_haskell_nix │ ├── 1.0 │ │ ├── MODULE.bazel │ │ └── source.json │ └── metadata.json │ ├── rules_nixpkgs_cc │ ├── 0.13.0 │ │ ├── MODULE.bazel │ │ └── source.json │ └── metadata.json │ ├── rules_nixpkgs_go │ ├── 0.13.0 │ │ ├── MODULE.bazel │ │ └── source.json │ └── metadata.json │ ├── rules_nixpkgs_java │ ├── 0.13.0 │ │ ├── MODULE.bazel │ │ └── source.json │ └── metadata.json │ ├── rules_nixpkgs_posix │ ├── 0.13.0 │ │ ├── MODULE.bazel │ │ └── source.json │ └── metadata.json │ └── rules_nixpkgs_python │ ├── 0.13.0 │ ├── MODULE.bazel │ └── source.json │ └── metadata.json ├── rule_info ├── BUILD.bazel └── rule_info.proto ├── rules_haskell_nix ├── .bazelrc ├── .bazelrc.bzlmod ├── .bazelversion ├── BUILD.bazel ├── MODULE.bazel ├── README.md ├── WORKSPACE ├── WORKSPACE.bzlmod ├── extensions │ ├── BUILD.bazel │ └── nix_haskell_toolchains.bzl ├── nix_test.sh ├── nixpkgs.bzl ├── non_module_deps.bzl └── private │ ├── BUILD │ └── declare_toolchains.bzl ├── rules_haskell_tests ├── .bazelrc ├── .bazelrc.bzlmod ├── .bazelversion ├── .ghcide ├── .hie-bios ├── BUILD.bazel ├── MODULE.bazel ├── WORKSPACE ├── WORKSPACE.bzlmod ├── buildifier │ └── BUILD.bazel ├── ghcide-snapshot.json ├── ghcide-snapshot_9.2.8.json ├── ghcide-snapshot_9.4.6.json ├── ghcide-snapshot_9.4.8.json ├── ghcide-snapshot_9.6.5.json ├── ghcide-snapshot_9.8.2.json ├── ghcide-stack-snapshot.yaml ├── ghcide-stack-snapshot_9.2.8.yaml ├── ghcide-stack-snapshot_9.4.8.yaml ├── ghcide-stack-snapshot_9.6.5.yaml ├── ghcide-stack-snapshot_9.8.2.yaml ├── hie.yaml ├── nixpkgs ├── non_module_deps.bzl ├── non_module_deps_1.bzl ├── non_module_deps_2.bzl ├── non_module_deps_bzlmod.bzl ├── shell.nix ├── stackage-pinning-test.yaml ├── stackage-pinning-test_9.2.8.yaml ├── stackage-pinning-test_9.4.8.yaml ├── stackage-pinning-test_9.6.5.yaml ├── stackage-pinning-test_9.8.2.yaml ├── stackage-pinning-test_snapshot.json ├── stackage-pinning-test_snapshot_9.2.8.json ├── stackage-pinning-test_snapshot_9.4.6.json ├── stackage-pinning-test_snapshot_9.4.8.json ├── stackage-pinning-test_snapshot_9.6.5.json ├── stackage-pinning-test_snapshot_9.8.2.json ├── stackage-zlib-snapshot.json ├── stackage-zlib-snapshot_9.2.8.json ├── stackage-zlib-snapshot_9.4.6.json ├── stackage-zlib-snapshot_9.4.8.json ├── stackage-zlib-snapshot_9.6.5.json ├── stackage-zlib-snapshot_9.8.2.json ├── stackage_snapshot.json ├── stackage_snapshot.yaml ├── stackage_snapshot_9.2.8.json ├── stackage_snapshot_9.2.8.yaml ├── stackage_snapshot_9.4.8.json ├── stackage_snapshot_9.4.8.yaml ├── stackage_snapshot_9.6.5.json ├── stackage_snapshot_9.6.5.yaml ├── stackage_snapshot_9.8.2.json ├── stackage_snapshot_9.8.2.yaml └── tests │ ├── BUILD.bazel │ ├── Foo.hs │ ├── LZ4.hs │ ├── RunTests.hs │ ├── analysis_tests.bzl │ ├── asterius │ ├── asterius_binary │ │ └── BUILD │ ├── asterius_tests_utils.bzl │ ├── binary-dynamic │ │ └── BUILD.bazel │ ├── binary-simple │ │ └── BUILD.bazel │ ├── binary-with-compiler-flags │ │ └── BUILD.bazel │ ├── binary-with-lib-dynamic │ │ └── BUILD.bazel │ ├── binary-with-link-flags │ │ └── BUILD.bazel │ ├── binary-with-tool │ │ └── BUILD.bazel │ ├── binary_with_import │ │ └── BUILD.bazel │ ├── cabal-toolchain-flags │ │ └── BUILD.bazel │ ├── cpp_macro_conflict │ │ └── BUILD.bazel │ ├── encoding │ │ └── BUILD.bazel │ ├── extra-source-files │ │ └── BUILD.bazel │ ├── generated_modules │ │ └── BUILD.bazel │ ├── haskell_cabal_binary │ │ └── BUILD.bazel │ ├── haskell_cabal_datafile │ │ └── BUILD.bazel │ ├── haskell_toolchain_binary │ │ └── BUILD.bazel │ ├── hs-boot │ │ └── BUILD.bazel │ ├── lhs │ │ └── BUILD.bazel │ ├── library-empty │ │ └── BUILD.bazel │ ├── library-exports │ │ └── BUILD.bazel │ ├── package-id-clash-binary │ │ └── BUILD.bazel │ ├── package-name │ │ └── BUILD.bazel │ ├── package-reexport │ │ └── BUILD.bazel │ ├── repl-flags │ │ └── BUILD.bazel │ ├── repl-make-variables │ │ └── BUILD.bazel │ ├── stack_toolchain_libraries │ │ ├── BUILD │ │ ├── main.hs │ │ ├── snapshot.json │ │ └── snapshot.yaml │ ├── stackage_zlib_runpath │ │ └── BUILD │ ├── target-name │ │ └── BUILD.bazel │ ├── textual-hdrs │ │ └── BUILD.bazel │ ├── two-libs │ │ └── BUILD.bazel │ ├── two-same-file │ │ └── BUILD.bazel │ └── version-macros │ │ └── BUILD.bazel │ ├── binary-custom-main │ ├── BUILD.bazel │ └── Main.hs │ ├── binary-dynamic │ ├── BUILD.bazel │ └── Main.hs │ ├── binary-exe-path │ ├── BUILD.bazel │ └── Main.hs │ ├── binary-indirect-cbits │ ├── BUILD.bazel │ ├── Main.hs │ ├── Wrapper.hs │ └── Wrapper2.hs │ ├── binary-linkstatic-flag │ ├── BUILD.bazel │ ├── HsLib.hs │ ├── Main.hs │ └── c-lib.c │ ├── binary-simple │ ├── BUILD.bazel │ └── Main.hs │ ├── binary-with-compiler-flags │ ├── BUILD.bazel │ └── Main.hs │ ├── binary-with-data │ ├── BUILD.bazel │ ├── bin1-input │ ├── bin1.hs │ └── bin2.hs │ ├── binary-with-import │ ├── BUILD.bazel │ ├── Main.hs │ └── src │ │ └── Lib.hs │ ├── binary-with-indirect-sysdeps │ ├── BUILD.bazel │ ├── HsLib.hs │ └── Main.hs │ ├── binary-with-lib-dynamic │ ├── BUILD.bazel │ ├── Main.hs │ └── src │ │ └── Lib.hs │ ├── binary-with-lib │ ├── BUILD.bazel │ ├── Main.hs │ └── src │ │ └── Lib.hs │ ├── binary-with-link-flags │ ├── BUILD.bazel │ └── Main.hs │ ├── binary-with-main │ ├── BUILD.bazel │ └── MainIsHere.hs │ ├── binary-with-plugin │ ├── BUILD.bazel │ ├── Main.hs │ ├── Plugin.hs │ ├── main2.hs │ └── main3.hs │ ├── binary-with-prebuilt │ ├── BUILD.bazel │ └── Main.hs │ ├── binary-with-sysdeps │ ├── BUILD.bazel │ └── Main.hs │ ├── binary-with-tool │ ├── BUILD.bazel │ ├── Cat.hs │ └── Main.hs │ ├── bzlmod_runfiles │ ├── BUILD.bazel │ ├── Main.hs │ └── other_module │ │ ├── .bazelrc │ │ ├── .bazelrc.bzlmod │ │ ├── BUILD.bazel │ │ ├── Lib.hs │ │ ├── MODULE.bazel │ │ ├── Main.hs │ │ ├── WORKSPACE │ │ └── datafile │ ├── c-compiles-still │ ├── BUILD.bazel │ └── Foo.hs │ ├── c-compiles │ ├── BUILD.bazel │ ├── Lib.hs │ └── Main.hs │ ├── c2hs │ ├── BUILD.bazel │ ├── Bar.chs │ ├── repo │ │ ├── BUILD.bazel │ │ ├── Baz.chs │ │ └── WORKSPACE │ └── src │ │ └── Foo │ │ └── Foo.chs │ ├── cabal-toolchain-flags │ ├── BUILD.bazel │ ├── Main.hs │ └── test.cabal │ ├── cabal_binary_th │ ├── BUILD.bazel │ ├── Main.hs │ ├── QQ.hs │ └── cabal_test_th.cabal │ ├── cc_haskell_import │ ├── BUILD.bazel │ ├── LibA.hs │ ├── LibB.hs │ ├── cbits.c │ ├── main.c │ └── python_add_one.py │ ├── cpp_macro_conflict │ ├── BUILD.bazel │ ├── Main.hs │ └── src │ │ └── BS.hs │ ├── data │ ├── BUILD.bazel │ └── ourclibrary.c │ ├── encoding │ ├── BUILD.bazel │ ├── Main.hs │ ├── TH.hs │ └── unicode.txt │ ├── external-haskell-repository │ ├── BUILD.bazel │ ├── Main.hs │ └── workspace_dummy.bzl │ ├── extra-source-files │ ├── BUILD.bazel │ ├── Foo.hs │ ├── FooTH.hs │ ├── Main.hs │ ├── file.txt │ └── ld-options.txt │ ├── failing-repros │ ├── isystem-issue │ │ ├── BUILD.bazel │ │ ├── Main.hs │ │ └── include │ │ │ └── ghcautoconf.h │ └── should_fail.bzl │ ├── failures │ └── transitive-deps │ │ ├── BUILD.bazel │ │ ├── LibA.hs │ │ ├── LibB.hs │ │ ├── LibC.hs │ │ └── LibD.hs │ ├── generated-modules │ └── BUILD.bazel │ ├── ghc-check │ ├── BUILD.bazel │ ├── Main.hs │ └── ghc-check-cabal.cabal │ ├── ghc │ ├── BUILD.bazel │ └── ghc.bzl │ ├── ghcWithPackages_2097 │ ├── BUILD.bazel │ ├── Test.hs │ └── test │ │ ├── BUILD.bazel │ │ ├── One.hs │ │ ├── WORKSPACE │ │ └── main.c │ ├── ghcide │ └── BUILD.bazel │ ├── hackage │ └── BUILD.bazel │ ├── haddock-with-plugin │ ├── BUILD.bazel │ ├── Lib.hs │ └── Plugin.hs │ ├── haddock │ ├── BUILD.bazel │ ├── Deep.hsc │ ├── LibA.hs │ ├── LibA │ │ └── A.hs │ ├── LibB.hs │ ├── TH.hs │ ├── data_dependency.sh │ ├── header.h │ └── unicode.txt │ ├── haddock_protobuf │ ├── BUILD.bazel │ ├── HelloWorld.hs │ └── hello_world.proto │ ├── haskell_cabal_binary │ ├── BUILD.bazel │ ├── Main.hs │ ├── Setup.hs │ └── pkg.cabal │ ├── haskell_cabal_datafiles │ ├── compare_other_cabal_functions │ │ ├── BUILD.bazel │ │ ├── compare_files.sh │ │ ├── with_generate_paths_module │ │ │ ├── BUILD.bazel │ │ │ ├── Lib.hs │ │ │ ├── Write.hs │ │ │ └── lib.cabal │ │ └── without_generate_paths_module │ │ │ ├── BUILD.bazel │ │ │ ├── Lib.hs │ │ │ ├── Write.hs │ │ │ └── lib.cabal │ ├── haskell_cabal_binary_with_datafiles │ │ ├── BUILD.bazel │ │ ├── Main.hs │ │ ├── datafile │ │ └── generate-paths-module-binary.cabal │ ├── haskell_cabal_library_with_datafiles │ │ ├── BUILD.bazel │ │ ├── Lib.hs │ │ ├── Main.hs │ │ ├── datafile │ │ └── lib.cabal │ ├── other_binary │ │ └── haskell_cabal_library_datafiles_2 │ │ │ ├── BUILD.bazel │ │ │ └── Main.hs │ └── other_script │ │ └── src │ │ ├── BUILD.bazel │ │ └── test_cabal_binary_dep_datafiles.sh │ ├── haskell_cabal_doctest │ ├── BUILD.bazel │ ├── Lib.hs │ ├── Setup.hs │ └── lib.cabal │ ├── haskell_cabal_indirect_link │ ├── BUILD.bazel │ ├── Lib.hs │ ├── Main.hs │ ├── c-lib.c │ ├── c-lib.h │ ├── c-lib2.c │ ├── lib.cabal │ └── main2.hs │ ├── haskell_cabal_library │ ├── BUILD.bazel │ ├── Lib.hs │ ├── Main.hs │ ├── SecondLib.hs │ ├── c-lib.c │ ├── c-lib.h │ ├── lib.cabal │ └── second-lib.cabal │ ├── haskell_cabal_library_depends_on_haskell_library │ ├── BUILD.bazel │ ├── Lib.hs │ ├── OtherLib.hs │ └── lib.cabal │ ├── haskell_cabal_library_sublibrary_name │ ├── BUILD │ ├── Main.hs │ ├── README.md │ ├── app │ │ └── Main.hs │ ├── lib │ │ └── Lib.hs │ ├── package1.cabal │ ├── package1.tar │ └── sublib │ │ └── SubLib.hs │ ├── haskell_cabal_package │ ├── BUILD.bazel │ ├── exe │ │ └── Main.hs │ ├── lib.cabal │ └── lib │ │ └── Lib.hs │ ├── haskell_cabal_reproducibility │ ├── clib │ │ ├── BUILD.bazel │ │ ├── add.c │ │ └── myclib.h │ ├── pkg-a │ │ ├── BUILD.bazel │ │ ├── pkg-a.cabal │ │ └── src │ │ │ └── LibA.hsc │ └── pkg-b │ │ ├── BUILD.bazel │ │ ├── exe │ │ └── Main.hs │ │ └── pkg-b.cabal │ ├── haskell_doctest │ ├── BUILD.bazel │ ├── Bar.hs │ ├── Baz.hs │ ├── Foo.hs │ ├── Main.hs │ └── Quux.hsc │ ├── haskell_doctest_ffi_1559 │ ├── BUILD.bazel │ ├── Bar.hs │ └── Foo.hs │ ├── haskell_doctest_multiple_deps │ ├── BUILD.bazel │ ├── Bar.hs │ └── Baz.hs │ ├── haskell_import │ ├── BUILD.bazel │ ├── One.hs │ └── main.c │ ├── haskell_module │ ├── BUILD.bazel │ ├── attr_merging │ │ ├── BUILD.bazel │ │ ├── Bin.hs │ │ ├── ModuleWith.hs │ │ └── Plugin.hs │ ├── binary-custom-main │ │ ├── BUILD.bazel │ │ └── TestBin.hs │ ├── binary │ │ ├── BUILD.bazel │ │ ├── Main.hs │ │ └── TestBin.hs │ ├── dep-narrowing-th │ │ ├── BUILD.bazel │ │ ├── NonModulesTestLib.hs │ │ ├── SimpleFoo.hs │ │ ├── TestBinModule.hs │ │ ├── TestLibModule.hs │ │ ├── TestLibModule1.hs │ │ ├── TestLibModule2.hs │ │ ├── TestModule.hs │ │ └── TestModule2.hs │ ├── dep-narrowing │ │ ├── BUILD.bazel │ │ ├── DepFoo.hs │ │ ├── LibTop.hs │ │ ├── SimpleFoo.hs │ │ ├── TestBinModule.hs │ │ ├── TestLibModule.hs │ │ ├── TestLibModule2.hs │ │ ├── TestModule.hs │ │ └── TestModule2.hs │ ├── hs-boot │ │ ├── BUILD.bazel │ │ ├── Main.hs │ │ └── src │ │ │ ├── A.hs │ │ │ ├── A.hs-boot │ │ │ └── B.hs │ ├── hsc │ │ ├── BUILD.bazel │ │ ├── Bar.hsc │ │ ├── Bar │ │ │ └── Baz.hsc │ │ ├── BinHsc.hsc │ │ ├── Flags.hsc │ │ ├── Foo.hsc │ │ └── Main.hs │ ├── library-dep │ │ ├── BUILD.bazel │ │ ├── TestLibModule.hs │ │ └── TestModule.hs │ ├── library │ │ ├── BUILD.bazel │ │ ├── Bin.hs │ │ ├── TestLib.hs │ │ ├── TestLib2.hs │ │ ├── extra_src.md │ │ └── extra_src2.md │ ├── multiple │ │ ├── BUILD.bazel │ │ ├── BranchLeft.hs │ │ ├── BranchRight.hs │ │ ├── Leaf.hs │ │ └── Root.hs │ ├── nested │ │ ├── BUILD.bazel │ │ ├── Branch │ │ │ └── Left │ │ │ │ ├── BUILD.bazel │ │ │ │ └── Module.hs │ │ ├── LeafModule.hs │ │ ├── Root │ │ │ ├── BUILD.bazel │ │ │ └── Module.hs │ │ └── src │ │ │ └── Branch │ │ │ └── Right │ │ │ └── Module.hs │ ├── plugin │ │ ├── BUILD.bazel │ │ ├── Bin.hs │ │ ├── ModuleWith.hs │ │ ├── ModuleWithout.hs │ │ └── Plugin.hs │ ├── repl │ │ ├── BUILD.bazel │ │ ├── HaskellModuleReplCrossLibraryDepsTest.hs │ │ ├── HaskellModuleReplTest.hs │ │ ├── haskell_module_repl_cross_library_deps_test │ │ │ ├── WORKSPACE │ │ │ ├── package-a │ │ │ │ ├── BUILD.bazel │ │ │ │ └── src │ │ │ │ │ └── PackageA │ │ │ │ │ ├── Mod1.hs │ │ │ │ │ └── Mod2.hs │ │ │ └── package-b │ │ │ │ ├── BUILD.bazel │ │ │ │ └── src │ │ │ │ └── PackageB │ │ │ │ └── Mod1.hs │ │ └── haskell_module_repl_test │ │ │ ├── BUILD.bazel │ │ │ ├── BranchLeft.hs │ │ │ ├── BranchRight.hs │ │ │ ├── Leaf.hs │ │ │ ├── Root.hs │ │ │ └── WORKSPACE │ ├── th │ │ ├── BUILD.bazel │ │ ├── BranchLeft.hs │ │ ├── BranchRight.hs │ │ ├── Leaf.hs │ │ └── Root.hs │ └── tools │ │ ├── BUILD.bazel │ │ ├── Cat.hs │ │ └── Main.hs │ ├── haskell_proto_library │ ├── BUILD.bazel │ ├── Bar.hs │ ├── address.proto │ ├── person.proto │ ├── stripped_address.proto │ ├── stripped_zip_code.proto │ └── zip_code.proto │ ├── haskell_proto_simple │ ├── BUILD.bazel │ ├── Bar.hs │ └── foo.proto │ ├── haskell_test │ ├── BUILD.bazel │ ├── Lib.hs │ └── Test.hs │ ├── haskell_toolchain_library │ ├── BUILD.bazel │ ├── Bin.hs │ └── Lib.hs │ ├── hidden-modules │ ├── BUILD.bazel │ ├── hidden_modules_test.bzl │ ├── lib-a │ │ ├── Bar.hs │ │ └── Foo.hs │ ├── lib-b │ │ └── Foo.hs │ └── lib-c │ │ └── Baz.hs │ ├── hs-boot │ ├── A.hs-boot.in │ ├── A.hs.in │ ├── BUILD.bazel │ ├── MA.hs │ ├── MA.hs-boot │ ├── MB.hs │ ├── Main.hs │ └── srcs │ │ └── B.hs │ ├── hsc │ ├── BUILD.bazel │ ├── Bar.hsc │ ├── Bar │ │ └── Baz.hsc │ ├── BinHsc.hsc │ ├── Flags.hsc │ ├── Foo.hsc │ └── Main.hs │ ├── indirect-link │ ├── BUILD.bazel │ ├── cbits │ │ ├── impl.c │ │ └── intf.c │ ├── src │ │ └── MyModule.hs │ └── test │ │ └── Main.hs │ ├── integration_testing │ ├── BUILD.bazel │ ├── IntegrationTesting.hs │ ├── README.md │ ├── dependencies.bzl │ ├── haskell_bazel_integration_test.bzl │ └── rules_haskell_integration_test.bzl │ ├── java_classpath │ ├── BUILD.bazel │ └── Main.hs │ ├── lhs │ ├── BUILD.bazel │ ├── Lib.lhs │ └── Main.lhs │ ├── library-deps │ ├── BUILD.bazel │ ├── Bin.hs │ ├── TestLib.hs │ └── sublib │ │ ├── BUILD.bazel │ │ ├── TestSubLib.hs │ │ └── sublib-c.c │ ├── library-empty │ ├── BUILD.bazel │ └── Main.hs │ ├── library-exports │ ├── BUILD.bazel │ ├── Bin.hs │ ├── TestLib.hs │ └── TestSubLib.hs │ ├── library-external-workspace │ ├── BUILD.bazel │ ├── Bin.hs │ ├── TestLib2.hs │ └── repo │ │ ├── BUILD.bazel │ │ ├── TestLib.hs │ │ └── WORKSPACE │ ├── library-linkstatic-flag │ ├── BUILD.bazel │ ├── Lib.hs │ ├── Main.hs │ └── get_library_files.bzl │ ├── library-with-cbits │ ├── AddOne.hsc │ ├── AddOne2.hs │ └── BUILD.bazel │ ├── library-with-includes │ ├── BUILD.bazel │ ├── Lib.hs │ └── b.h │ ├── library-with-static-cc-dep │ ├── BUILD.bazel │ ├── cbits │ │ └── impl.c │ ├── src │ │ └── MyModule.hs │ └── test │ │ └── Main.hs │ ├── library-with-sysdeps │ ├── BUILD.bazel │ ├── Lib.hs │ └── Main.hs │ ├── library-with-sysincludes │ ├── BUILD.bazel │ ├── IntLib.hsc │ ├── Lib.hs │ └── TH.hs │ ├── linking_utils │ ├── BUILD.bazel │ └── ldd_test.bzl │ ├── multi_repl │ ├── BUILD.bazel │ ├── a │ │ ├── BUILD.bazel │ │ └── src │ │ │ └── A │ │ │ └── A.hs │ ├── bc │ │ ├── BUILD.bazel │ │ ├── src-b │ │ │ └── BC │ │ │ │ └── B.hs │ │ ├── src-c │ │ │ └── BC │ │ │ │ └── C.hs │ │ └── src-d │ │ │ └── BC │ │ │ └── D.hs │ └── core_package_dep │ │ ├── BUILD.bazel │ │ └── Lib.hs │ ├── package-id-clash-binary │ ├── BUILD.bazel │ ├── Main.hs │ ├── a │ │ ├── BUILD.bazel │ │ └── Foo.hs │ └── b │ │ ├── BUILD.bazel │ │ └── Baz.hs │ ├── package-id-clash │ ├── BUILD.bazel │ ├── Baz.hs │ ├── Foo.hs │ └── sublib │ │ ├── BUILD.bazel │ │ └── Bar.hs │ ├── package-name │ ├── BUILD.bazel │ ├── Lib.hs │ └── Main.hs │ ├── package-reexport-transitive │ ├── BUILD.bazel │ ├── Main.hs │ └── Root.hs │ ├── package-reexport │ ├── BUILD.bazel │ ├── Dep.hs │ ├── Final.hs │ └── TransitiveDep.hs │ ├── plugin-install-order │ ├── BUILD.bazel │ ├── Main.hs │ ├── Plugin1.hs │ └── Plugin2.hs │ ├── recompilation │ ├── BUILD.bazel │ ├── SomeTest.hs │ └── recompilation_workspace │ │ ├── BUILD.bazel │ │ ├── WORKSPACE │ │ ├── patch1 │ │ ├── patch2 │ │ ├── patch3 │ │ ├── patch4 │ │ └── src │ │ ├── A.hs │ │ ├── B.hs │ │ └── C.hs │ ├── repl-flags │ ├── BUILD.bazel │ ├── CompilerFlags.hs │ └── ReplFlags.hs │ ├── repl-make-variables │ ├── BUILD.bazel │ ├── Main.hs │ └── data.txt │ ├── repl-multiple-definition │ ├── BUILD.bazel │ ├── intermediate │ │ └── Intermediate.hs │ └── src │ │ ├── Final.hs │ │ └── Root.hs │ ├── repl-name-conflicts │ ├── BUILD.bazel │ └── PreludeShadowing.hs │ ├── repl-targets │ ├── BUILD.bazel │ ├── Bad.hs │ ├── Chs.chs │ ├── Foo.hs │ ├── HsBinReplTest.hs │ ├── HsLibReplTest.hs │ ├── Hsc.hsc │ ├── Quux.hs │ ├── QuuxLib.hs │ ├── RebindableSyntax.hs │ ├── hs_bin_repl_test │ │ ├── BUILD.bazel │ │ ├── Quux.hs │ │ ├── QuuxLib.hs │ │ └── WORKSPACE │ ├── hs_lib_repl_test │ │ ├── BUILD.bazel │ │ ├── Chs.chs │ │ ├── Foo.hs │ │ ├── Hsc.hs │ │ ├── Hsc.hsc │ │ ├── WORKSPACE │ │ ├── maybe_cc_shared_library.bzl │ │ └── ourclibrary.c │ └── src │ │ ├── Bar.hs │ │ └── Baz.hsc │ ├── rule_test_exe.bzl │ ├── run-start-script.sh │ ├── runfiles │ ├── BUILD.bazel │ ├── Main.hs │ ├── bar.txt │ ├── foo.txt │ ├── main.cc │ └── runfiles-tree.sh │ ├── sandwich │ ├── BUILD.bazel │ ├── Lib.hs │ ├── Main.hs │ └── test.c │ ├── scripts │ └── exec.sh │ ├── shellcheck │ └── BUILD.bazel │ ├── solib_dir │ ├── BUILD.bazel │ └── solib_test.bzl │ ├── stack-snapshot-deps │ ├── BUILD.bazel │ ├── HsOverrideStackTest.hs │ ├── Main.hs │ └── hs_override_stack_test │ │ ├── BUILD.bazel │ │ ├── Quux.hs │ │ ├── WORKSPACE │ │ └── stack │ ├── stackage_sublibrary │ ├── BUILD │ └── Main.hs │ ├── stackage_zlib_runpath │ ├── BUILD.bazel │ ├── cabal-binary │ │ ├── Main.hs │ │ └── cabal-binary.cabal │ └── dynamic_libraries.bzl │ ├── target-name │ ├── BUILD.bazel │ ├── Lib.hs │ └── Main.hs │ ├── template-haskell-with-cbits │ ├── BUILD.bazel │ ├── Main.hs │ └── TH.hs │ ├── test_haddock.bzl │ ├── textual-hdrs │ ├── BUILD.bazel │ ├── Main.hs │ └── include │ │ └── main_definition.h │ ├── two-libs │ ├── BUILD.bazel │ ├── Main.hs │ ├── One.hs │ └── Two.hs │ ├── two-same-file │ ├── BUILD.bazel │ └── Main.hs │ ├── unit-tests │ ├── BUILD.bazel │ └── tests.bzl │ └── version-macros │ ├── BUILD.bazel │ ├── C2hsLib.chs │ ├── HsLib.hs │ ├── HscLib.hsc │ ├── Main.hs │ ├── MainC2hs.hs │ └── VersionedLib.hs ├── serve-docs.sh ├── shell.nix ├── stackage_snapshot.json ├── stackage_snapshot.yaml ├── stackage_snapshot_9.2.8.json ├── stackage_snapshot_9.2.8.yaml ├── stackage_snapshot_9.4.8.json ├── stackage_snapshot_9.4.8.yaml ├── stackage_snapshot_9.6.5.json ├── stackage_snapshot_9.6.5.yaml ├── stackage_snapshot_9.8.2.json ├── stackage_snapshot_9.8.2.yaml ├── start ├── tests ├── BUILD.bazel ├── haskell_tests │ ├── BUILD.bazel │ └── bazel_platforms_tests.bzl ├── inline_tests.bzl ├── package_configuration │ ├── BUILD.bazel │ └── package_configuration_test.py ├── protoc.bzl └── shellcheck │ ├── BUILD.bazel │ └── shellcheck.bzl ├── tools ├── BUILD.bazel ├── README.md ├── coverage-reports │ ├── .gitignore │ ├── LICENSE │ ├── README.md │ ├── Setup.hs │ ├── executable │ │ └── Main.hs │ ├── package.yaml │ └── stack.yaml ├── ghc-paths │ ├── BUILD.bazel │ ├── GHC │ │ └── Paths.hs.tpl │ ├── README.md │ ├── Test.hs │ ├── defs.bzl │ ├── ghc-paths.cabal │ └── ghc_paths.bzl ├── os_info.bzl ├── repositories.bzl ├── runfiles │ ├── BUILD.bazel │ ├── LICENSE │ ├── README.md │ ├── bazel-runfiles.cabal │ ├── bin-data.txt │ ├── bin │ │ └── Bin.hs │ ├── package.yaml │ ├── src │ │ └── Bazel │ │ │ ├── Arg0.hs │ │ │ └── Runfiles.hs │ ├── stack.yaml │ ├── test-data.txt │ └── test │ │ └── Test.hs └── worker │ ├── BUILD.bazel │ ├── Compile.hs │ ├── Main.hs │ ├── Proto │ ├── Worker.hs │ └── Worker_Fields.hs │ ├── Server.hs │ ├── Setup.hs │ └── worker.cabal └── tutorial ├── .bazelrc ├── .bazelrc.bzlmod ├── .bazelrc.common ├── .bazelrc.local ├── .gitignore ├── BUILD.bazel ├── MODULE.bazel ├── README.md ├── WORKSPACE ├── lib ├── BUILD.bazel └── Bool.hs ├── main ├── BUILD.bazel └── Main.hs └── tools └── build_rules ├── BUILD.bazel └── prelude_bazel /.bazelignore: -------------------------------------------------------------------------------- 1 | examples 2 | tutorial 3 | haskell/asterius/npm/node_modules 4 | registry 5 | rules_haskell_tests 6 | rules_haskell_nix 7 | -------------------------------------------------------------------------------- /.bazelrc: -------------------------------------------------------------------------------- 1 | import %workspace%/.bazelrc.common 2 | import %workspace%/.bazelrc.bzlmod 3 | 4 | # Remote Cache Authentication 5 | # --------------------------- 6 | try-import %workspace%/.bazelrc.auth 7 | 8 | # User Configuration 9 | # ------------------ 10 | try-import %workspace%/.bazelrc.local 11 | -------------------------------------------------------------------------------- /.bazelrc.bzlmod: -------------------------------------------------------------------------------- 1 | # Disable bzlmod explicitly by default, see https://github.com/tweag/rules_haskell/issues/1977 2 | common --noenable_bzlmod 3 | 4 | common:bzlmod --enable_bzlmod 5 | # Note, have to use /// to make Bazel not crash on Windows 6 | common:common --registry=file:///%workspace%/registry --registry=https://bcr.bazel.build 7 | 8 | -------------------------------------------------------------------------------- /.bazelversion: -------------------------------------------------------------------------------- 1 | 6.5.0 2 | -------------------------------------------------------------------------------- /.bcr/config.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/rules_haskell/3322610caba2ce8f17ec010b2f76a366a06f97c4/.bcr/config.yml -------------------------------------------------------------------------------- /.bcr/metadata.template.json: -------------------------------------------------------------------------------- 1 | { 2 | "homepage": "https://github.com/tweag/rules_haskell/", 3 | "maintainers": [ 4 | { 5 | "email": "claudio.bley@tweag.io", 6 | "github": "avdv", 7 | "name": "Claudio Bley" 8 | }, 9 | { 10 | "email": "andreas.herrmann@tweag.io", 11 | "github": "aherrmann", 12 | "name": "Andreas Herrmann" 13 | } 14 | ], 15 | "repository": [ 16 | "github:tweag/rules_haskell" 17 | ], 18 | "versions": [], 19 | "yanked_versions": {} 20 | } 21 | -------------------------------------------------------------------------------- /.bcr/source.template.json: -------------------------------------------------------------------------------- 1 | { 2 | "integrity": "", 3 | "strip_prefix": "{REPO}-{VERSION}", 4 | "url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/{REPO}-{VERSION}.tar.gz" 5 | } 6 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Prevent git from automatically introducing \r characters in .sha256 files. 2 | # Otherwise msys sha256sum fails. 3 | *.sha256 binary 4 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @avdv 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a bug report to help us fix it. 4 | labels: 'type: bug' 5 | 6 | --- 7 | 8 | **Describe the bug** 9 | A clear and concise description of what the bug is. 10 | 11 | **To Reproduce** 12 | Steps to reproduce the behavior. 13 | 14 | **Expected behavior** 15 | A clear and concise description of what you expected to happen. 16 | 17 | **Environment** 18 | - OS name + version: 19 | - Bazel version: 20 | - Version of the rules: 21 | 22 | **Additional context** 23 | Add any other context about the problem here. 24 | -------------------------------------------------------------------------------- /.github/actions/free_disk_space_on_linux/action.yaml: -------------------------------------------------------------------------------- 1 | name: Free Disk Space on Linux 2 | description: Remove unneeded files from the Ubuntu GitHub runner. 3 | 4 | runs: 5 | using: composite 6 | steps: 7 | - shell: bash 8 | if: ${{ runner.os == 'Linux' }} 9 | run: |- 10 | sudo swapoff -a 11 | sudo rm -rf /swapfile /usr/share/dotnet /usr/local/lib/android /opt/ghc "$ANDROID_HOME" /usr/local/.ghcup /usr/local/share/powershell /opt/az /opt/microsoft /etc/skel 12 | docker images -q | xargs -r docker rmi -f 13 | -------------------------------------------------------------------------------- /.github/actions/install_apt_pkgs/action.yaml: -------------------------------------------------------------------------------- 1 | name: Install Apt Packages 2 | description: Install packages via apt-get install. 3 | 4 | inputs: 5 | packages: 6 | type: string 7 | description: A space-separated list of apt packages to install. 8 | 9 | runs: 10 | using: composite 11 | steps: 12 | - shell: bash 13 | if: ${{ runner.os == 'Linux' }} 14 | env: 15 | APT_PACKAGES: ${{ inputs.packages }} 16 | run: |- 17 | sudo apt-get update 18 | sudo apt-get install --no-install-recommends -yy "${APT_PACKAGES}" 19 | sudo apt clean 20 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | 4 | - package-ecosystem: "github-actions" 5 | directory: "/" 6 | schedule: 7 | # Check for updates to GitHub Actions every weekday 8 | interval: "daily" 9 | 10 | -------------------------------------------------------------------------------- /.github/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "github>tweag/renovate-presets:ruleset_base", 4 | "github>tweag/renovate-presets:mergify" 5 | ], 6 | "ignorePaths": [ 7 | "registry/**" 8 | ], 9 | "packageRules": [ 10 | { 11 | "matchFileNames": [ 12 | "rules_haskell_nix/MODULE.bazel" 13 | ], 14 | "enabled": false 15 | } 16 | ], 17 | "gitAuthor": "Renovate Bot " 18 | } 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /bazel-* 2 | /rules_haskell_tests/bazel-* 3 | /rules_haskell_nix/bazel-* 4 | .bazelrc.auth 5 | .bazelrc.local 6 | *.swp 7 | *.swo 8 | __pycache__ 9 | /.direnv 10 | /.envrc 11 | tests/recompilation/logfile.json 12 | -------------------------------------------------------------------------------- /.mergify.yml: -------------------------------------------------------------------------------- 1 | queue_rules: 2 | - name: default 3 | queue_conditions: 4 | - "label=merge-queue" 5 | - "base=master" 6 | merge_conditions: [] 7 | merge_method: merge 8 | 9 | pull_request_rules: 10 | - name: delete head branch after merge 11 | conditions: 12 | - merged 13 | - closed 14 | actions: 15 | delete_head_branch: {} 16 | - name: remove from merge-queue after merge 17 | conditions: 18 | - merged 19 | actions: 20 | label: 21 | remove: 22 | - "merge-queue" 23 | - name: automatic merge 24 | conditions: [] 25 | actions: 26 | queue: 27 | -------------------------------------------------------------------------------- /.netlify/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eux 4 | 5 | npx @bazel/bazelisk build //docs:api_html 6 | mkdir -p public 7 | unzip -d public bazel-bin/docs/api_html-stardoc.zip 8 | cp start public 9 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the official list of Bazel authors for copyright purposes. 2 | # This file is distinct from the CONTRIBUTORS files. 3 | # See the latter for an explanation. 4 | 5 | # Names should be added to this file as: 6 | # Name or Organization 7 | # The email address is not required for organizations. 8 | 9 | Tweag I/O Limited 10 | -------------------------------------------------------------------------------- /WORKSPACE.bzlmod: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/rules_haskell/3322610caba2ce8f17ec010b2f76a366a06f97c4/WORKSPACE.bzlmod -------------------------------------------------------------------------------- /constants.bzl: -------------------------------------------------------------------------------- 1 | test_ghc_version = "9.4.8" 2 | test_asterius_version = "0.0.1" 3 | -------------------------------------------------------------------------------- /debug/linking_utils/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@rules_python//python:defs.bzl", "py_library") 2 | 3 | py_library( 4 | name = "linking_utils", 5 | srcs = ["ldd.py"], 6 | visibility = ["//visibility:public"], 7 | ) 8 | 9 | filegroup( 10 | name = "all_files", 11 | testonly = True, 12 | srcs = glob(["**"]), 13 | visibility = ["//visibility:public"], 14 | ) 15 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | _build 2 | -------------------------------------------------------------------------------- /docs/readthedocs_requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/rules_haskell/3322610caba2ce8f17ec010b2f76a366a06f97c4/docs/readthedocs_requirements.txt -------------------------------------------------------------------------------- /docs/templates/markdown/header.vm: -------------------------------------------------------------------------------- 1 | --- 2 | title: ${moduleDocstring} 3 | ... 4 | -------------------------------------------------------------------------------- /docs/templates/metadata/aspect.vm: -------------------------------------------------------------------------------- 1 | - name: ${aspectName} 2 | type: aspect 3 | summary: ${aspectInfo.getDocString().replaceFirst("(?s) 4 | .*", "")} 5 | -------------------------------------------------------------------------------- /docs/templates/metadata/func.vm: -------------------------------------------------------------------------------- 1 | - name: ${funcInfo.functionName} 2 | type: function 3 | summary: ${funcInfo.docString.replaceFirst("(?s) 4 | .*", "")} 5 | -------------------------------------------------------------------------------- /docs/templates/metadata/header.vm: -------------------------------------------------------------------------------- 1 | summary: ${moduleDocstring} 2 | symbol: 3 | -------------------------------------------------------------------------------- /docs/templates/metadata/provider.vm: -------------------------------------------------------------------------------- 1 | - name: ${providerName} 2 | type: provider 3 | summary: ${providerInfo.docString.replaceFirst("(?s) 4 | .*", "")} 5 | -------------------------------------------------------------------------------- /docs/templates/metadata/rule.vm: -------------------------------------------------------------------------------- 1 | - name: ${ruleName} 2 | type: rule 3 | summary: ${ruleInfo.docString.replaceFirst("(?s) 4 | .*", "")} 5 | -------------------------------------------------------------------------------- /examples/.bazelignore: -------------------------------------------------------------------------------- 1 | arm 2 | -------------------------------------------------------------------------------- /examples/.bazelrc: -------------------------------------------------------------------------------- 1 | ../.bazelrc -------------------------------------------------------------------------------- /examples/.bazelrc.auth: -------------------------------------------------------------------------------- 1 | ../.bazelrc.auth -------------------------------------------------------------------------------- /examples/.bazelrc.bzlmod: -------------------------------------------------------------------------------- 1 | common:bzlmod --enable_bzlmod 2 | common:common --registry=file:///%workspace%/../registry --registry=https://bcr.bazel.build 3 | -------------------------------------------------------------------------------- /examples/.bazelrc.common: -------------------------------------------------------------------------------- 1 | ../.bazelrc.common -------------------------------------------------------------------------------- /examples/.bazelrc.local: -------------------------------------------------------------------------------- 1 | ../.bazelrc.local -------------------------------------------------------------------------------- /examples/.gitignore: -------------------------------------------------------------------------------- 1 | /bazel-* 2 | -------------------------------------------------------------------------------- /examples/BUILD.bazel: -------------------------------------------------------------------------------- 1 | filegroup( 2 | name = "all_files", 3 | testonly = True, 4 | srcs = [ 5 | "BUILD.bazel", 6 | "MODULE.bazel", 7 | "WORKSPACE", 8 | "WORKSPACE.bzlmod", 9 | "//cat_hs:all_files", 10 | "//primitive:all_files", 11 | "//rts:all_files", 12 | "//transformers:all_files", 13 | "//vector:all_files", 14 | ], 15 | visibility = ["//visibility:public"], 16 | ) 17 | -------------------------------------------------------------------------------- /examples/WORKSPACE.bzlmod: -------------------------------------------------------------------------------- 1 | local_repository( 2 | name = "arm", 3 | path = "arm", 4 | ) 5 | -------------------------------------------------------------------------------- /examples/arm/.bazelrc: -------------------------------------------------------------------------------- 1 | ../../.bazelrc -------------------------------------------------------------------------------- /examples/arm/.bazelrc.bzlmod: -------------------------------------------------------------------------------- 1 | common:bzlmod --experimental_enable_bzlmod 2 | common:bzlmod --registry=file://%workspace%/../../registry --registry=https://bcr.bazel.build 3 | -------------------------------------------------------------------------------- /examples/arm/.bazelrc.common: -------------------------------------------------------------------------------- 1 | ../../.bazelrc.common -------------------------------------------------------------------------------- /examples/arm/Example.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | module Main where 3 | 4 | import Codec.Compression.Zlib (compress, decompress) 5 | import Prelude ((.), putStrLn) 6 | import Language.Haskell.TH 7 | 8 | main = $(do runIO (putStrLn "Hello, ") 9 | [| putStrLn "World!" |] 10 | ) 11 | 12 | slowId = decompress . compress 13 | -------------------------------------------------------------------------------- /examples/arm/Example2.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | module Main where 3 | 4 | import Prelude ((.), putStrLn) 5 | import Language.Haskell.TH 6 | import LibExample (exampleFunction) 7 | 8 | main = $(do runIO (putStrLn "Hello, ") 9 | [| exampleFunction |] 10 | ) 11 | -------------------------------------------------------------------------------- /examples/arm/LibExample.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | module LibExample where 3 | 4 | import Prelude ((.), putStrLn) 5 | import Language.Haskell.TH 6 | 7 | exampleFunction = 8 | $(do runIO (putStrLn "Hello, ") 9 | [| putStrLn "Library!" |] 10 | ) 11 | -------------------------------------------------------------------------------- /examples/arm/nixpkgs: -------------------------------------------------------------------------------- 1 | ../../nixpkgs -------------------------------------------------------------------------------- /examples/arm/qemu-shell.nix: -------------------------------------------------------------------------------- 1 | let 2 | pkgs = (import ./arm-cross.nix).pkgs; 3 | crossPkgs = pkgs.pkgsCross.aarch64-multiplatform; 4 | in 5 | pkgs.mkShell { 6 | LANG="C.UTF-8"; 7 | LD_LIBRARY_PATH = "${crossPkgs.buildPackages.gcc-unwrapped.out.lib}/aarch64-unknown-linux-gnu/lib"; 8 | buildInputs = [ 9 | pkgs.qemu 10 | ]; 11 | } 12 | -------------------------------------------------------------------------------- /examples/arm/shell.nix: -------------------------------------------------------------------------------- 1 | ../../shell.nix -------------------------------------------------------------------------------- /examples/basic_modules/README.md: -------------------------------------------------------------------------------- 1 | # basic_modules - A rules_haskell Example Project 2 | 3 | This project implements a very basic project with 2 modules. 4 | It uses [Bazel][bazel] build system, using [rules_haskell][rules_haskell] 5 | to define the Haskell build. 6 | 7 | [bazel]: https://bazel.build/ 8 | [rules_haskell]: https://haskell.build/ 9 | 10 | ## Instructions 11 | 12 | To build the package execute the following command *in the `examples/` 13 | directory*: 14 | 15 | ``` 16 | $ bazel build //basic_modules 17 | ``` 18 | -------------------------------------------------------------------------------- /examples/basic_modules/src/A.hs: -------------------------------------------------------------------------------- 1 | module A (f, g, T, a) where 2 | 3 | data T = T0 | T1 4 | 5 | a :: T 6 | a = T1 7 | 8 | f :: a -> b -> a 9 | f x y = x 10 | 11 | g :: T -> T 12 | g T0 = a 13 | g T1 = T1 14 | -------------------------------------------------------------------------------- /examples/basic_modules/src/B.hs: -------------------------------------------------------------------------------- 1 | module B where 2 | 3 | import qualified A (f, g, T) 4 | 5 | f :: A.T -> A.T 6 | f x = A.f (A.g x) x 7 | 8 | g :: a -> a -> a -> a 9 | g x y = A.f (A.f x) (A.f x) 10 | -------------------------------------------------------------------------------- /examples/basic_modules/src/C.hs: -------------------------------------------------------------------------------- 1 | module C where 2 | 3 | import qualified B 4 | 5 | data N = Z | S N 6 | 7 | f :: a -> a -> a 8 | f x = B.g x x 9 | -------------------------------------------------------------------------------- /examples/cat_hs/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load( 2 | "@rules_haskell//haskell:defs.bzl", 3 | "haskell_doc", 4 | ) 5 | 6 | haskell_doc( 7 | name = "api-doc", 8 | deps = [ 9 | "//cat_hs/lib/args", 10 | "//cat_hs/lib/cat", 11 | ], 12 | ) 13 | 14 | filegroup( 15 | name = "all_files", 16 | testonly = True, 17 | srcs = glob(["**"]) + [ 18 | "//cat_hs/exec/cat_hs:all_files", 19 | "//cat_hs/lib/args:all_files", 20 | "//cat_hs/lib/cat:all_files", 21 | ], 22 | visibility = ["//visibility:public"], 23 | ) 24 | -------------------------------------------------------------------------------- /examples/cat_hs/exec/cat_hs/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load( 2 | "@rules_haskell//haskell:defs.bzl", 3 | "haskell_binary", 4 | ) 5 | 6 | haskell_binary( 7 | name = "cat_hs", 8 | srcs = glob(["src/**/*.hs"]), 9 | deps = [ 10 | "//cat_hs/lib/args", 11 | "//cat_hs/lib/cat", 12 | "@stackage//:base", 13 | ], 14 | ) 15 | 16 | filegroup( 17 | name = "all_files", 18 | testonly = True, 19 | srcs = glob(["**"]), 20 | visibility = ["//visibility:public"], 21 | ) 22 | -------------------------------------------------------------------------------- /examples/cat_hs/exec/cat_hs/src/Main.hs: -------------------------------------------------------------------------------- 1 | module Main 2 | ( main 3 | ) where 4 | 5 | import qualified Args 6 | import Cat (runCat) 7 | 8 | 9 | main :: IO () 10 | main = Args.parse >>= runCat 11 | -------------------------------------------------------------------------------- /examples/nixpkgs: -------------------------------------------------------------------------------- 1 | ../nixpkgs/ -------------------------------------------------------------------------------- /examples/primitive/.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | dist-* 3 | cabal-dev 4 | *.o 5 | *.hi 6 | *.chi 7 | *.chs.h 8 | *.dyn_o 9 | *.dyn_hi 10 | .hpc 11 | .hsenv 12 | .cabal-sandbox/ 13 | cabal.sandbox.config 14 | *.prof 15 | *.aux 16 | *.hp 17 | *.eventlog 18 | .stack-work/ 19 | cabal.project.local 20 | cabal.project.local~ 21 | .HTF/ 22 | .ghc.environment.* 23 | stack.yaml 24 | *.swm 25 | *.swo 26 | *.swp 27 | test_results/** 28 | -------------------------------------------------------------------------------- /examples/primitive/README.md: -------------------------------------------------------------------------------- 1 | The `primitive` package [![Build Status](https://travis-ci.org/haskell/primitive.png?branch=master)](https://travis-ci.org/haskell/primitive) 2 | ======================= 3 | 4 | This package provides various primitive memory-related operations for Haskell. 5 | 6 | See [`primitive` on Hackage](http://hackage.haskell.org/package/primitive) for more information. 7 | -------------------------------------------------------------------------------- /examples/primitive/cabal.project: -------------------------------------------------------------------------------- 1 | packages: primitive.cabal 2 | 3 | 4 | package primitive 5 | ghc-options: -Wall -Wcompat 6 | 7 | allow-newer: tagged-0.8.6.1:template-haskell 8 | -------------------------------------------------------------------------------- /examples/rts/One.hs: -------------------------------------------------------------------------------- 1 | module One () where 2 | 3 | add_one_hs :: Int -> Int 4 | add_one_hs x = x + 1 5 | 6 | foreign export ccall add_one_hs :: Int -> Int 7 | -------------------------------------------------------------------------------- /examples/rts/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "HsFFI.h" 3 | 4 | extern HsInt add_one_hs(HsInt a0); 5 | 6 | int main(int argc, char *argv[]) { 7 | hs_init(&argc, &argv); 8 | printf("Adding one to 5 through Haskell is %lld\n", add_one_hs(5)); 9 | hs_exit(); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /examples/shell.nix: -------------------------------------------------------------------------------- 1 | ../shell.nix -------------------------------------------------------------------------------- /examples/split.patch: -------------------------------------------------------------------------------- 1 | diff --git a/split.cabal b/split.cabal 2 | index a60b284..1941c2f 100644 3 | --- a/split.cabal 4 | +++ b/split.cabal 5 | @@ -51,7 +51,7 @@ Source-repository head 6 | 7 | Library 8 | ghc-options: -Wall 9 | - build-depends: base <4.12 10 | + build-depends: base <5 11 | exposed-modules: Data.List.Split, Data.List.Split.Internals 12 | default-language: Haskell2010 13 | Hs-source-dirs: src 14 | 15 | -------------------------------------------------------------------------------- /examples/transformers/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load( 2 | "@rules_haskell//haskell:defs.bzl", 3 | "haskell_library", 4 | "haskell_toolchain_library", 5 | ) 6 | 7 | haskell_toolchain_library(name = "base") 8 | 9 | haskell_library( 10 | name = "transformers", 11 | srcs = glob([ 12 | "Data/**/*.hs", 13 | "Control/**/*.hs", 14 | ]), 15 | version = "0", 16 | visibility = ["//visibility:public"], 17 | deps = [":base"], 18 | ) 19 | 20 | filegroup( 21 | name = "all_files", 22 | testonly = True, 23 | srcs = glob(["**"]), 24 | visibility = ["//visibility:public"], 25 | ) 26 | -------------------------------------------------------------------------------- /examples/vector/benchmarks/Algo/Leaffix.hs: -------------------------------------------------------------------------------- 1 | module Algo.Leaffix where 2 | 3 | import Data.Vector.Unboxed as V 4 | 5 | leaffix :: (Vector Int, Vector Int) -> Vector Int 6 | {-# NOINLINE leaffix #-} 7 | leaffix (ls,rs) 8 | = leaffix (V.replicate (V.length ls) 1) ls rs 9 | where 10 | leaffix xs ls rs 11 | = let zs = V.replicate (V.length ls * 2) 0 12 | vs = V.update_ zs ls xs 13 | sums = V.prescanl' (+) 0 vs 14 | in 15 | V.zipWith (-) (V.backpermute sums ls) (V.backpermute sums rs) 16 | 17 | -------------------------------------------------------------------------------- /examples/vector/benchmarks/Algo/ListRank.hs: -------------------------------------------------------------------------------- 1 | module Algo.ListRank 2 | where 3 | 4 | import Data.Vector.Unboxed as V 5 | 6 | listRank :: Int -> Vector Int 7 | {-# NOINLINE listRank #-} 8 | listRank n = pointer_jump xs val 9 | where 10 | xs = 0 `V.cons` V.enumFromTo 0 (n-2) 11 | 12 | val = V.zipWith (\i j -> if i == j then 0 else 1) 13 | xs (V.enumFromTo 0 (n-1)) 14 | 15 | pointer_jump pt val 16 | | npt == pt = val 17 | | otherwise = pointer_jump npt nval 18 | where 19 | npt = V.backpermute pt pt 20 | nval = V.zipWith (+) val (V.backpermute val pt) 21 | 22 | -------------------------------------------------------------------------------- /examples/vector/benchmarks/Algo/Rootfix.hs: -------------------------------------------------------------------------------- 1 | module Algo.Rootfix where 2 | 3 | import Data.Vector.Unboxed as V 4 | 5 | rootfix :: (V.Vector Int, V.Vector Int) -> V.Vector Int 6 | {-# NOINLINE rootfix #-} 7 | rootfix (ls, rs) = rootfix (V.replicate (V.length ls) 1) ls rs 8 | where 9 | rootfix xs ls rs 10 | = let zs = V.replicate (V.length ls * 2) 0 11 | vs = V.update_ (V.update_ zs ls xs) rs (V.map negate xs) 12 | sums = V.prescanl' (+) 0 vs 13 | in 14 | V.backpermute sums ls 15 | 16 | -------------------------------------------------------------------------------- /examples/vector/benchmarks/Algo/Spectral.hs: -------------------------------------------------------------------------------- 1 | module Algo.Spectral ( spectral ) where 2 | 3 | import Data.Vector.Unboxed as V 4 | 5 | import Data.Bits 6 | 7 | spectral :: Vector Double -> Vector Double 8 | {-# NOINLINE spectral #-} 9 | spectral us = us `seq` V.map row (V.enumFromTo 0 (n-1)) 10 | where 11 | n = V.length us 12 | 13 | row i = i `seq` V.sum (V.imap (\j u -> eval_A i j * u) us) 14 | 15 | eval_A i j = 1 / fromIntegral r 16 | where 17 | r = u + (i+1) 18 | u = t `shiftR` 1 19 | t = n * (n+1) 20 | n = i+j 21 | 22 | -------------------------------------------------------------------------------- /examples/vector/benchmarks/Algo/Tridiag.hs: -------------------------------------------------------------------------------- 1 | module Algo.Tridiag ( tridiag ) where 2 | 3 | import Data.Vector.Unboxed as V 4 | 5 | tridiag :: (Vector Double, Vector Double, Vector Double, Vector Double) 6 | -> Vector Double 7 | {-# NOINLINE tridiag #-} 8 | tridiag (as,bs,cs,ds) = V.prescanr' (\(c,d) x' -> d - c*x') 0 9 | $ V.prescanl' modify (0,0) 10 | $ V.zip (V.zip as bs) (V.zip cs ds) 11 | where 12 | modify (c',d') ((a,b),(c,d)) = 13 | let id = 1 / (b - c'*a) 14 | in 15 | id `seq` (c*id, (d-d'*a)*id) 16 | 17 | -------------------------------------------------------------------------------- /examples/vector/benchmarks/Setup.hs: -------------------------------------------------------------------------------- 1 | import Distribution.Simple 2 | main = defaultMain 3 | 4 | -------------------------------------------------------------------------------- /examples/vector/benchmarks/TestData/Random.hs: -------------------------------------------------------------------------------- 1 | module TestData.Random ( randomVector ) where 2 | 3 | import qualified Data.Vector.Unboxed as V 4 | 5 | import System.Random.MWC 6 | import Control.Monad.ST ( runST ) 7 | import Data.Word 8 | 9 | randomVector :: (Variate a, V.Unbox a) => Word32 -> Int -> IO (V.Vector a) 10 | randomVector seed n = do 11 | g <- initialize (V.singleton seed) 12 | xs <- sequence $ replicate n $ uniform g 13 | io (return $ V.fromListN n xs) 14 | where 15 | io :: IO a -> IO a 16 | io = id 17 | 18 | -------------------------------------------------------------------------------- /examples/vector/tests/Main.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | import qualified Tests.Vector 4 | import qualified Tests.Vector.UnitTests 5 | import qualified Tests.Bundle 6 | import qualified Tests.Move 7 | 8 | import Test.Tasty (defaultMain,testGroup) 9 | 10 | main :: IO () 11 | main = defaultMain $ testGroup "toplevel" $ Tests.Bundle.tests 12 | ++ Tests.Vector.tests 13 | ++ Tests.Vector.UnitTests.tests 14 | ++ Tests.Move.tests 15 | 16 | -------------------------------------------------------------------------------- /examples/vector/tests/Setup.hs: -------------------------------------------------------------------------------- 1 | import Distribution.Simple 2 | main = defaultMain 3 | 4 | -------------------------------------------------------------------------------- /examples/vector/tests/Tests/Vector.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE ConstraintKinds #-} 2 | module Tests.Vector (tests) where 3 | 4 | import Test.Tasty (testGroup) 5 | import qualified Tests.Vector.Boxed 6 | import qualified Tests.Vector.Primitive 7 | import qualified Tests.Vector.Storable 8 | import qualified Tests.Vector.Unboxed 9 | 10 | tests = 11 | [ testGroup "Tests.Vector.Boxed" Tests.Vector.Boxed.tests 12 | , testGroup "Tests.Vector.Primitive" Tests.Vector.Primitive.tests 13 | , testGroup "Tests.Vector.Storable" Tests.Vector.Storable.tests 14 | , testGroup "Tests.Vector.Unboxed" Tests.Vector.Unboxed.tests 15 | ] 16 | -------------------------------------------------------------------------------- /extensions/BUILD.bazel: -------------------------------------------------------------------------------- 1 | filegroup( 2 | name = "all_files", 3 | testonly = True, 4 | srcs = glob(["**"]), 5 | visibility = ["//visibility:public"], 6 | ) 7 | -------------------------------------------------------------------------------- /haskell/ahc.BUILD.tpl: -------------------------------------------------------------------------------- 1 | load( 2 | "@rules_haskell//haskell:defs.bzl", 3 | "haskell_import", 4 | "haskell_toolchain", 5 | ) 6 | 7 | load( 8 | "@rules_haskell//haskell/asterius:defs.bzl", 9 | "asterius_toolchain", 10 | ) 11 | 12 | package(default_visibility = ["//visibility:public"]) 13 | 14 | %{toolchain_libraries} 15 | 16 | %{toolchain} 17 | 18 | %{asterius_toolchain} 19 | -------------------------------------------------------------------------------- /haskell/assets/ghci_script: -------------------------------------------------------------------------------- 1 | :load {ADD_SOURCES} 2 | :module + {MODULES} 3 | -------------------------------------------------------------------------------- /haskell/asterius/asterius_webpack_config.js.tpl: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = { 4 | entry: './{ENTRY}' , 5 | context: path.resolve(__dirname, '.'), 6 | output: { 7 | path: path.resolve(__dirname, "."), 8 | hashFunction: "xxhash64", 9 | }, 10 | mode : 'production', 11 | stats: 'errors-only', 12 | }; 13 | -------------------------------------------------------------------------------- /haskell/asterius/npm/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@rules_haskell_npm//:defs.bzl", "npm_link_all_packages") 2 | 3 | npm_link_all_packages(name = "node_modules") 4 | -------------------------------------------------------------------------------- /haskell/asterius/npm/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "devDependencies": { 4 | "webpack": "^5.94.0", 5 | "webpack-cli": "^5.0.0" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /haskell/c2hs/BUILD.bazel: -------------------------------------------------------------------------------- 1 | toolchain_type( 2 | name = "toolchain", 3 | visibility = ["//visibility:public"], 4 | ) 5 | 6 | filegroup( 7 | name = "all_files", 8 | testonly = True, 9 | srcs = glob(["**"]), 10 | visibility = ["//visibility:public"], 11 | ) 12 | -------------------------------------------------------------------------------- /haskell/cabal_wrapper.bzl: -------------------------------------------------------------------------------- 1 | load("@rules_python//python:defs.bzl", "py_binary") 2 | 3 | def cabal_wrapper(name, **kwargs): 4 | py_binary( 5 | name = name, 6 | srcs = [ 7 | "@rules_haskell//haskell:private/cabal_wrapper.py", 8 | "@rules_haskell//haskell:private/generate_cabal_paths_module.py", 9 | ], 10 | srcs_version = "PY3", 11 | python_version = "PY3", 12 | imports = ["private"], 13 | **kwargs 14 | ) 15 | -------------------------------------------------------------------------------- /haskell/experimental/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # for bzl_library() in //haskell:BUILD.bazel 2 | exports_files([ 3 | "providers.bzl", 4 | "defs.bzl", 5 | ]) 6 | 7 | filegroup( 8 | name = "all_files", 9 | testonly = True, 10 | srcs = glob(["**"]) + [ 11 | "//haskell/experimental/private:all_files", 12 | ], 13 | visibility = ["//visibility:public"], 14 | ) 15 | -------------------------------------------------------------------------------- /haskell/experimental/private/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # for bzl_library() in //haskell:BUILD.bazel 2 | exports_files([ 3 | "module.bzl", 4 | ]) 5 | 6 | filegroup( 7 | name = "all_files", 8 | testonly = True, 9 | srcs = glob(["**"]), 10 | visibility = ["//visibility:public"], 11 | ) 12 | -------------------------------------------------------------------------------- /haskell/experimental/providers.bzl: -------------------------------------------------------------------------------- 1 | HaskellModuleInfo = provider( 2 | doc = "Information about a single Haskell module to compile", 3 | fields = { 4 | "attr": "The attributes of the haskell_module rule", 5 | "direct_module_deps": "The direct dependency targets of the haskell_module rule", 6 | "direct_cross_library_deps": "The direct cross-library dependency targets of the haskell_module rule", 7 | "transitive_module_dep_labels": "List of the labels of transitive module dependencies of the haskell_module rule in the enclosing library", 8 | }, 9 | ) 10 | -------------------------------------------------------------------------------- /haskell/ghc.bzl: -------------------------------------------------------------------------------- 1 | # If you change this, change stackage's version in the start script 2 | # (see stackage.org). 3 | 4 | # Currently, we are using GHC 9.2.x as default. 5 | DEFAULT_GHC_VERSION = "9.4.8" 6 | -------------------------------------------------------------------------------- /haskell/nixpkgs.bzl: -------------------------------------------------------------------------------- 1 | ../rules_haskell_nix/nixpkgs.bzl -------------------------------------------------------------------------------- /haskell/private/dict.bzl: -------------------------------------------------------------------------------- 1 | """Helper functions on dicts.""" 2 | 3 | def find(d, value): 4 | """ Look for the first key correspondind to value `value` in dictionnary `d` """ 5 | for (k, v) in d.items(): 6 | if v == value: 7 | return k 8 | -------------------------------------------------------------------------------- /haskell/private/haskell_runfiles.tpl: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE CPP #-} 2 | module %{module_name} (create, createFromProgramPath, rlocation) where 3 | import qualified Bazel.Runfiles as RulesHaskellRunfiles 4 | create = RulesHaskellRunfiles.createFromCurrentFile __FILE__ 5 | createFromProgramPath = RulesHaskellRunfiles.createFromProgramPathAndCurrentFile (Just __FILE__) 6 | rlocation = RulesHaskellRunfiles.rlocation -------------------------------------------------------------------------------- /haskell/private/mode.bzl: -------------------------------------------------------------------------------- 1 | """Compilation modes.""" 2 | 3 | def is_profiling_enabled(hs): 4 | """Check whether profiling mode is enabled. 5 | 6 | Args: 7 | hs: Haskell context. 8 | 9 | Returns: 10 | bool: True if the mode is enabled, False otherwise. 11 | """ 12 | return hs.mode == "dbg" 13 | -------------------------------------------------------------------------------- /haskell/private/plugins.bzl: -------------------------------------------------------------------------------- 1 | """Utilities for GHC plugins.""" 2 | 3 | def resolve_plugin_tools(ctx, plugin_info): 4 | """Convert a plugin provider to a struct with tools resolved to inputs.""" 5 | (tool_inputs, tool_input_manifests) = ctx.resolve_tools(tools = plugin_info.tools) 6 | return struct( 7 | module = plugin_info.module, 8 | deps = plugin_info.deps, 9 | args = plugin_info.args, 10 | tool_inputs = tool_inputs, 11 | tool_input_manifests = tool_input_manifests, 12 | ) 13 | -------------------------------------------------------------------------------- /haskell/toolchain_info.bzl: -------------------------------------------------------------------------------- 1 | load(":private/actions/info.bzl", "write_proto_file") 2 | load(":private/context.bzl", "haskell_context") 3 | 4 | def _haskell_toolchain_info_impl(ctx): 5 | hs = haskell_context(ctx) 6 | pb = write_proto_file( 7 | hs, 8 | ctx.label.name, 9 | "haskell.GhcConfig", 10 | struct(ghc = hs.tools.ghc.path), 11 | ) 12 | 13 | return [DefaultInfo(files = depset([pb]))] 14 | 15 | haskell_toolchain_info = rule( 16 | implementation = _haskell_toolchain_info_impl, 17 | toolchains = ["@rules_haskell//haskell:toolchain"], 18 | ) 19 | -------------------------------------------------------------------------------- /logo/horizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/rules_haskell/3322610caba2ce8f17ec010b2f76a366a06f97c4/logo/horizontal.png -------------------------------------------------------------------------------- /logo/logomark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/rules_haskell/3322610caba2ce8f17ec010b2f76a366a06f97c4/logo/logomark.png -------------------------------------------------------------------------------- /logo/vertical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/rules_haskell/3322610caba2ce8f17ec010b2f76a366a06f97c4/logo/vertical.png -------------------------------------------------------------------------------- /netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | command = ".netlify/build.sh" 3 | publish = "public" 4 | -------------------------------------------------------------------------------- /nixpkgs/BUILD.bazel: -------------------------------------------------------------------------------- 1 | filegroup( 2 | name = "all_files", 3 | testonly = True, 4 | srcs = glob(["**"]), 5 | visibility = ["//visibility:public"], 6 | ) 7 | -------------------------------------------------------------------------------- /nixpkgs/NOTUSED: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/rules_haskell/3322610caba2ce8f17ec010b2f76a366a06f97c4/nixpkgs/NOTUSED -------------------------------------------------------------------------------- /nixpkgs/default.nix: -------------------------------------------------------------------------------- 1 | { ... }@args: 2 | let 3 | # nixos-24.05 @ 2024-07-02 4 | sha256 = "sha256:0bpw6x46mp0xqfdwbrhnjn6qlb4avglir993n3cdqg8zv4klgllw"; 5 | rev = "706eef542dec88cc0ed25b9075d3037564b2d164"; 6 | in 7 | import (fetchTarball { 8 | inherit sha256; 9 | url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz"; 10 | }) args 11 | -------------------------------------------------------------------------------- /protobuf/BUILD.bazel: -------------------------------------------------------------------------------- 1 | toolchain_type( 2 | name = "toolchain", 3 | visibility = ["//visibility:public"], 4 | ) 5 | 6 | filegroup( 7 | name = "all_files", 8 | testonly = True, 9 | srcs = glob(["**"]), 10 | visibility = ["//visibility:public"], 11 | ) 12 | -------------------------------------------------------------------------------- /registry/bazel_registry.json: -------------------------------------------------------------------------------- 1 | { 2 | "mirrors": [], 3 | "module_base_path": ".." 4 | } 5 | -------------------------------------------------------------------------------- /registry/modules/rules_haskell/1.0/MODULE.bazel: -------------------------------------------------------------------------------- 1 | ../../../../MODULE.bazel -------------------------------------------------------------------------------- /registry/modules/rules_haskell/1.0/source.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "local_path", 3 | "path": "." 4 | } 5 | -------------------------------------------------------------------------------- /registry/modules/rules_haskell/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "homepage": "", 3 | "maintainers": [], 4 | "versions": ["1.0"], 5 | "yanked_versions": [] 6 | } 7 | -------------------------------------------------------------------------------- /registry/modules/rules_haskell_nix/1.0/MODULE.bazel: -------------------------------------------------------------------------------- 1 | ../../../../rules_haskell_nix/MODULE.bazel -------------------------------------------------------------------------------- /registry/modules/rules_haskell_nix/1.0/source.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "local_path", 3 | "path": "rules_haskell_nix" 4 | } 5 | -------------------------------------------------------------------------------- /registry/modules/rules_haskell_nix/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "homepage": "", 3 | "maintainers": [], 4 | "versions": ["1.0"], 5 | "yanked_versions": [] 6 | } 7 | -------------------------------------------------------------------------------- /registry/modules/rules_nixpkgs_cc/0.13.0/MODULE.bazel: -------------------------------------------------------------------------------- 1 | module( 2 | name = "rules_nixpkgs_cc", 3 | version = "0.13.0", 4 | ) 5 | 6 | bazel_dep(name = "rules_nixpkgs_core", version = "0.13.0") 7 | bazel_dep(name = "bazel_skylib", version = "1.0.3") 8 | bazel_dep(name = "rules_cc", version = "0.0.1") 9 | -------------------------------------------------------------------------------- /registry/modules/rules_nixpkgs_cc/0.13.0/source.json: -------------------------------------------------------------------------------- 1 | { 2 | "integrity": "sha256-MCcfe9OA5OIOTXEywySUbE/bwx6+C7tmOKD2GjfnQ5c=", 3 | "strip_prefix": "rules_nixpkgs-0.13.0/toolchains/cc", 4 | "url": "https://github.com/tweag/rules_nixpkgs/releases/download/v0.13.0/rules_nixpkgs-0.13.0.tar.gz" 5 | } 6 | -------------------------------------------------------------------------------- /registry/modules/rules_nixpkgs_cc/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "homepage": "", 3 | "maintainers": [ 4 | { 5 | "email": "benjamin.radford@tweag.io ", 6 | "github": "benradf", 7 | "name": "Benjamin Radford" 8 | }, 9 | { 10 | "email": "andreas.herrmann@tweag.io", 11 | "github": "aherrmann", 12 | "name": "Andreas Herrmann" 13 | } 14 | ], 15 | "versions": ["0.13.0"], 16 | "yanked_versions": [] 17 | } 18 | -------------------------------------------------------------------------------- /registry/modules/rules_nixpkgs_go/0.13.0/MODULE.bazel: -------------------------------------------------------------------------------- 1 | module( 2 | name = "rules_nixpkgs_go", 3 | version = "0.13.0", 4 | ) 5 | 6 | bazel_dep(name = "rules_nixpkgs_core", version = "0.13.0") 7 | bazel_dep(name = "rules_go", repo_name = "io_bazel_rules_go", version = "0.39.1") 8 | bazel_dep(name = "bazel_skylib", version = "1.0.3") 9 | bazel_dep(name = "platforms", version = "0.0.4") 10 | -------------------------------------------------------------------------------- /registry/modules/rules_nixpkgs_go/0.13.0/source.json: -------------------------------------------------------------------------------- 1 | { 2 | "integrity": "sha256-MCcfe9OA5OIOTXEywySUbE/bwx6+C7tmOKD2GjfnQ5c=", 3 | "strip_prefix": "rules_nixpkgs-0.13.0/toolchains/go", 4 | "url": "https://github.com/tweag/rules_nixpkgs/releases/download/v0.13.0/rules_nixpkgs-0.13.0.tar.gz" 5 | } 6 | -------------------------------------------------------------------------------- /registry/modules/rules_nixpkgs_go/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "homepage": "", 3 | "maintainers": [ 4 | { 5 | "email": "benjamin.radford@tweag.io ", 6 | "github": "benradf", 7 | "name": "Benjamin Radford" 8 | }, 9 | { 10 | "email": "andreas.herrmann@tweag.io", 11 | "github": "aherrmann", 12 | "name": "Andreas Herrmann" 13 | } 14 | ], 15 | "versions": ["0.13.0"], 16 | "yanked_versions": [] 17 | } 18 | -------------------------------------------------------------------------------- /registry/modules/rules_nixpkgs_java/0.13.0/MODULE.bazel: -------------------------------------------------------------------------------- 1 | module( 2 | name = "rules_nixpkgs_java", 3 | version = "0.13.0", 4 | ) 5 | 6 | bazel_dep(name = "rules_nixpkgs_core", version = "0.13.0") 7 | local_path_override( 8 | module_name = "rules_nixpkgs_core", 9 | path = "../../core", 10 | ) 11 | bazel_dep(name = "rules_java", version = "7.3.1") 12 | bazel_dep(name = "bazel_skylib", version = "1.0.3") 13 | 14 | toolchains = use_extension("@rules_java//java:extensions.bzl", "toolchains") 15 | use_repo(toolchains, "remote_java_tools") 16 | -------------------------------------------------------------------------------- /registry/modules/rules_nixpkgs_java/0.13.0/source.json: -------------------------------------------------------------------------------- 1 | { 2 | "integrity": "sha256-MCcfe9OA5OIOTXEywySUbE/bwx6+C7tmOKD2GjfnQ5c=", 3 | "strip_prefix": "rules_nixpkgs-0.13.0/toolchains/java", 4 | "url": "https://github.com/tweag/rules_nixpkgs/releases/download/v0.13.0/rules_nixpkgs-0.13.0.tar.gz" 5 | } 6 | -------------------------------------------------------------------------------- /registry/modules/rules_nixpkgs_java/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "homepage": "", 3 | "maintainers": [ 4 | { 5 | "email": "benjamin.radford@tweag.io ", 6 | "github": "benradf", 7 | "name": "Benjamin Radford" 8 | }, 9 | { 10 | "email": "andreas.herrmann@tweag.io", 11 | "github": "aherrmann", 12 | "name": "Andreas Herrmann" 13 | } 14 | ], 15 | "versions": ["0.13.0"], 16 | "yanked_versions": [] 17 | } 18 | -------------------------------------------------------------------------------- /registry/modules/rules_nixpkgs_posix/0.13.0/MODULE.bazel: -------------------------------------------------------------------------------- 1 | module( 2 | name = "rules_nixpkgs_posix", 3 | version = "0.13.0", 4 | ) 5 | 6 | bazel_dep(name = "rules_nixpkgs_core", version = "0.13.0") 7 | bazel_dep(name = "rules_sh", version = "0.3.0") 8 | bazel_dep(name = "bazel_skylib", version = "1.0.3") 9 | -------------------------------------------------------------------------------- /registry/modules/rules_nixpkgs_posix/0.13.0/source.json: -------------------------------------------------------------------------------- 1 | { 2 | "integrity": "sha256-MCcfe9OA5OIOTXEywySUbE/bwx6+C7tmOKD2GjfnQ5c=", 3 | "strip_prefix": "rules_nixpkgs-0.13.0/toolchains/posix", 4 | "url": "https://github.com/tweag/rules_nixpkgs/releases/download/v0.13.0/rules_nixpkgs-0.13.0.tar.gz" 5 | } 6 | -------------------------------------------------------------------------------- /registry/modules/rules_nixpkgs_posix/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "homepage": "", 3 | "maintainers": [ 4 | { 5 | "email": "benjamin.radford@tweag.io ", 6 | "github": "benradf", 7 | "name": "Benjamin Radford" 8 | }, 9 | { 10 | "email": "andreas.herrmann@tweag.io", 11 | "github": "aherrmann", 12 | "name": "Andreas Herrmann" 13 | } 14 | ], 15 | "versions": ["0.13.0"], 16 | "yanked_versions": [] 17 | } 18 | -------------------------------------------------------------------------------- /registry/modules/rules_nixpkgs_python/0.13.0/MODULE.bazel: -------------------------------------------------------------------------------- 1 | module( 2 | name = "rules_nixpkgs_python", 3 | version = "0.13.0", 4 | ) 5 | 6 | bazel_dep(name = "rules_nixpkgs_core", version = "0.13.0") 7 | bazel_dep(name = "bazel_skylib", version = "1.0.3") 8 | -------------------------------------------------------------------------------- /registry/modules/rules_nixpkgs_python/0.13.0/source.json: -------------------------------------------------------------------------------- 1 | { 2 | "integrity": "sha256-MCcfe9OA5OIOTXEywySUbE/bwx6+C7tmOKD2GjfnQ5c=", 3 | "strip_prefix": "rules_nixpkgs-0.13.0/toolchains/python", 4 | "url": "https://github.com/tweag/rules_nixpkgs/releases/download/v0.13.0/rules_nixpkgs-0.13.0.tar.gz" 5 | } 6 | -------------------------------------------------------------------------------- /registry/modules/rules_nixpkgs_python/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "homepage": "", 3 | "maintainers": [ 4 | { 5 | "email": "benjamin.radford@tweag.io ", 6 | "github": "benradf", 7 | "name": "Benjamin Radford" 8 | }, 9 | { 10 | "email": "andreas.herrmann@tweag.io", 11 | "github": "aherrmann", 12 | "name": "Andreas Herrmann" 13 | } 14 | ], 15 | "versions": ["0.13.0"], 16 | "yanked_versions": [] 17 | } 18 | -------------------------------------------------------------------------------- /rules_haskell_nix/.bazelrc: -------------------------------------------------------------------------------- 1 | import %workspace%/../.bazelrc.common 2 | import %workspace%/.bazelrc.bzlmod 3 | 4 | # User Configuration 5 | # ------------------ 6 | try-import %workspace%/.bazelrc.local 7 | -------------------------------------------------------------------------------- /rules_haskell_nix/.bazelrc.bzlmod: -------------------------------------------------------------------------------- 1 | common:bzlmod --enable_bzlmod 2 | 3 | # Note, have to use /// to make Bazel not crash on Windows 4 | common:common --registry=file:///%workspace%/../registry --registry=https://bcr.bazel.build 5 | -------------------------------------------------------------------------------- /rules_haskell_nix/.bazelversion: -------------------------------------------------------------------------------- 1 | ../.bazelversion -------------------------------------------------------------------------------- /rules_haskell_nix/README.md: -------------------------------------------------------------------------------- 1 | With bzlmod, the [nix functionalities](https://api.haskell.build/haskell/nixpkgs.html) provided by rules_haskell must be 2 | accessed via `@rules_haskell_nix//:nixpkgs.bzl`. 3 | 4 | This way the main `rules_haskell` module does not have to depend on 5 | `rules_nixpkgs` when we do not intend to use nix toolchains. 6 | -------------------------------------------------------------------------------- /rules_haskell_nix/WORKSPACE: -------------------------------------------------------------------------------- 1 | # This WORKSPACE file is empty because the folder is only used as a repository with bzlmod 2 | -------------------------------------------------------------------------------- /rules_haskell_nix/extensions/BUILD.bazel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/rules_haskell/3322610caba2ce8f17ec010b2f76a366a06f97c4/rules_haskell_nix/extensions/BUILD.bazel -------------------------------------------------------------------------------- /rules_haskell_nix/nix_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | export XDG_CACHE_HOME=${TMPDIR} 4 | 5 | exec nix run -I nixpkgs=../nixpkgs 'nixpkgs#cowsay' -- hello, rules_haskell_nix 6 | -------------------------------------------------------------------------------- /rules_haskell_nix/non_module_deps.bzl: -------------------------------------------------------------------------------- 1 | load("@rules_haskell//tools:os_info.bzl", "os_info") 2 | load( 3 | "@rules_nixpkgs_core//:nixpkgs.bzl", 4 | "nixpkgs_local_repository", 5 | ) 6 | 7 | def repositories(*, bzlmod): 8 | os_info(name = "os_info") 9 | 10 | nixpkgs_local_repository( 11 | name = "nixpkgs_default", 12 | nix_file = "@rules_haskell//nixpkgs:default.nix", 13 | ) 14 | 15 | def _non_module_deps_impl(_ctx): 16 | repositories(bzlmod = True) 17 | 18 | non_module_deps = module_extension( 19 | implementation = _non_module_deps_impl, 20 | ) 21 | -------------------------------------------------------------------------------- /rules_haskell_nix/private/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/rules_haskell/3322610caba2ce8f17ec010b2f76a366a06f97c4/rules_haskell_nix/private/BUILD -------------------------------------------------------------------------------- /rules_haskell_tests/.bazelrc: -------------------------------------------------------------------------------- 1 | import %workspace%/../.bazelrc.common 2 | import %workspace%/.bazelrc.bzlmod 3 | 4 | # User Configuration 5 | # ------------------ 6 | try-import %workspace%/.bazelrc.local 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/.bazelrc.bzlmod: -------------------------------------------------------------------------------- 1 | # Disable bzlmod explicitly by default, see https://github.com/tweag/rules_haskell/issues/1977 2 | common --noenable_bzlmod 3 | 4 | common:bzlmod --enable_bzlmod 5 | 6 | # Note, have to use /// to make Bazel not crash on Windows 7 | common:common --registry=file:///%workspace%/../registry --registry=https://bcr.bazel.build 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/.bazelversion: -------------------------------------------------------------------------------- 1 | ../.bazelversion -------------------------------------------------------------------------------- /rules_haskell_tests/.ghcide: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | build_ghcide() { 4 | bazel build //tests/ghcide \ 5 | --experimental_show_artifacts \ 6 | 2>&1 \ 7 | | awk ' 8 | /^>>>/ { print substr($1, 4); next } 9 | { print $0 > "/dev/stderr" } 10 | ' 11 | } 12 | ghcide="$(build_ghcide)" 13 | "$ghcide" "$@" 14 | -------------------------------------------------------------------------------- /rules_haskell_tests/.hie-bios: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | hie_bios_flags() { 4 | bazel run //tests:hie-bios@bios 5 | # Make warnings non-fatal 6 | echo -Wwarn 7 | } 8 | if [[ -z "${HIE_BIOS_OUTPUT-}" ]]; then 9 | hie_bios_flags 10 | else 11 | hie_bios_flags >"$HIE_BIOS_OUTPUT" 12 | fi 13 | -------------------------------------------------------------------------------- /rules_haskell_tests/BUILD.bazel: -------------------------------------------------------------------------------- 1 | exports_files( 2 | [ 3 | "BUILD.bazel", 4 | "MODULE.bazel", 5 | "WORKSPACE", 6 | "WORKSPACE.bzlmod", 7 | "non_module_deps.bzl", 8 | "non_module_deps_1.bzl", 9 | "non_module_deps_2.bzl", 10 | "non_module_deps_bzlmod.bzl", 11 | ], 12 | visibility = ["//buildifier:__pkg__"], 13 | ) 14 | -------------------------------------------------------------------------------- /rules_haskell_tests/WORKSPACE.bzlmod: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/rules_haskell/3322610caba2ce8f17ec010b2f76a366a06f97c4/rules_haskell_tests/WORKSPACE.bzlmod -------------------------------------------------------------------------------- /rules_haskell_tests/ghcide-snapshot.json: -------------------------------------------------------------------------------- 1 | ghcide-snapshot_9.4.6.json -------------------------------------------------------------------------------- /rules_haskell_tests/ghcide-stack-snapshot.yaml: -------------------------------------------------------------------------------- 1 | ghcide-stack-snapshot_9.4.8.yaml -------------------------------------------------------------------------------- /rules_haskell_tests/ghcide-stack-snapshot_9.6.5.yaml: -------------------------------------------------------------------------------- 1 | resolver: lts-22.27 2 | 3 | packages: 4 | - ghcide-2.6.0.0 5 | - hie-compat-0.3.1.1 6 | - hiedb-0.5.0.1 7 | - hls-graph-2.6.0.0 8 | - hls-plugin-api-2.6.0.0 9 | - implicit-hie-0.1.4.0 10 | - implicit-hie-cradle-0.5.0.1 11 | 12 | -------------------------------------------------------------------------------- /rules_haskell_tests/ghcide-stack-snapshot_9.8.2.yaml: -------------------------------------------------------------------------------- 1 | resolver: nightly-2024-10-10 2 | 3 | packages: 4 | - ghcide-2.9.0.0 5 | - hie-compat-0.3.1.2 6 | - hie-bios-0.14.0 7 | - hiedb-0.6.0.1 8 | - hls-graph-2.9.0.0 9 | - hls-plugin-api-2.9.0.0 10 | - implicit-hie-0.1.4.0 11 | - implicit-hie-cradle-0.5.0.1 12 | - logict-0.8.1.0 13 | - special-functors-1.0.0.1 14 | 15 | # no release on hackage 16 | - git: https://github.com/haskell-works/hw-fingertree 17 | commit: 8b2f9003b6aebf958f0f03a5d0cc5bb6f7854727 18 | -------------------------------------------------------------------------------- /rules_haskell_tests/hie.yaml: -------------------------------------------------------------------------------- 1 | cradle: {bios: {program: ".hie-bios"}} 2 | -------------------------------------------------------------------------------- /rules_haskell_tests/nixpkgs: -------------------------------------------------------------------------------- 1 | ../nixpkgs -------------------------------------------------------------------------------- /rules_haskell_tests/stackage-pinning-test.yaml: -------------------------------------------------------------------------------- 1 | stackage-pinning-test_9.4.8.yaml -------------------------------------------------------------------------------- /rules_haskell_tests/stackage-pinning-test_snapshot.json: -------------------------------------------------------------------------------- 1 | stackage-pinning-test_snapshot_9.4.6.json -------------------------------------------------------------------------------- /rules_haskell_tests/stackage-zlib-snapshot.json: -------------------------------------------------------------------------------- 1 | stackage-zlib-snapshot_9.4.6.json -------------------------------------------------------------------------------- /rules_haskell_tests/stackage_snapshot.json: -------------------------------------------------------------------------------- 1 | stackage_snapshot_9.4.8.json -------------------------------------------------------------------------------- /rules_haskell_tests/stackage_snapshot.yaml: -------------------------------------------------------------------------------- 1 | stackage_snapshot_9.4.8.yaml -------------------------------------------------------------------------------- /rules_haskell_tests/stackage_snapshot_9.2.8.yaml: -------------------------------------------------------------------------------- 1 | ../stackage_snapshot_9.2.8.yaml -------------------------------------------------------------------------------- /rules_haskell_tests/stackage_snapshot_9.4.8.yaml: -------------------------------------------------------------------------------- 1 | ../stackage_snapshot_9.4.8.yaml -------------------------------------------------------------------------------- /rules_haskell_tests/stackage_snapshot_9.6.5.yaml: -------------------------------------------------------------------------------- 1 | ../stackage_snapshot_9.6.5.yaml -------------------------------------------------------------------------------- /rules_haskell_tests/stackage_snapshot_9.8.2.yaml: -------------------------------------------------------------------------------- 1 | ../stackage_snapshot_9.8.2.yaml -------------------------------------------------------------------------------- /rules_haskell_tests/tests/Foo.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | module Foo where 3 | 4 | -- This is here just to trigger template haskell 5 | blork = $([| 1 + 1 |]) 6 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/LZ4.hs: -------------------------------------------------------------------------------- 1 | -- | Foreign bindings to LZ4 library. 2 | module LZ4 where 3 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/asterius_binary/BUILD: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro("//tests/binary-with-lib") 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/binary-dynamic/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro("//tests/binary-dynamic") 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/binary-simple/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro( 4 | "//tests/binary-simple", 5 | test_entry_point = "test_entry_point.mjs", 6 | ) 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/binary-with-compiler-flags/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro("//tests/binary-with-compiler-flags") 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/binary-with-lib-dynamic/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro("//tests/binary-with-lib-dynamic") 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/binary-with-link-flags/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro("//tests/binary-with-link-flags") 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/binary-with-tool/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro("//tests/binary-with-tool") 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/binary_with_import/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro("//tests/binary-with-import") 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/cabal-toolchain-flags/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro("//tests/cabal-toolchain-flags") 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/cpp_macro_conflict/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro("//tests/cpp_macro_conflict:macro_conflict") 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/encoding/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro("//tests/encoding") 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/extra-source-files/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro("//tests/extra-source-files:extra-source-files-bin") 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/generated_modules/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro("//tests/generated-modules") 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/haskell_cabal_binary/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro("//tests/haskell_cabal_binary") 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/haskell_cabal_datafile/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro("//tests/haskell_cabal_datafiles/other_binary/haskell_cabal_library_datafiles_2:bin") 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/haskell_toolchain_binary/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro("//tests/haskell_toolchain_library:binary") 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/hs-boot/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro("//tests/hs-boot") 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/lhs/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro("//tests/lhs:lhs-bin") 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/library-empty/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro("//tests/library-empty") 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/library-exports/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro("//tests/library-exports:library-reexported_modules") 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/package-id-clash-binary/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro("//tests/package-id-clash-binary:bin") 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/package-name/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro( 4 | "//tests/package-name:bin", 5 | test_subfolder_name = "test_subfolder_name", 6 | ) 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/package-reexport/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro("//tests/package-reexport:final") 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/repl-flags/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro( 4 | "//tests/repl-flags:compiler_flags", 5 | suffix = "_compiler", 6 | ) 7 | 8 | asterius_test_macro( 9 | "//tests/repl-flags:repl_flags", 10 | suffix = "_repl", 11 | ) 12 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/repl-make-variables/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro("//tests/repl-make-variables:test-compiler-flags") 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/stack_toolchain_libraries/main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE MagicHash #-} 2 | 3 | module Main where 4 | import GHC.Integer.Logarithms 5 | import GHC.Exts 6 | import Text.XHtml 7 | 8 | main = do 9 | print $ I# (integerLog2# 8) 10 | print $ head treeColors 11 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/stack_toolchain_libraries/snapshot.yaml: -------------------------------------------------------------------------------- 1 | resolver: "lts-16.31" 2 | packages: 3 | - xhtml-3000.2.2.1 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/stackage_zlib_runpath/BUILD: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro("//tests/stackage_zlib_runpath:cabal-binary") 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/target-name/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro("//tests/target-name:bin0-a_A@a") 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/textual-hdrs/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro("//tests/textual-hdrs") 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/two-libs/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro("//tests/two-libs") 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/two-same-file/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro( 4 | "//tests/two-same-file:one", 5 | suffix = "_one", 6 | ) 7 | 8 | asterius_test_macro( 9 | "//tests/two-same-file:two", 10 | suffix = "_two", 11 | ) 12 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/asterius/version-macros/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests:asterius/asterius_tests_utils.bzl", "asterius_test_macro") 2 | 3 | asterius_test_macro("//tests/version-macros:version_macros_c2hs") 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-custom-main/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load( 2 | "@rules_haskell//haskell:defs.bzl", 3 | "haskell_test", 4 | ) 5 | 6 | package(default_testonly = 1) 7 | 8 | haskell_test( 9 | name = "binary-custom-main", 10 | srcs = ["Main.hs"], 11 | expected_covered_expressions_percentage = 50, 12 | tags = [ 13 | "coverage-compatible", 14 | ], 15 | visibility = ["//visibility:public"], 16 | deps = ["//tests/hackage:base"], 17 | ) 18 | 19 | filegroup( 20 | name = "all_files", 21 | testonly = True, 22 | srcs = glob(["**"]), 23 | visibility = ["//visibility:public"], 24 | ) 25 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-custom-main/Main.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | main :: IO () 4 | main = return () 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-dynamic/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load( 2 | "@rules_haskell//haskell:defs.bzl", 3 | "haskell_test", 4 | ) 5 | 6 | package(default_testonly = 1) 7 | 8 | haskell_test( 9 | name = "binary-dynamic", 10 | srcs = ["Main.hs"], 11 | linkstatic = False, 12 | visibility = ["//visibility:public"], 13 | deps = ["//tests/hackage:base"], 14 | ) 15 | 16 | filegroup( 17 | name = "all_files", 18 | testonly = True, 19 | srcs = glob(["**"]), 20 | visibility = ["//visibility:public"], 21 | ) 22 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-dynamic/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | main = putStrLn "hello world" 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-exe-path/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load( 2 | "@rules_haskell//haskell:defs.bzl", 3 | "haskell_test", 4 | ) 5 | 6 | package(default_testonly = 1) 7 | 8 | haskell_test( 9 | name = "binary-exe-path", 10 | srcs = ["Main.hs"], 11 | visibility = ["//visibility:public"], 12 | deps = ["//tests/hackage:base"], 13 | ) 14 | 15 | filegroup( 16 | name = "all_files", 17 | testonly = True, 18 | srcs = glob(["**"]), 19 | visibility = ["//visibility:public"], 20 | ) 21 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-exe-path/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import System.Environment 4 | 5 | main = getExecutablePath >>= putStrLn 6 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-indirect-cbits/Main.hs: -------------------------------------------------------------------------------- 1 | import AddOne 2 | 3 | main :: IO () 4 | main = do 5 | putStrLn $ show $ addOne 2 6 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-indirect-cbits/Wrapper.hs: -------------------------------------------------------------------------------- 1 | module Wrapper 2 | ( module AddOne 3 | ) where 4 | 5 | import AddOne 6 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-indirect-cbits/Wrapper2.hs: -------------------------------------------------------------------------------- 1 | module Wrapper2 2 | ( module AddOne 3 | , addOne2 4 | ) where 5 | 6 | import AddOne 7 | import qualified Wrapper 8 | 9 | addOne2 = Wrapper.addOne 10 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-linkstatic-flag/HsLib.hs: -------------------------------------------------------------------------------- 1 | module HsLib (value) where 2 | 3 | value :: Int 4 | value = 13 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-linkstatic-flag/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE ForeignFunctionInterface #-} 2 | 3 | module Main (main) where 4 | 5 | import qualified HsLib 6 | 7 | foreign import ccall "value" value :: Int 8 | 9 | main = print $ HsLib.value + value 10 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-linkstatic-flag/c-lib.c: -------------------------------------------------------------------------------- 1 | int value() { return 29; } 2 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-simple/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load( 2 | "@rules_haskell//haskell:defs.bzl", 3 | "haskell_test", 4 | ) 5 | 6 | package(default_testonly = 1) 7 | 8 | haskell_test( 9 | name = "binary-simple", 10 | srcs = ["Main.hs"], 11 | expected_covered_expressions_percentage = 100, 12 | tags = ["coverage-compatible"], 13 | visibility = ["//visibility:public"], 14 | deps = ["//tests/hackage:base"], 15 | ) 16 | 17 | filegroup( 18 | name = "all_files", 19 | testonly = True, 20 | srcs = glob(["**"]), 21 | visibility = ["//visibility:public"], 22 | ) 23 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-simple/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | main = putStrLn "hello world" 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-with-compiler-flags/Main.hs: -------------------------------------------------------------------------------- 1 | -- Expects to pull -XStandaloneDeriving from the default compiler flags. 2 | module Main (main) where 3 | 4 | data Foo = Foo 5 | deriving instance Show Foo 6 | 7 | -- Expects -XLambdaCase to be passed via the 'compiler_flags' rule attribute. 8 | dummyId :: Foo -> Foo 9 | dummyId = \case 10 | Foo -> Foo 11 | 12 | main :: IO () 13 | main = print $ dummyId Foo 14 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-with-data/bin1-input: -------------------------------------------------------------------------------- 1 | contents 2 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-with-data/bin1.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE CPP #-} 2 | 3 | module Main where 4 | 5 | import qualified Bazel.Runfiles 6 | import Control.Monad (unless) 7 | 8 | main :: IO () 9 | main = do 10 | runfiles <- Bazel.Runfiles.create 11 | let path = Bazel.Runfiles.rlocation runfiles ("rules_haskell_tests/" ++ BIN1_INPUT) 12 | contents <- readFile path 13 | unless (contents == "contents\n") 14 | $ error $ "Incorrect input; got " ++ show contents 15 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-with-data/bin2.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import qualified Bazel.Runfiles 4 | import System.Process (callProcess) 5 | import System.Environment (getArgs) 6 | 7 | main = do 8 | [arg] <- getArgs 9 | runfiles <- Bazel.Runfiles.create 10 | let path = Bazel.Runfiles.rlocation runfiles ("rules_haskell_tests/" ++ arg) 11 | callProcess path [] 12 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-with-import/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import Lib (printValue) 4 | 5 | main :: IO () 6 | main = printValue 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-with-import/src/Lib.hs: -------------------------------------------------------------------------------- 1 | module Lib (printValue) where 2 | 3 | import Control.Monad (void) 4 | import Control.Monad.Trans.Class (lift) 5 | import Control.Monad.Trans.Except (ExceptT, runExceptT) 6 | 7 | getValue :: Monad m => ExceptT e m Int 8 | getValue = pure 42 9 | 10 | printValue :: IO () 11 | printValue = void $ runExceptT $ do 12 | value <- getValue 13 | lift $ print value 14 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-with-indirect-sysdeps/HsLib.hs: -------------------------------------------------------------------------------- 1 | module HsLib where 2 | 3 | import Foreign.Ptr 4 | import Foreign.C.Types 5 | 6 | foreign import ccall crc32 :: CLong -> Ptr () -> CInt -> IO () 7 | 8 | test = crc32 0 nullPtr 0 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-with-indirect-sysdeps/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import HsLib (test) 4 | 5 | main = test 6 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-with-lib-dynamic/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import Control.Monad (unless) 4 | import Lib (value) 5 | 6 | main = unless (value == 42) 7 | $ error $ "Incorrect lib value. Got " <> show value 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-with-lib-dynamic/src/Lib.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE NoImplicitPrelude #-} 2 | 3 | module Lib (value) where 4 | 5 | value = 42 6 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-with-lib/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | module Main where 3 | 4 | import Control.Monad (unless) 5 | import Lib (value) 6 | import Language.Haskell.TH 7 | 8 | val :: Int 9 | val = $(value) 10 | 11 | main = unless (val == 42) 12 | $ error $ "Incorrect lib value. Got " <> show val 13 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-with-lib/src/Lib.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE NoImplicitPrelude #-} 2 | {-# LANGUAGE TemplateHaskell #-} 3 | 4 | module Lib (value) where 5 | 6 | import Language.Haskell.TH 7 | 8 | value :: Q Exp 9 | value = [|42|] 10 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-with-link-flags/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load( 2 | "@rules_haskell//haskell:defs.bzl", 3 | "haskell_test", 4 | ) 5 | 6 | package( 7 | default_testonly = 1, 8 | default_visibility = ["//visibility:public"], 9 | ) 10 | 11 | haskell_test( 12 | name = "binary-with-link-flags", 13 | srcs = ["Main.hs"], 14 | ghcopts = ["-threaded"], 15 | visibility = ["//visibility:public"], 16 | deps = ["//tests/hackage:base"], 17 | ) 18 | 19 | filegroup( 20 | name = "all_files", 21 | testonly = True, 22 | srcs = glob(["**"]), 23 | visibility = ["//visibility:public"], 24 | ) 25 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-with-link-flags/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | main = return () 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-with-main/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load( 2 | "@rules_haskell//haskell:defs.bzl", 3 | "haskell_test", 4 | ) 5 | 6 | package(default_testonly = 1) 7 | 8 | haskell_test( 9 | name = "binary-with-main", 10 | srcs = ["MainIsHere.hs"], 11 | main_function = "MainIsHere.this", 12 | visibility = ["//visibility:public"], 13 | deps = ["//tests/hackage:base"], 14 | ) 15 | 16 | filegroup( 17 | name = "all_files", 18 | testonly = True, 19 | srcs = glob(["**"]), 20 | visibility = ["//visibility:public"], 21 | ) 22 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-with-main/MainIsHere.hs: -------------------------------------------------------------------------------- 1 | module MainIsHere (this) where 2 | 3 | this :: IO () 4 | this = return () 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-with-plugin/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | main = 4 | if "plugin" == ['p', 'l', 'u', 'g', 'i', 'n', '1'] then 5 | putStrLn "hello world" 6 | else 7 | error "plugin1 not loaded" 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-with-plugin/main2.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | main = 4 | if "plugin" == ['p', 'l', 'u', 'g', 'i', 'n', '2'] then 5 | putStrLn "hello world" 6 | else 7 | error "plugin2 not loaded" 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-with-plugin/main3.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | main = 4 | if "plugin" == ['p', 'l', 'u', 'g', 'i', 'n', '2'] then 5 | error "unexpected plugin2 loaded" 6 | else 7 | putStrLn "hello world" 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-with-prebuilt/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import Data.List () 4 | import Language.Haskell.TH () 5 | 6 | main = return () 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-with-sysdeps/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load( 2 | "@rules_haskell//haskell:defs.bzl", 3 | "haskell_test", 4 | ) 5 | 6 | package(default_testonly = 1) 7 | 8 | haskell_test( 9 | name = "binary-with-sysdeps", 10 | srcs = ["Main.hs"], 11 | visibility = ["//visibility:public"], 12 | deps = [ 13 | "//tests:zlib", 14 | "//tests/hackage:base", 15 | ], 16 | ) 17 | 18 | filegroup( 19 | name = "all_files", 20 | testonly = True, 21 | srcs = glob(["**"]), 22 | visibility = ["//visibility:public"], 23 | ) 24 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-with-sysdeps/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import Foreign.Ptr 4 | import Foreign.C.Types 5 | 6 | foreign import ccall crc32 :: CLong -> Ptr () -> CInt -> IO () 7 | 8 | main = crc32 0 nullPtr 0 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-with-tool/Cat.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import System.Environment (getArgs) 4 | 5 | main = do 6 | [name, src, dest] <- getArgs 7 | contents <- readFile src 8 | writeFile dest contents 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/binary-with-tool/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE CPP #-} 2 | {-# OPTIONS_GHC -F -pgmF CAT #-} 3 | 4 | module Main where 5 | 6 | main :: IO Int 7 | main = return 0 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/bzlmod_runfiles/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | import Lib 3 | 4 | main :: IO () 5 | main = print =<< content 6 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/bzlmod_runfiles/other_module/.bazelrc: -------------------------------------------------------------------------------- 1 | import %workspace%/../../../../.bazelrc.common 2 | import %workspace%/.bazelrc.bzlmod 3 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/bzlmod_runfiles/other_module/.bazelrc.bzlmod: -------------------------------------------------------------------------------- 1 | common:bzlmod --experimental_enable_bzlmod 2 | common:bzlmod --registry=file:%workspace%/../../../../registry --registry=https://bcr.bazel.build 3 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/bzlmod_runfiles/other_module/Lib.hs: -------------------------------------------------------------------------------- 1 | module Lib where 2 | 3 | import Runfiles 4 | import System.IO (IOMode (ReadMode), hGetLine, withFile) 5 | 6 | content :: IO String 7 | content = do 8 | r <- Runfiles.create 9 | let location = Runfiles.rlocation r "other_module/datafile" 10 | withFile location ReadMode hGetLine 11 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/bzlmod_runfiles/other_module/MODULE.bazel: -------------------------------------------------------------------------------- 1 | module( 2 | name = "other_module", 3 | version = "0.0.1", 4 | ) 5 | 6 | bazel_dep( 7 | name = "rules_haskell_nix", 8 | version = "1.0", 9 | ) 10 | bazel_dep( 11 | name = "rules_haskell", 12 | version = "1.0", 13 | ) 14 | bazel_dep( 15 | name = "rules_nixpkgs_core", 16 | version = "0.13.0", 17 | ) 18 | bazel_dep( 19 | name = "platforms", 20 | version = "0.0.11", 21 | ) 22 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/bzlmod_runfiles/other_module/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | import Lib 3 | 4 | main :: IO () 5 | main = print =<< content 6 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/bzlmod_runfiles/other_module/WORKSPACE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/rules_haskell/3322610caba2ce8f17ec010b2f76a366a06f97c4/rules_haskell_tests/tests/bzlmod_runfiles/other_module/WORKSPACE -------------------------------------------------------------------------------- /rules_haskell_tests/tests/bzlmod_runfiles/other_module/datafile: -------------------------------------------------------------------------------- 1 | content -------------------------------------------------------------------------------- /rules_haskell_tests/tests/c-compiles-still/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load( 2 | "@rules_haskell//haskell:defs.bzl", 3 | "haskell_library", 4 | ) 5 | 6 | package(default_testonly = 1) 7 | 8 | haskell_library( 9 | name = "foo", 10 | srcs = ["Foo.hs"], 11 | deps = [ 12 | "//tests/data:ourclibrary", 13 | "//tests/hackage:base", 14 | ], 15 | ) 16 | 17 | filegroup( 18 | name = "all_files", 19 | testonly = True, 20 | srcs = glob(["**"]), 21 | visibility = ["//visibility:public"], 22 | ) 23 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/c-compiles-still/Foo.hs: -------------------------------------------------------------------------------- 1 | module Foo (foo) where 2 | 3 | foo :: Int 4 | foo = 5 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/c-compiles/Lib.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE ForeignFunctionInterface #-} 2 | module Lib (ten) where 3 | 4 | import Foreign.C.Types (CInt(..)) 5 | 6 | foreign import ccall "c_add_one" 7 | c_add_one :: CInt -> CInt 8 | 9 | ten :: Int 10 | ten = fromIntegral (c_add_one 9) 11 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/c-compiles/Main.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | import Control.Monad (unless) 4 | import Lib (ten) 5 | 6 | main :: IO () 7 | main = unless (ten == 10) 8 | $ error $ "Incorrect lib value. Got " <> show ten 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/c2hs/Bar.chs: -------------------------------------------------------------------------------- 1 | module Bar (bar) where 2 | 3 | {#import Foo.Foo#} 4 | 5 | bar :: Int 6 | bar = 6 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/c2hs/repo/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@rules_haskell//haskell:c2hs.bzl", "c2hs_library") 2 | 3 | package(default_testonly = 1) 4 | 5 | c2hs_library( 6 | name = "baz", 7 | srcs = ["Baz.chs"], 8 | visibility = ["//visibility:public"], 9 | deps = ["@rules_haskell_tests//tests:zlib"], 10 | ) 11 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/c2hs/repo/Baz.chs: -------------------------------------------------------------------------------- 1 | module Baz (baz) where 2 | 3 | #include 4 | 5 | baz :: Int 6 | baz = {# sizeof gz_header_s #} 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/c2hs/repo/WORKSPACE: -------------------------------------------------------------------------------- 1 | workspace(name = "c2hs_repo") 2 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/c2hs/src/Foo/Foo.chs: -------------------------------------------------------------------------------- 1 | module Foo.Foo (foo) where 2 | 3 | #include 4 | 5 | foo :: Int 6 | foo = {# sizeof gz_header_s #} 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/cabal-toolchain-flags/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_binary") 2 | 3 | haskell_cabal_binary( 4 | name = "cabal-toolchain-flags", 5 | srcs = glob(["**"]), 6 | visibility = ["//tests/asterius/cabal-toolchain-flags:__pkg__"], 7 | ) 8 | 9 | filegroup( 10 | name = "all_files", 11 | testonly = True, 12 | srcs = glob(["**"]), 13 | visibility = ["//visibility:public"], 14 | ) 15 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/cabal-toolchain-flags/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE CPP #-} 2 | 3 | module Main where 4 | 5 | import Data.ByteString 6 | 7 | #ifdef TESTS_TOOLCHAIN_CABALOPTS 8 | main :: IO () 9 | main = print ("hello" :: ByteString) 10 | #endif 11 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/cabal-toolchain-flags/test.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: >=1.10 2 | name: cabal-toolchain-flags 3 | version: 0.1.0.0 4 | build-type: Simple 5 | 6 | executable cabal-toolchain-flags 7 | build-depends: base, bytestring 8 | default-language: Haskell2010 9 | extensions: OverloadedStrings 10 | main-is: Main.hs 11 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/cabal_binary_th/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE QuasiQuotes #-} 2 | module Main where 3 | 4 | import QQ 5 | 6 | main = print [qq| 1 + 1 |] 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/cabal_binary_th/QQ.hs: -------------------------------------------------------------------------------- 1 | {-# OPTIONS_GHC -Wno-missing-fields #-} 2 | 3 | module QQ where 4 | 5 | import Language.Haskell.TH 6 | import Language.Haskell.TH.Quote 7 | 8 | qq :: QuasiQuoter 9 | qq = QuasiQuoter { quoteExp = stringE } 10 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/cabal_binary_th/cabal_test_th.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: 1.12 2 | 3 | name: cabal-test-th 4 | version: 0.0.1 5 | license: AllRightsReserved 6 | build-type: Simple 7 | 8 | library 9 | other-modules: 10 | Main 11 | QQ 12 | build-depends: 13 | base 14 | , template-haskell 15 | default-language: Haskell2010 16 | 17 | executable anexe 18 | main-is: Main.hs 19 | other-modules: 20 | QQ 21 | build-depends: 22 | base 23 | , template-haskell 24 | default-language: Haskell2010 25 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/cc_haskell_import/LibA.hs: -------------------------------------------------------------------------------- 1 | module LibA (add_one) where 2 | 3 | import Data.Int (Int32) 4 | 5 | foreign import ccall "c_add_one" c_add_one' :: Int32 -> Int32 6 | 7 | add_one :: Int32 -> Int32 8 | add_one x = c_add_one' x 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/cc_haskell_import/LibB.hs: -------------------------------------------------------------------------------- 1 | module LibB (add_one_hs) where 2 | 3 | import LibA (add_one) 4 | import Data.Int (Int32) 5 | 6 | foreign export ccall add_one_hs :: Int32 -> IO Int32 7 | 8 | add_one_hs :: Int32 -> IO Int32 9 | add_one_hs x = pure $! add_one x + 0 10 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/cc_haskell_import/cbits.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int32_t c_add_one(int32_t x) { 4 | return 1 + x; 5 | } 6 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/cc_haskell_import/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "HsFFI.h" 3 | 4 | extern HsInt32 add_one_hs(HsInt32 a0); 5 | 6 | int main(int argc, char *argv[]) { 7 | hs_init(&argc, &argv); 8 | printf("Adding one to 5 through Haskell is %d\n", add_one_hs(5)); 9 | hs_exit(); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/cc_haskell_import/python_add_one.py: -------------------------------------------------------------------------------- 1 | import os 2 | import ctypes 3 | from python.runfiles import runfiles 4 | import subprocess 5 | 6 | r = runfiles.Create() 7 | 8 | path = r.Rlocation('rules_haskell_tests/tests/cc_haskell_import/hs-lib-b-wrapped.so') 9 | 10 | foreignlib = ctypes.cdll.LoadLibrary(path) 11 | foreignlib.hs_init.restype = ctypes.c_int 12 | foreignlib.hs_init.argtypes = [ctypes.c_int, ctypes.POINTER(ctypes.POINTER(ctypes.c_char))] 13 | 14 | foreignlib.hs_init(0, None) 15 | assert(str(foreignlib.add_one_hs(ctypes.c_int(1))) == "2") 16 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/cpp_macro_conflict/Main.hs: -------------------------------------------------------------------------------- 1 | import qualified Data.ByteString 2 | import BS 3 | 4 | main = putStrLn "hello" 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/cpp_macro_conflict/src/BS.hs: -------------------------------------------------------------------------------- 1 | module BS where 2 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/data/ourclibrary.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int32_t c_add_one(int32_t x) { 4 | return 1 + x; 5 | } 6 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/encoding/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | 3 | module Main (main) where 4 | 5 | import TH 6 | 7 | main :: IO () 8 | main = putStrLn $foo 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/encoding/TH.hs: -------------------------------------------------------------------------------- 1 | module TH (foo) where 2 | 3 | import Language.Haskell.TH 4 | import Language.Haskell.TH.Syntax (lift) 5 | 6 | foo :: Q Exp 7 | foo = runIO (readFile "tests/encoding/unicode.txt") >>= lift 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/encoding/unicode.txt: -------------------------------------------------------------------------------- 1 | Некоторый текст на русском. 2 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/external-haskell-repository/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import AddOne 4 | import Control.Exception (assert) 5 | 6 | main = assert (addOne 41 == 42) $ return () 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/extra-source-files/Foo.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | 3 | module Foo (foo) where 4 | 5 | import FooTH (embedFile) 6 | 7 | foo :: String 8 | foo = $(embedFile "tests/extra-source-files/file.txt") ++ "!" 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/extra-source-files/FooTH.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | 3 | module FooTH (embedFile) where 4 | 5 | import Language.Haskell.TH 6 | import Language.Haskell.TH.Syntax 7 | 8 | embedFile :: FilePath -> Q Exp 9 | embedFile path = do 10 | str <- runIO (readFile path) 11 | addDependentFile path 12 | [| str |] 13 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/extra-source-files/Main.hs: -------------------------------------------------------------------------------- 1 | import Foo (foo) 2 | 3 | main :: IO () 4 | main = putStrLn foo 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/extra-source-files/file.txt: -------------------------------------------------------------------------------- 1 | And here we go 2 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/extra-source-files/ld-options.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/rules_haskell/3322610caba2ce8f17ec010b2f76a366a06f97c4/rules_haskell_tests/tests/extra-source-files/ld-options.txt -------------------------------------------------------------------------------- /rules_haskell_tests/tests/failing-repros/isystem-issue/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE CPP #-} 2 | 3 | #include "ghcautoconf.h" 4 | 5 | import System.IO (hPutStrLn, stderr) 6 | import System.Exit (exitFailure) 7 | 8 | main :: IO () 9 | main = do 10 | #ifndef RULES_HASKELL_ISYSTEM_TEST 11 | hPutStrLn stderr "Included wrong ghcautoconf.h" 12 | exitFailure 13 | #else 14 | pure () 15 | #endif 16 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/failing-repros/isystem-issue/include/ghcautoconf.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #define RULES_HASKELL_ISYSTEM_TEST 3 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/failures/transitive-deps/LibA.hs: -------------------------------------------------------------------------------- 1 | module LibA (thingA) where 2 | 3 | thingA :: Int 4 | thingA = 5 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/failures/transitive-deps/LibB.hs: -------------------------------------------------------------------------------- 1 | module LibB (thingB) where 2 | 3 | import LibA (thingA) 4 | 5 | thingB :: Int 6 | thingB = thingA + 1 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/failures/transitive-deps/LibC.hs: -------------------------------------------------------------------------------- 1 | module LibC (thingC) where 2 | 3 | import LibB (thingB) 4 | 5 | thingC :: Int 6 | thingC = thingB * 2 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/failures/transitive-deps/LibD.hs: -------------------------------------------------------------------------------- 1 | module LibD (thingD) where 2 | 3 | import LibA (thingA) 4 | import LibB (thingB) 5 | 6 | thingD :: Int 7 | thingD = thingA + thingB 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/ghc-check/ghc-check-cabal.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: >=1.10 2 | name: ghc-check-cabal 3 | version: 0.1.0.0 4 | build-type: Simple 5 | 6 | executable ghc-check-cabal 7 | build-depends: base, ghc-check, ghc-paths 8 | default-language: Haskell2010 9 | main-is: Main.hs 10 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/ghc/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests/ghc:ghc.bzl", "ghc_help") 2 | 3 | ghc_help(name = "ghc_help") 4 | 5 | filegroup( 6 | name = "all_files", 7 | testonly = True, 8 | srcs = glob(["**"]), 9 | visibility = ["//visibility:public"], 10 | ) 11 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/ghc/ghc.bzl: -------------------------------------------------------------------------------- 1 | """Runs ghc --help""" 2 | 3 | hs_toolchain = "@rules_haskell//haskell:toolchain" 4 | 5 | def _impl(ctx): 6 | output = ctx.outputs.out 7 | ghc = ctx.toolchains[hs_toolchain].tools.ghc 8 | ctx.actions.run_shell( 9 | inputs = [ghc], 10 | outputs = [output], 11 | progress_message = "Printing ghc help message", 12 | command = "%s --help > %s" % (ghc.path, output.path), 13 | ) 14 | 15 | ghc_help = rule( 16 | implementation = _impl, 17 | outputs = {"out": "out_file"}, 18 | toolchains = [hs_toolchain], 19 | ) 20 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/ghcWithPackages_2097/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests/integration_testing:rules_haskell_integration_test.bzl", "rules_haskell_integration_test") 2 | 3 | rules_haskell_integration_test( 4 | name = "ghc_with_packages_test", 5 | srcs = ["Test.hs"], 6 | # this test is only useful with a nixpkgs based ghc toolchain 7 | target_compatible_with = ["@rules_nixpkgs_core//constraints:support_nix"], 8 | workspace_path = "test", 9 | ) 10 | 11 | filegroup( 12 | name = "all_files", 13 | testonly = True, 14 | srcs = glob(["**"]), 15 | visibility = ["//visibility:public"], 16 | ) 17 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/ghcWithPackages_2097/Test.hs: -------------------------------------------------------------------------------- 1 | {-# OPTIONS -Wall #-} 2 | 3 | import Test.Hspec (hspec, it) 4 | import IntegrationTesting 5 | 6 | main :: IO () 7 | main = hspec $ do 8 | it "bazel run ghcWithPackages" $ do 9 | bazel <- setupTestBazel 10 | assertSuccess (bazel ["run", "//:add-one"]) 11 | -- assertSuccess (bazel ["cquery", "--output", "build", "@rules_haskell_ghc_nixpkgs_haskell_toolchain//:rts"]) 12 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/ghcWithPackages_2097/test/One.hs: -------------------------------------------------------------------------------- 1 | module One () where 2 | 3 | add_one_hs :: Int -> Int 4 | add_one_hs x = x + 1 5 | 6 | foreign export ccall add_one_hs :: Int -> Int 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/ghcWithPackages_2097/test/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "HsFFI.h" 3 | 4 | extern HsInt add_one_hs(HsInt a0); 5 | 6 | int main(int argc, char *argv[]) { 7 | hs_init(&argc, &argv); 8 | printf("Adding one to 5 through Haskell is %lld\n", add_one_hs(5)); 9 | hs_exit(); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haddock-with-plugin/Lib.hs: -------------------------------------------------------------------------------- 1 | module Lib where 2 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haddock-with-plugin/Plugin.hs: -------------------------------------------------------------------------------- 1 | module Plugin where 2 | 3 | import GHC.Driver.Plugins 4 | 5 | plugin :: Plugin 6 | plugin = defaultPlugin 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haddock/Deep.hsc: -------------------------------------------------------------------------------- 1 | -- | "Deep" doc. 2 | module Deep (deep_lib) where 3 | 4 | -- | 'deep_lib' doc. 5 | 6 | #if __GLASGOW_HASKELL__ >= 700 7 | #ifndef _INTERNAL_HSC_DO_NOT_DEFINE_ME 8 | deep_lib :: Int 9 | deep_lib = 100 10 | #endif 11 | #endif 12 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haddock/LibA.hs: -------------------------------------------------------------------------------- 1 | -- | "LibA" header 2 | {-# LANGUAGE CPP #-} 3 | {-# LANGUAGE TemplateHaskell #-} 4 | 5 | #include "header.h" 6 | 7 | module LibA where 8 | 9 | import LibA.A (a) 10 | import Deep (deep_lib) 11 | 12 | -- | 'A' declaration. 13 | data A = 14 | -- | 'A' constructor. 15 | A 16 | 17 | -- | Doc for 'f' using 'a' and 'deep_lib'. 18 | f :: Int 19 | f = const $a deep_lib + MAGIC_NUMBER 20 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haddock/LibA/A.hs: -------------------------------------------------------------------------------- 1 | -- | "LibA.A" header 2 | {-# LANGUAGE TemplateHaskell #-} 3 | 4 | module LibA.A where 5 | 6 | import Language.Haskell.TH 7 | 8 | -- | 'a' doc 9 | a :: Q Exp 10 | a = [| 5 |] 11 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haddock/LibB.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | -- | "LibB" doc. 3 | 4 | module LibB where 5 | 6 | import LibA.A (a) 7 | import LibA (f) 8 | import TH (foo) 9 | 10 | -- | Doc for 'x' using 'f' and 'a' and 'Int'. 11 | x :: Int 12 | x = const f a 13 | 14 | -- | A thing generated with TH. 15 | z :: String 16 | z = $foo 17 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haddock/TH.hs: -------------------------------------------------------------------------------- 1 | module TH (foo) where 2 | 3 | import Language.Haskell.TH 4 | import Language.Haskell.TH.Syntax (lift) 5 | 6 | foo :: Q Exp 7 | foo = runIO (readFile "tests/haddock/unicode.txt") >>= lift 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haddock/header.h: -------------------------------------------------------------------------------- 1 | #define MAGIC_NUMBER 100 2 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haddock/unicode.txt: -------------------------------------------------------------------------------- 1 | Некоторый текст на русском. 2 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haddock_protobuf/HelloWorld.hs: -------------------------------------------------------------------------------- 1 | module HelloWorld (bar) where 2 | 3 | import Proto.Tests.HaddockProtobuf.HelloWorld 4 | 5 | -- | What about 'Proto.Tests.HaddockProtobuf.HelloWorld.Person'? 6 | bar :: Int 7 | bar = 5 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haddock_protobuf/hello_world.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package hello_world; // Required to generate valid code. 4 | 5 | message Person { 6 | string name = 1; 7 | int32 id = 2; 8 | string email = 3; 9 | } 10 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_binary/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_binary") 2 | 3 | haskell_cabal_binary( 4 | name = "haskell_cabal_binary", 5 | srcs = glob(["**"]), 6 | visibility = ["//tests/asterius/haskell_cabal_binary:__pkg__"], 7 | ) 8 | 9 | filegroup( 10 | name = "all_files", 11 | testonly = True, 12 | srcs = glob(["**"]), 13 | visibility = ["//visibility:public"], 14 | ) 15 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_binary/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | main :: IO () 4 | main = return () 5 | 6 | {-# ANN module "Test annotations in cabal package" #-} 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_binary/Setup.hs: -------------------------------------------------------------------------------- 1 | import Distribution.Simple 2 | main = defaultMain 3 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_binary/pkg.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: >=1.10 2 | name: pkg 3 | version: 0.1.0.0 4 | build-type: Simple 5 | 6 | executable haskell_cabal_binary 7 | build-depends: base 8 | default-language: Haskell2010 9 | main-is: Main.hs 10 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_datafiles/compare_other_cabal_functions/with_generate_paths_module/Write.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import Lib 4 | import System.Environment 5 | 6 | main = do 7 | [outputFileName] <- getArgs 8 | writeCabalPathsValues outputFileName 9 | 10 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_datafiles/compare_other_cabal_functions/with_generate_paths_module/lib.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: >=1.10 2 | name: lib 3 | version: 0.1.0.0 4 | build-type: Simple 5 | 6 | library 7 | build-depends: base, process, runfiles, filepath 8 | default-language: Haskell2010 9 | exposed-modules: Lib 10 | other-modules: Paths_lib 11 | 12 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_datafiles/compare_other_cabal_functions/without_generate_paths_module/Write.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import Lib 4 | import System.Environment 5 | 6 | main = do 7 | [outputFileName] <- getArgs 8 | writeCabalPathsValues outputFileName 9 | 10 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_datafiles/compare_other_cabal_functions/without_generate_paths_module/lib.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: >=1.10 2 | name: lib 3 | version: 0.1.0.0 4 | build-type: Simple 5 | 6 | library 7 | build-depends: base, process, runfiles, filepath 8 | default-language: Haskell2010 9 | exposed-modules: Lib 10 | other-modules: Paths_lib 11 | 12 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_datafiles/haskell_cabal_binary_with_datafiles/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import Paths_generate_paths_module_binary 4 | import Control.Exception 5 | import System.Exit 6 | 7 | readDataFile :: IO () 8 | readDataFile = do 9 | p <- getDataFileName "datafile" 10 | handle ((\e -> print p >> (exitWith $ ExitFailure 1)):: IOException -> IO ()) $ do 11 | s <- readFile p 12 | return () 13 | 14 | main = readDataFile 15 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_datafiles/haskell_cabal_binary_with_datafiles/datafile: -------------------------------------------------------------------------------- 1 | datafile_content 2 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_datafiles/haskell_cabal_binary_with_datafiles/generate-paths-module-binary.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: >=1.10 2 | name: generate-paths-module-binary 3 | version: 0.1.0.0 4 | build-type: Simple 5 | 6 | data-files: 7 | datafile 8 | 9 | executable inside 10 | build-depends: base, runfiles 11 | default-language: Haskell2010 12 | main-is: Main.hs 13 | other-modules: Paths_generate_paths_module_binary 14 | autogen-modules: Paths_generate_paths_module_binary 15 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_datafiles/haskell_cabal_library_with_datafiles/Lib.hs: -------------------------------------------------------------------------------- 1 | module Lib where 2 | import Paths_lib_pkg 3 | import Control.Exception 4 | import System.Exit 5 | import Data.List 6 | 7 | readDataFile :: IO () 8 | readDataFile = do 9 | p <- getDataFileName "datafile" 10 | handle ((\e -> print p >> (exitWith $ ExitFailure 1)):: IOException -> IO ()) $ do 11 | s <- readFile p 12 | return () 13 | 14 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_datafiles/haskell_cabal_library_with_datafiles/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import Lib 4 | 5 | main = readDataFile 6 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_datafiles/haskell_cabal_library_with_datafiles/datafile: -------------------------------------------------------------------------------- 1 | datafile_content 2 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_datafiles/haskell_cabal_library_with_datafiles/lib.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: >=1.10 2 | name: lib-pkg 3 | version: 0.1.0.0 4 | build-type: Simple 5 | 6 | data-files: 7 | datafile 8 | 9 | library 10 | build-depends: base, runfiles 11 | default-language: Haskell2010 12 | 13 | executable inside 14 | build-depends: base, sublib 15 | default-language: Haskell2010 16 | main-is: Main.hs 17 | 18 | library sublib 19 | visibility: public 20 | build-depends: base, runfiles 21 | default-language: Haskell2010 22 | exposed-modules: Lib 23 | other-modules: Paths_lib_pkg -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_datafiles/other_binary/haskell_cabal_library_datafiles_2/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import Lib 4 | 5 | main = readDataFile 6 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_doctest/Lib.hs: -------------------------------------------------------------------------------- 1 | module Lib where 2 | 3 | -- | The string foo 4 | -- 5 | -- >>> foo 6 | -- "foo" 7 | foo :: String 8 | foo = "foo" 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_doctest/Setup.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import Distribution.Extra.Doctest (defaultMainWithDoctests) 4 | 5 | main :: IO () 6 | main = defaultMainWithDoctests "doctests" 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_doctest/lib.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: >=1.10 2 | name: lib 3 | version: 0.1.0.0 4 | build-type: Custom 5 | 6 | custom-setup 7 | setup-depends: 8 | base, 9 | Cabal, 10 | cabal-doctest 11 | 12 | library 13 | build-depends: base 14 | default-language: Haskell2010 15 | exposed-modules: Lib 16 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_indirect_link/Lib.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE ForeignFunctionInterface #-} 2 | 3 | module Lib(add) where 4 | 5 | foreign import ccall "add" add :: Int -> Int -> Int 6 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_indirect_link/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE ForeignFunctionInterface #-} 2 | module Main where 3 | 4 | foreign import ccall "add" add :: Int -> Int -> Int 5 | 6 | main :: IO () 7 | main = print $ add 1 1 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_indirect_link/c-lib.c: -------------------------------------------------------------------------------- 1 | extern int add2(int a, int b); 2 | int add(int a, int b) { return add2(a, b); } 3 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_indirect_link/c-lib.h: -------------------------------------------------------------------------------- 1 | int add(int, int); 2 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_indirect_link/c-lib2.c: -------------------------------------------------------------------------------- 1 | int add2(int a, int b) { return a + b; } 2 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_indirect_link/lib.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: >=1.10 2 | name: lib 3 | version: 0.1.0.0 4 | build-type: Simple 5 | 6 | library 7 | exposed-modules: Lib 8 | build-depends: base 9 | extra-libraries: c-lib c-lib2 10 | 11 | executable main 12 | main-is: Main.hs 13 | build-depends: base 14 | extra-libraries: c-lib c-lib2 15 | 16 | executable main2 17 | main-is: main2.hs 18 | build-depends: base, lib 19 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_indirect_link/main2.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import Lib(add) 4 | 5 | main :: IO () 6 | main = print $ add 1 1 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_library/Lib.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE CPP #-} 2 | {-# LANGUAGE ForeignFunctionInterface #-} 3 | 4 | module Lib where 5 | 6 | foreign import ccall "add" add :: Int -> Int -> Int 7 | 8 | x :: Int 9 | x = add ONE ONE 10 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_library/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import Lib 4 | import SecondLib 5 | 6 | main = print (Lib.x + SecondLib.y) 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_library/SecondLib.hs: -------------------------------------------------------------------------------- 1 | module SecondLib where 2 | 3 | y :: Int 4 | y = 3 -- ^ Intentionally broken haddock comment to test @haddock = False@. 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_library/c-lib.c: -------------------------------------------------------------------------------- 1 | int add(int a, int b) { return a + b; } 2 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_library/c-lib.h: -------------------------------------------------------------------------------- 1 | int add(int, int); 2 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_library/lib.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: >=1.10 2 | name: lib 3 | version: 0.1.0.0 4 | build-type: Simple 5 | 6 | -- Example flags to test the Cabal flags attribute. 7 | flag use-base 8 | default: False 9 | manual: True 10 | description: Depend on the base library. 11 | 12 | flag expose-lib 13 | default: False 14 | manual: True 15 | description: Expose the Lib module. 16 | 17 | library 18 | if flag(use-base) 19 | build-depends: base 20 | default-language: Haskell2010 21 | if flag(expose-lib) 22 | exposed-modules: Lib 23 | else 24 | other-modules: Lib 25 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_library/second-lib.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: >=1.10 2 | name: second-lib 3 | version: 0.1.0.0 4 | build-type: Simple 5 | 6 | library 7 | build-depends: base 8 | default-language: Haskell2010 9 | exposed-modules: SecondLib 10 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_library_depends_on_haskell_library/Lib.hs: -------------------------------------------------------------------------------- 1 | module Lib where 2 | 3 | import OtherLib 4 | 5 | x :: Int 6 | x = 0 7 | 8 | z :: String 9 | z = y 10 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_library_depends_on_haskell_library/OtherLib.hs: -------------------------------------------------------------------------------- 1 | module OtherLib where 2 | 3 | y :: String 4 | y = "other lib" 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_library_depends_on_haskell_library/lib.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: >=1.10 2 | name: lib 3 | version: 0.1.0.0 4 | build-type: Simple 5 | 6 | library 7 | build-depends: base, other-lib 8 | default-language: Haskell2010 9 | exposed-modules: Lib -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_library_sublibrary_name/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | import SubLib 3 | 4 | main :: IO () 5 | main = print subLibVal 6 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_library_sublibrary_name/README.md: -------------------------------------------------------------------------------- 1 | The `package1.tar` archive contains a copy of the cabal package from the current directory. 2 | 3 | It is there so that this cabal package can be used in a custom stack snapshot this way: 4 | 5 | ``` 6 | - archive: https://github.com/tweag/rules_haskell/raw/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/tests/haskell_cabal_library_sublibrary_name/package1.tar 7 | sha256: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" 8 | ``` 9 | 10 | It is used in particular to test support of cabal sublibraries in the `stack_snapshot` rule. 11 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_library_sublibrary_name/app/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | import Lib 3 | 4 | main :: IO () 5 | main = print $ "Hello from " ++ libval 6 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_library_sublibrary_name/lib/Lib.hs: -------------------------------------------------------------------------------- 1 | module Lib where 2 | import SubLib 3 | 4 | libval = subLibVal ++ " through Lib" 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_library_sublibrary_name/sublib/SubLib.hs: -------------------------------------------------------------------------------- 1 | {-| 2 | Module : SubLib 3 | Description : Test compilation of cabal sublibrary 4 | -} 5 | module SubLib where 6 | -- |test subLibVal doc 7 | subLibVal = "SubLib" 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_package/exe/Main.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | import Lib (main) 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_package/lib.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: >=1.10 2 | name: lib 3 | version: 0.1.0.0 4 | build-type: Simple 5 | 6 | library 7 | build-depends: base 8 | default-language: Haskell2010 9 | exposed-modules: Lib 10 | hs-source-dirs: lib 11 | 12 | executable haskell_cabal_package 13 | build-depends: base, lib 14 | default-language: Haskell2010 15 | main-is: Main.hs 16 | hs-source-dirs: exe 17 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_package/lib/Lib.hs: -------------------------------------------------------------------------------- 1 | module Lib (main) where 2 | 3 | main :: IO () 4 | main = pure () 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_reproducibility/clib/BUILD.bazel: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "myclib", 3 | srcs = ["add.c"], 4 | hdrs = ["myclib.h"], 5 | includes = ["."], 6 | ) 7 | 8 | cc_library( 9 | name = "libmyclib", 10 | srcs = [":myclib"], 11 | hdrs = ["myclib.h"], 12 | includes = ["."], 13 | linkstatic = True, 14 | visibility = ["//tests/haskell_cabal_reproducibility:__subpackages__"], 15 | ) 16 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_reproducibility/clib/add.c: -------------------------------------------------------------------------------- 1 | #include "myclib.h" 2 | 3 | int add(int a, int b) { return a + b; } 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_reproducibility/clib/myclib.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_MYCLIB_H_INCLUDED 2 | #define GUARD_MYCLIB_H_INCLUDED 3 | 4 | int add(int, int); 5 | 6 | #endif // GUARD_MYCLIB_H_INCLUDED 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_reproducibility/pkg-a/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_library") 2 | 3 | haskell_cabal_library( 4 | name = "pkg-a", 5 | srcs = [ 6 | "pkg-a.cabal", 7 | "src/LibA.hsc", 8 | ], 9 | version = "0.1.0.0", 10 | visibility = ["//tests/haskell_cabal_reproducibility:__subpackages__"], 11 | deps = ["//tests/haskell_cabal_reproducibility/clib:libmyclib"], 12 | ) 13 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_reproducibility/pkg-a/pkg-a.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: 2.4 2 | name: pkg-a 3 | version: 0.1.0.0 4 | 5 | library 6 | exposed-modules: LibA 7 | build-depends: base >=4.14.1.0 8 | includes: myclib.h 9 | extra-libraries: myclib 10 | hs-source-dirs: src 11 | default-language: Haskell2010 12 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_reproducibility/pkg-a/src/LibA.hsc: -------------------------------------------------------------------------------- 1 | module LibA (double) where 2 | 3 | #include "myclib.h" 4 | 5 | foreign import ccall "myclib.h add" c_add :: Int -> Int -> Int 6 | 7 | double :: Int -> Int 8 | double a = c_add a a 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_reproducibility/pkg-b/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_binary") 2 | 3 | # TODO Define an integration test to confirm that the build of pkg-a is 4 | # deterministic, i.e. that the generated artifacts are bit-reproducible. 5 | # Pending on https://github.com/tweag/rules_haskell/pull/1645 6 | 7 | haskell_cabal_binary( 8 | name = "pkg-b", 9 | srcs = [ 10 | "exe/Main.hs", 11 | "pkg-b.cabal", 12 | ], 13 | deps = ["//tests/haskell_cabal_reproducibility/pkg-a"], 14 | ) 15 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_reproducibility/pkg-b/exe/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import LibA (double) 4 | 5 | main :: IO () 6 | main = do 7 | putStrLn $ show (double 21) 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_cabal_reproducibility/pkg-b/pkg-b.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: 2.4 2 | name: pkg-b 3 | version: 0.1.0.0 4 | 5 | executable pkg-b 6 | main-is: Main.hs 7 | build-depends: base, pkg-a 8 | hs-source-dirs: exe 9 | default-language: Haskell2010 10 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_doctest/Bar.hs: -------------------------------------------------------------------------------- 1 | module Bar (bar) where 2 | 3 | -- Regression test for https://github.com/tweag/rules_haskell/issues/936 4 | import Data.Default.Class (def) -- Stackage dependency 5 | import Data.Functor.Constant -- GHC package-db dependency 6 | 7 | import Foo (foo) 8 | import Numeric 9 | 10 | -- | 11 | -- >>> bar 12 | -- 9 13 | -- >>> showInt bar "" ++ "!" 14 | -- "9!" 15 | 16 | bar :: Int 17 | bar = getConstant $ Constant $ 4 + foo + def 18 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_doctest/Baz.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE CPP #-} 2 | 3 | module Baz (baz) where 4 | 5 | -- | 6 | -- >>> baz 7 | -- 101 8 | 9 | baz :: Int 10 | #ifndef MAGIC_DOCTEST_THING 11 | baz = 100 12 | #else 13 | baz = 101 14 | #endif 15 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_doctest/Foo.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE ForeignFunctionInterface #-} 2 | 3 | module Foo (foo) where 4 | 5 | import Foreign.C.Types (CInt(..)) 6 | 7 | foreign import ccall "c_add_one" 8 | c_add_one :: CInt -> CInt 9 | 10 | -- | 11 | -- >>> foo 12 | -- 5 13 | foo :: Int 14 | foo = fromIntegral (c_add_one 4) 15 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_doctest/Main.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | import Foo (foo) 4 | 5 | main :: IO () 6 | main = print foo 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_doctest/Quux.hsc: -------------------------------------------------------------------------------- 1 | -- | This module is in a .hsc file, this way we test that improt directories 2 | -- are passed correctly to the doctest executable. 3 | 4 | module Quux (quux) where 5 | 6 | -- | 7 | -- >>> quux 8 | -- 68 9 | 10 | quux :: Int 11 | quux = 68 12 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_doctest_ffi_1559/Bar.hs: -------------------------------------------------------------------------------- 1 | module Bar (bar) where 2 | import Foo (foo) 3 | import Numeric 4 | 5 | -- | 6 | -- >>> bar 7 | -- 9 8 | -- >>> showInt bar "" ++ "!" 9 | -- "9!" 10 | 11 | bar :: Int 12 | bar = 4 + foo 13 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_doctest_ffi_1559/Foo.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE ForeignFunctionInterface #-} 2 | 3 | module Foo (foo) where 4 | 5 | import Foreign.C.Types (CInt(..)) 6 | 7 | foreign import ccall "c_add_one" 8 | c_add_one :: CInt -> CInt 9 | 10 | -- | 11 | -- >>> foo 12 | -- 5 13 | foo :: Int 14 | foo = fromIntegral (c_add_one 4) 15 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_doctest_multiple_deps/Bar.hs: -------------------------------------------------------------------------------- 1 | module Bar (bar) where 2 | 3 | -- | 4 | -- >>> bar 5 | -- 9 6 | 7 | bar :: Int 8 | bar = 9 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_doctest_multiple_deps/Baz.hs: -------------------------------------------------------------------------------- 1 | module Baz (baz) where 2 | 3 | -- | 4 | -- >>> baz 5 | -- 101 6 | 7 | baz :: Int 8 | baz = 101 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_import/One.hs: -------------------------------------------------------------------------------- 1 | module One where 2 | 3 | add_one_hs :: Int -> Int 4 | add_one_hs x = x + 1 5 | 6 | foreign export ccall add_one_hs :: Int -> Int 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_import/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "HsFFI.h" 3 | 4 | extern HsInt add_one_hs(HsInt a0); 5 | 6 | int main(int argc, char *argv[]) { 7 | hs_init(&argc, &argv); 8 | printf("Adding one to 5 through Haskell is %ld\n", add_one_hs(5)); 9 | hs_exit(); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/attr_merging/Bin.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | import ModuleWith (part1) 4 | 5 | main :: IO () 6 | main = 7 | if "plugin" == ['a', 'c', 't', 'i', 'v', 'e'] then 8 | error "plugin loaded unexpectedly in binary" 9 | else 10 | putStrLn part1 11 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/attr_merging/ModuleWith.hs: -------------------------------------------------------------------------------- 1 | module ModuleWith (part1) where 2 | 3 | part1 :: String 4 | part1 = 5 | if "plugin" == ['a', 'c', 't', 'i', 'v', 'e'] then 6 | "hello," 7 | else 8 | error "plugin not loaded" 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/binary-custom-main/TestBin.hs: -------------------------------------------------------------------------------- 1 | module TestBin where 2 | 3 | custom_main :: IO () 4 | custom_main = putStrLn "hello, world!" 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/binary/Main.hs: -------------------------------------------------------------------------------- 1 | main :: IO () 2 | main = putStrLn "hello, world!" 3 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/binary/TestBin.hs: -------------------------------------------------------------------------------- 1 | main :: IO () 2 | main = putStrLn "hello, world!" 3 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/dep-narrowing-th/NonModulesTestLib.hs: -------------------------------------------------------------------------------- 1 | module NonModulesTestLib where 2 | 3 | import TestLibModule1 (foo1) 4 | 5 | fooNonModules :: Int 6 | fooNonModules = foo1 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/dep-narrowing-th/SimpleFoo.hs: -------------------------------------------------------------------------------- 1 | module SimpleFoo where 2 | 3 | import TestLibModule1 (foo1) 4 | import System.IO.Temp 5 | 6 | foo :: IO Int 7 | foo = withSystemTempDirectory "test" $ \_ -> return foo1 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/dep-narrowing-th/TestBinModule.hs: -------------------------------------------------------------------------------- 1 | import TestModule 2 | 3 | main :: IO () 4 | main = bar >>= print 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/dep-narrowing-th/TestLibModule.hs: -------------------------------------------------------------------------------- 1 | module TestLibModule where 2 | 3 | foo :: Int 4 | foo = 21 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/dep-narrowing-th/TestLibModule1.hs: -------------------------------------------------------------------------------- 1 | module TestLibModule1 where 2 | 3 | foo1 :: Int 4 | foo1 = 2 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/dep-narrowing-th/TestLibModule2.hs: -------------------------------------------------------------------------------- 1 | module TestLibModule2 where 2 | 3 | import SimpleFoo 4 | 5 | foo2 :: IO Int 6 | foo2 = (\x -> x - 2) <$> foo 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/dep-narrowing-th/TestModule.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | module TestModule where 3 | 4 | import NonModulesTestLib (fooNonModules) 5 | import TestLibModule (foo) 6 | import TestLibModule2 (foo2) 7 | 8 | $(return []) 9 | 10 | bar :: IO Int 11 | bar = (+ fooNonModules * foo) <$> foo2 12 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/dep-narrowing-th/TestModule2.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | module TestModule2 where 3 | 4 | import Language.Haskell.TH 5 | import SimpleFoo 6 | 7 | runIO foo >> return [] 8 | 9 | f :: IO () 10 | f = return () 11 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/dep-narrowing/DepFoo.hs: -------------------------------------------------------------------------------- 1 | module DepFoo where 2 | 3 | depFoo :: Int 4 | depFoo = 23 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/dep-narrowing/LibTop.hs: -------------------------------------------------------------------------------- 1 | module LibTop(bar, bar2, foo2) where 2 | 3 | import TestModule 4 | 5 | -- Requiring foo2 tests that the interface file for the cross-library 6 | -- dep TestLibModule2.foo2 is exposed when building this module. 7 | -- 8 | -- Similarly for depFoo, we test that the interface file of the transitive 9 | -- dependency DepFoo is available. 10 | bar2 :: Int 11 | bar2 = foo2 + depFoo 12 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/dep-narrowing/SimpleFoo.hs: -------------------------------------------------------------------------------- 1 | module SimpleFoo(foo, depFoo) where 2 | 3 | import DepFoo 4 | 5 | foo :: Int 6 | foo = depFoo 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/dep-narrowing/TestBinModule.hs: -------------------------------------------------------------------------------- 1 | import LibTop 2 | 3 | -- Requiring both bar and foo2 tests that the interface file 4 | -- for the cross-library dep TestLibModule2.foo2 is exposed 5 | -- when building this module. 6 | main :: IO () 7 | main = print (bar + foo2) 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/dep-narrowing/TestLibModule.hs: -------------------------------------------------------------------------------- 1 | module TestLibModule where 2 | 3 | foo :: Int 4 | foo = 21 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/dep-narrowing/TestLibModule2.hs: -------------------------------------------------------------------------------- 1 | module TestLibModule2(foo2, foo, depFoo) where 2 | 3 | import SimpleFoo 4 | 5 | foo2 :: Int 6 | foo2 = foo - 1 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/dep-narrowing/TestModule.hs: -------------------------------------------------------------------------------- 1 | module TestModule(bar, foo2, depFoo) where 2 | 3 | import TestLibModule (foo) 4 | import TestLibModule2 (foo2, depFoo) 5 | 6 | bar :: Int 7 | bar = 2 * foo + foo2 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/dep-narrowing/TestModule2.hs: -------------------------------------------------------------------------------- 1 | module TestModule2 where 2 | 3 | f :: IO () 4 | f = return () 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/hs-boot/Main.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | import A () 4 | import B () 5 | 6 | main :: IO () 7 | main = putStrLn "hsboot" 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/hs-boot/src/A.hs: -------------------------------------------------------------------------------- 1 | module A where 2 | 3 | import B (TB (..)) 4 | 5 | newtype TA = MkTA Int 6 | 7 | f :: TB -> TA 8 | f (MkTB x) = MkTA x 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/hs-boot/src/A.hs-boot: -------------------------------------------------------------------------------- 1 | module A where 2 | newtype TA = MkTA Int 3 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/hs-boot/src/B.hs: -------------------------------------------------------------------------------- 1 | module B where 2 | 3 | import {-# SOURCE #-} A (TA (..)) 4 | 5 | data TB = MkTB !Int 6 | 7 | g :: TA -> TB 8 | g (MkTA x) = MkTB x 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/hsc/Bar.hsc: -------------------------------------------------------------------------------- 1 | module Bar (hscFiredBar) where 2 | 3 | #ifndef _INTERNAL_HSC_DO_NOT_DEFINE_ME 4 | hscFiredBar :: String 5 | hscFiredBar = "hscFiredBar" 6 | #endif 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/hsc/Bar/Baz.hsc: -------------------------------------------------------------------------------- 1 | module Bar.Baz (hscFiredBaz) where 2 | 3 | #ifndef _INTERNAL_HSC_DO_NOT_DEFINE_ME 4 | hscFiredBaz :: String 5 | hscFiredBaz = "hscFiredBaz" 6 | #endif 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/hsc/BinHsc.hsc: -------------------------------------------------------------------------------- 1 | module BinHsc () where 2 | 3 | import Bar.Baz() 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/hsc/Flags.hsc: -------------------------------------------------------------------------------- 1 | module Flags (hscFlags) where 2 | 3 | #ifdef THIS_IS_TRUE 4 | #ifdef THIS_TOO_IS_TRUE 5 | hscFlags :: String 6 | hscFlags = "hscFlags" 7 | #endif 8 | #endif 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/hsc/Foo.hsc: -------------------------------------------------------------------------------- 1 | module Foo (hscFiredFoo) where 2 | 3 | #if __GLASGOW_HASKELL__ >= 700 4 | #ifndef _INTERNAL_HSC_DO_NOT_DEFINE_ME 5 | hscFiredFoo :: String 6 | hscFiredFoo = "hscFiredFoo" 7 | #endif 8 | #endif 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/hsc/Main.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | import BinHsc () 4 | import Foo (hscFiredFoo) 5 | import Bar (hscFiredBar) 6 | import Bar.Baz (hscFiredBaz) 7 | import Flags (hscFlags) 8 | 9 | main :: IO () 10 | main = putStrLn (hscFiredFoo ++ hscFiredBar ++ hscFiredBaz ++ hscFlags) 11 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/library-dep/TestLibModule.hs: -------------------------------------------------------------------------------- 1 | module TestLibModule where 2 | 3 | foo :: Int 4 | foo = 21 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/library-dep/TestModule.hs: -------------------------------------------------------------------------------- 1 | module TestModule where 2 | 3 | import TestLibModule (foo) 4 | 5 | bar :: Int 6 | bar = 2 * foo 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/library/Bin.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | import TestLib (testMessage) 4 | import qualified Test.Lib (testMessage) 5 | 6 | main :: IO () 7 | main = do 8 | putStrLn testMessage 9 | putStrLn Test.Lib.testMessage 10 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/library/TestLib.hs: -------------------------------------------------------------------------------- 1 | module TestLib (testMessage) where 2 | 3 | testMessage :: String 4 | testMessage = "hello, world!" 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/library/TestLib2.hs: -------------------------------------------------------------------------------- 1 | module Test.Lib (testMessage) where 2 | 3 | testMessage :: String 4 | testMessage = "hello, world! from Test.Lib" 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/library/extra_src.md: -------------------------------------------------------------------------------- 1 | Some file to stand as extra source to rehearse 2 | the `extra_srcs` attribute of `haskell_module`. 3 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/library/extra_src2.md: -------------------------------------------------------------------------------- 1 | Some other file to stand as extra source to rehearse 2 | the `extra_srcs` attribute of `haskell_library`. 3 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/multiple/BranchLeft.hs: -------------------------------------------------------------------------------- 1 | module BranchLeft where 2 | 3 | import Root 4 | 5 | branch_left :: Int 6 | branch_left = 3 * root 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/multiple/BranchRight.hs: -------------------------------------------------------------------------------- 1 | module BranchRight where 2 | 3 | import Root 4 | 5 | branch_right :: Int 6 | branch_right = 5 * root 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/multiple/Leaf.hs: -------------------------------------------------------------------------------- 1 | module Leaf where 2 | 3 | import BranchLeft 4 | import BranchRight 5 | 6 | leaf :: Int 7 | leaf = 7 * branch_left * branch_right 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/multiple/Root.hs: -------------------------------------------------------------------------------- 1 | module Root where 2 | 3 | root :: Int 4 | root = 2 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/nested/Branch/Left/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@rules_haskell//haskell/experimental:defs.bzl", "haskell_module") 2 | 3 | haskell_module( 4 | name = "Module", 5 | src = "Module.hs", 6 | src_strip_prefix = "/tests/haskell_module/nested", 7 | visibility = ["//tests/haskell_module/nested:__subpackages__"], 8 | deps = [ 9 | "//tests/haskell_module/nested/Root:Module", 10 | ], 11 | ) 12 | 13 | filegroup( 14 | name = "all_files", 15 | testonly = True, 16 | srcs = glob(["**"]), 17 | visibility = ["//visibility:public"], 18 | ) 19 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/nested/Branch/Left/Module.hs: -------------------------------------------------------------------------------- 1 | module Branch.Left.Module where 2 | 3 | import Root.Module 4 | 5 | branch_left :: Int 6 | branch_left = 3 * root 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/nested/LeafModule.hs: -------------------------------------------------------------------------------- 1 | module LeafModule where 2 | 3 | import Branch.Left.Module 4 | import Branch.Right.Module 5 | 6 | leaf :: Int 7 | leaf = 7 * branch_left * branch_right 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/nested/Root/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@rules_haskell//haskell/experimental:defs.bzl", "haskell_module") 2 | 3 | haskell_module( 4 | name = "Module", 5 | src = "Module.hs", 6 | src_strip_prefix = "/tests/haskell_module/nested", 7 | visibility = ["//tests/haskell_module/nested:__subpackages__"], 8 | ) 9 | 10 | filegroup( 11 | name = "all_files", 12 | testonly = True, 13 | srcs = glob(["**"]), 14 | visibility = ["//visibility:public"], 15 | ) 16 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/nested/Root/Module.hs: -------------------------------------------------------------------------------- 1 | module Root.Module where 2 | 3 | root :: Int 4 | root = 2 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/nested/src/Branch/Right/Module.hs: -------------------------------------------------------------------------------- 1 | module Branch.Right.Module where 2 | 3 | import Root.Module 4 | 5 | branch_right :: Int 6 | branch_right = 5 * root 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/plugin/Bin.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | import ModuleWith (part1) 4 | import ModuleWithout (part2) 5 | 6 | main :: IO () 7 | main = 8 | if "plugin" == ['a', 'c', 't', 'i', 'v', 'e'] then 9 | error "plugin loaded unexpectedly in binary" 10 | else 11 | putStrLn $ part1 ++ part2 12 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/plugin/ModuleWith.hs: -------------------------------------------------------------------------------- 1 | module ModuleWith (part1) where 2 | 3 | part1 :: String 4 | part1 = 5 | if "plugin" == ['a', 'c', 't', 'i', 'v', 'e'] then 6 | "hello," 7 | else 8 | error "plugin not loaded" 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/plugin/ModuleWithout.hs: -------------------------------------------------------------------------------- 1 | module ModuleWithout (part2) where 2 | 3 | part2 :: String 4 | part2 = 5 | if "plugin" == ['a', 'c', 't', 'i', 'v', 'e'] then 6 | error "plugin loaded unexpectedly" 7 | else 8 | " world" 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/repl/HaskellModuleReplCrossLibraryDepsTest.hs: -------------------------------------------------------------------------------- 1 | {-# OPTIONS -Wall #-} 2 | 3 | import Test.Hspec (hspec, it) 4 | import IntegrationTesting 5 | 6 | main :: IO () 7 | main = hspec $ do 8 | it "bazel run repl" $ do 9 | bazel <- setupTestBazel 10 | let p (stdout, _stderr) = lines stdout == ["42"] 11 | in 12 | outputSatisfy p (bazel ["run", "//package-b:package-b@repl", "--", "-ignore-dot-ghci", "-e", "mod1num"]) 13 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/repl/HaskellModuleReplTest.hs: -------------------------------------------------------------------------------- 1 | {-# OPTIONS -Wall #-} 2 | 3 | import Test.Hspec (hspec, it) 4 | import IntegrationTesting 5 | 6 | main :: IO () 7 | main = hspec $ do 8 | it "bazel run repl" $ do 9 | bazel <- setupTestBazel 10 | let p (stdout, _stderr) = lines stdout == ["420"] 11 | in 12 | outputSatisfy p (bazel ["run", "//:repl", "--", "-ignore-dot-ghci", "-e", "leaf"]) 13 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/repl/haskell_module_repl_cross_library_deps_test/package-a/src/PackageA/Mod1.hs: -------------------------------------------------------------------------------- 1 | module PackageA.Mod1 where 2 | 3 | mod1num :: Int 4 | mod1num = 2 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/repl/haskell_module_repl_cross_library_deps_test/package-a/src/PackageA/Mod2.hs: -------------------------------------------------------------------------------- 1 | module PackageA.Mod2 where 2 | 3 | import PackageA.Mod1 4 | 5 | mod2num :: Int 6 | mod2num = mod1num * 3 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/repl/haskell_module_repl_cross_library_deps_test/package-b/src/PackageB/Mod1.hs: -------------------------------------------------------------------------------- 1 | module PackageB.Mod1 (PackageB.Mod1.mod1num) where 2 | 3 | import qualified PackageA.Mod2 4 | 5 | mod1num :: Int 6 | mod1num = PackageA.Mod2.mod2num * 7 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/repl/haskell_module_repl_test/BranchLeft.hs: -------------------------------------------------------------------------------- 1 | module BranchLeft where 2 | 3 | import Root 4 | 5 | branch_left :: Int 6 | branch_left = 3 * root 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/repl/haskell_module_repl_test/BranchRight.hs: -------------------------------------------------------------------------------- 1 | module BranchRight where 2 | 3 | import Root 4 | 5 | branch_right :: Int 6 | branch_right = 5 * root 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/repl/haskell_module_repl_test/Leaf.hs: -------------------------------------------------------------------------------- 1 | module Leaf where 2 | 3 | import BranchLeft 4 | import BranchRight 5 | 6 | leaf :: Int 7 | leaf = 7 * branch_left * branch_right 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/repl/haskell_module_repl_test/Root.hs: -------------------------------------------------------------------------------- 1 | module Root where 2 | 3 | root :: Int 4 | root = 2 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/th/BranchLeft.hs: -------------------------------------------------------------------------------- 1 | module BranchLeft where 2 | 3 | import Root 4 | 5 | branch_left :: Int 6 | branch_left = 3 * root 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/th/BranchRight.hs: -------------------------------------------------------------------------------- 1 | module BranchRight(root, branch_right) where 2 | 3 | import Root 4 | 5 | branch_right :: Int 6 | branch_right = 5 * root 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/th/Leaf.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | module Leaf where 3 | 4 | import BranchLeft 5 | import BranchRight 6 | import Control.Monad (replicateM) 7 | import qualified Data.Vector as Vector 8 | import Language.Haskell.TH (runIO) 9 | 10 | runIO (replicateM root (return Vector.empty)) >> return [] 11 | 12 | leaf :: Int 13 | leaf = 7 * branch_left * branch_right 14 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/th/Root.hs: -------------------------------------------------------------------------------- 1 | module Root where 2 | 3 | root :: Int 4 | root = 2 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/tools/Cat.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import System.Environment (getArgs) 4 | 5 | main = do 6 | [name, src, dest] <- getArgs 7 | contents <- readFile src 8 | writeFile dest contents 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_module/tools/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE CPP #-} 2 | {-# OPTIONS_GHC -F -pgmF CAT #-} 3 | 4 | module Main where 5 | 6 | main :: IO Int 7 | main = return 0 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_proto_library/Bar.hs: -------------------------------------------------------------------------------- 1 | module Bar (bar) where 2 | 3 | import Proto.StrippedAddress 4 | import Proto.Tests.HaskellProtoLibrary.Person 5 | import Proto.Tests.HaskellProtoLibrary.Person_Fields 6 | 7 | bar :: Int 8 | bar = 5 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_proto_library/address.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package demo; // Required to generate valid code. 4 | 5 | // Always import protos with a full path relative to the WORKSPACE file. 6 | import "tests/haskell_proto_library/zip_code.proto"; 7 | 8 | message Address { 9 | string city = 1; 10 | ZipCode zip_code = 2; 11 | } 12 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_proto_library/person.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package demo; // Required to generate valid code. 4 | 5 | // Always import protos with a full path relative to the WORKSPACE file. 6 | import "tests/haskell_proto_library/address.proto"; 7 | 8 | import "google/protobuf/timestamp.proto"; 9 | 10 | message Person { 11 | string name = 1; 12 | int32 id = 2; 13 | string email = 3; 14 | Address address = 4; 15 | google.protobuf.Timestamp timestamp = 5; 16 | } 17 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_proto_library/stripped_address.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package demo; // Required to generate valid code. 4 | 5 | import "stripped_zip_code.proto"; 6 | 7 | message StrippedAddress { 8 | string city = 1; 9 | StrippedZipCode zip_code = 2; 10 | } 11 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_proto_library/stripped_zip_code.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package demo; // Required to generate valid code. 4 | 5 | message StrippedZipCode { 6 | string code = 1; 7 | } 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_proto_library/zip_code.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package demo; // Required to generate valid code. 4 | 5 | message ZipCode { 6 | string code = 1; 7 | } 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_proto_simple/Bar.hs: -------------------------------------------------------------------------------- 1 | module Bar (bar) where 2 | 3 | -- TODO this doesn't work as the Haskell packages generated for Protobuf dependencies 4 | -- are hidden by default. 5 | -- 6 | -- As a workaround, we wrap FileDescriptorSet in a custom message. 7 | -- 8 | -- import qualified Proto.Google.Protobuf.Descriptor 9 | 10 | import Proto.Tests.HaskellProtoSimple.Foo (Baz, FileDescriptorSet2) 11 | import Data.ProtoLens.Message (defMessage) 12 | 13 | bar :: Baz 14 | bar = defMessage 15 | 16 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_proto_simple/foo.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | import "google/protobuf/descriptor.proto"; 6 | 7 | message Baz {} 8 | 9 | message FileDescriptorSet2 { 10 | google.protobuf.FileDescriptorSet x = 1; 11 | } 12 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_test/Lib.hs: -------------------------------------------------------------------------------- 1 | module Lib where 2 | 3 | foo :: Int 4 | foo = 42 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_test/Test.hs: -------------------------------------------------------------------------------- 1 | module Test (test) where 2 | 3 | test :: IO () 4 | test = putStrLn "haskell_test fired" 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_toolchain_library/Bin.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | import qualified Data.Text.IO as T 4 | import qualified Data.Text.Encoding as E 5 | 6 | import Lib (message) 7 | 8 | main = T.putStrLn $ E.decodeUtf8 message 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/haskell_toolchain_library/Lib.hs: -------------------------------------------------------------------------------- 1 | module Lib (message) where 2 | 3 | import qualified Data.ByteString.Char8 as B 4 | 5 | message = B.pack "hello, world" 6 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/hidden-modules/lib-a/Bar.hs: -------------------------------------------------------------------------------- 1 | module Bar (bar) where 2 | 3 | import Foo (foo) 4 | 5 | bar :: Int 6 | bar = foo * 2 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/hidden-modules/lib-a/Foo.hs: -------------------------------------------------------------------------------- 1 | module Foo (foo) where 2 | 3 | foo :: Int 4 | foo = 15 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/hidden-modules/lib-b/Foo.hs: -------------------------------------------------------------------------------- 1 | module Foo (foo) where 2 | 3 | foo :: Int 4 | foo = 16 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/hidden-modules/lib-c/Baz.hs: -------------------------------------------------------------------------------- 1 | module Baz (bar) where 2 | 3 | import Foo (foo) 4 | import Bar (bar) 5 | 6 | baz :: Int 7 | baz = foo + bar 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/hs-boot/A.hs-boot.in: -------------------------------------------------------------------------------- 1 | module A where 2 | newtype TA = MkTA Int 3 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/hs-boot/A.hs.in: -------------------------------------------------------------------------------- 1 | module A where 2 | 3 | import B (TB (..)) 4 | 5 | newtype TA = MkTA Int 6 | 7 | f :: TB -> TA 8 | f (MkTB x) = MkTA x 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/hs-boot/MA.hs: -------------------------------------------------------------------------------- 1 | module MA where 2 | 3 | import MB (TB (..)) 4 | 5 | newtype TA = MkTA Int 6 | 7 | f :: TB -> TA 8 | f (MkTB x) = MkTA x 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/hs-boot/MA.hs-boot: -------------------------------------------------------------------------------- 1 | module MA where 2 | newtype TA = MkTA Int 3 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/hs-boot/MB.hs: -------------------------------------------------------------------------------- 1 | module MB where 2 | 3 | import {-# SOURCE #-} MA (TA (..)) 4 | 5 | data TB = MkTB !Int 6 | 7 | g :: TA -> TB 8 | g (MkTA x) = MkTB x 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/hs-boot/Main.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | import A () 4 | import B () 5 | import MA () 6 | import MB () 7 | 8 | main :: IO () 9 | main = putStrLn "hsboot" 10 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/hs-boot/srcs/B.hs: -------------------------------------------------------------------------------- 1 | module B where 2 | 3 | import {-# SOURCE #-} A (TA (..)) 4 | 5 | data TB = MkTB !Int 6 | 7 | g :: TA -> TB 8 | g (MkTA x) = MkTB x 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/hsc/Bar.hsc: -------------------------------------------------------------------------------- 1 | module Bar (hscFiredBar) where 2 | 3 | #ifndef _INTERNAL_HSC_DO_NOT_DEFINE_ME 4 | hscFiredBar :: String 5 | hscFiredBar = "hscFiredBar" 6 | #endif 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/hsc/Bar/Baz.hsc: -------------------------------------------------------------------------------- 1 | module Bar.Baz (hscFiredBaz) where 2 | 3 | #ifndef _INTERNAL_HSC_DO_NOT_DEFINE_ME 4 | hscFiredBaz :: String 5 | hscFiredBaz = "hscFiredBaz" 6 | #endif 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/hsc/BinHsc.hsc: -------------------------------------------------------------------------------- 1 | module BinHsc () where -------------------------------------------------------------------------------- /rules_haskell_tests/tests/hsc/Flags.hsc: -------------------------------------------------------------------------------- 1 | module Flags (hscFlags) where 2 | 3 | #ifdef THIS_IS_TRUE 4 | #ifdef THIS_TOO_IS_TRUE 5 | hscFlags :: String 6 | hscFlags = "hscFlags" 7 | #endif 8 | #endif 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/hsc/Foo.hsc: -------------------------------------------------------------------------------- 1 | module Foo (hscFiredFoo) where 2 | 3 | #if __GLASGOW_HASKELL__ >= 700 4 | #ifndef _INTERNAL_HSC_DO_NOT_DEFINE_ME 5 | hscFiredFoo :: String 6 | hscFiredFoo = "hscFiredFoo" 7 | #endif 8 | #endif 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/hsc/Main.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | import BinHsc () 4 | import Foo (hscFiredFoo) 5 | import Bar (hscFiredBar) 6 | import Bar.Baz (hscFiredBaz) 7 | import Flags (hscFlags) 8 | 9 | main :: IO () 10 | main = putStrLn (hscFiredFoo ++ hscFiredBar ++ hscFiredBaz ++ hscFlags) 11 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/indirect-link/cbits/impl.c: -------------------------------------------------------------------------------- 1 | static int thing; 2 | 3 | int real_get_thing(void) { 4 | return thing; 5 | } 6 | 7 | void real_set_thing(int value) { 8 | thing = value; 9 | } 10 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/indirect-link/cbits/intf.c: -------------------------------------------------------------------------------- 1 | extern int real_get_thing(void); 2 | extern void real_set_thing(int value); 3 | 4 | int get_thing(void) { 5 | return real_get_thing(); 6 | } 7 | 8 | void set_thing(int value) { 9 | real_set_thing(value); 10 | } 11 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/indirect-link/src/MyModule.hs: -------------------------------------------------------------------------------- 1 | module MyModule where 2 | 3 | foreign import ccall get_thing :: IO Int 4 | 5 | getThing :: IO Int 6 | getThing = get_thing 7 | 8 | foreign import ccall set_thing :: Int -> IO () 9 | 10 | setThing :: Int -> IO () 11 | setThing = set_thing 12 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/indirect-link/test/Main.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | import qualified MyModule 4 | 5 | main :: IO () 6 | main = do 7 | print =<< MyModule.getThing 8 | MyModule.setThing 123 9 | print =<< MyModule.getThing 10 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/integration_testing/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@rules_haskell//haskell:defs.bzl", "haskell_library") 2 | 3 | haskell_library( 4 | name = "integration_testing", 5 | srcs = ["IntegrationTesting.hs"], 6 | visibility = ["//tests:__subpackages__"], 7 | deps = [ 8 | "//tests/hackage:base", 9 | "//tests/hackage:directory", 10 | "//tests/hackage:filepath", 11 | "//tests/hackage:process", 12 | "//tests/hackage:text", 13 | "@rules_haskell//tools/runfiles", 14 | "@stackage//:hspec", 15 | "@stackage//:hspec-core", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/lhs/Lib.lhs: -------------------------------------------------------------------------------- 1 | > module Lib (lib) where 2 | 3 | > lib :: String 4 | > lib = "lhs" 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/lhs/Main.lhs: -------------------------------------------------------------------------------- 1 | > module Main (main) where 2 | 3 | > import Lib (lib) 4 | 5 | > main :: IO () 6 | > main = putStrLn lib 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/library-deps/Bin.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | import TestSubLib (messageEnd) 4 | 5 | main :: IO () 6 | main = putStrLn $ messageEnd 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/library-deps/TestLib.hs: -------------------------------------------------------------------------------- 1 | module TestLib (testMessage) where 2 | 3 | import TestSubLib (messageEnd) 4 | 5 | testMessage :: String 6 | testMessage = "hello " ++ messageEnd 7 | 8 | -- Force dynamic linking 9 | {-# ANN testMessage () #-} 10 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/library-deps/sublib/TestSubLib.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE ForeignFunctionInterface #-} 2 | module TestSubLib (messageEnd) where 3 | 4 | messageEnd :: String 5 | messageEnd = "world " ++ show (foo 10) 6 | 7 | foreign import ccall foo :: Int -> Int 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/library-deps/sublib/sublib-c.c: -------------------------------------------------------------------------------- 1 | int foo(int x) { 2 | return x * 2; 3 | } 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/library-empty/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | main = return 0 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/library-exports/Bin.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | import TestSubLib (messageEnd) 4 | import Lib.Map 5 | 6 | main :: IO () 7 | main = print $ Lib.Map.singleton 1 messageEnd 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/library-exports/TestLib.hs: -------------------------------------------------------------------------------- 1 | module TestLib (testMessage) where 2 | 3 | import TestSubLib (messageEnd) 4 | import SubLib.Map 5 | 6 | testMessage :: String 7 | testMessage = "hello " ++ messageEnd 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/library-exports/TestSubLib.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE ForeignFunctionInterface #-} 2 | module TestSubLib (messageEnd) where 3 | 4 | messageEnd :: String 5 | messageEnd = "world" 6 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/library-external-workspace/Bin.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | import TestLib (testMessage) 4 | import qualified TestLib2 (testMessage) 5 | 6 | main :: IO () 7 | main = putStrLn $ testMessage ++ TestLib2.testMessage 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/library-external-workspace/TestLib2.hs: -------------------------------------------------------------------------------- 1 | module TestLib2 (testMessage) where 2 | 3 | testMessage :: String 4 | testMessage = "world!" 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/library-external-workspace/repo/TestLib.hs: -------------------------------------------------------------------------------- 1 | module TestLib (testMessage) where 2 | 3 | testMessage :: String 4 | testMessage = "hello, world!" 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/library-external-workspace/repo/WORKSPACE: -------------------------------------------------------------------------------- 1 | workspace(name = "library_repo") 2 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/library-linkstatic-flag/Lib.hs: -------------------------------------------------------------------------------- 1 | module Lib (message) where 2 | 3 | import qualified Data.ByteString.Char8 as B 4 | 5 | message = B.pack "hello, world" 6 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/library-linkstatic-flag/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | main = putStrLn "hello world" 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/library-with-cbits/AddOne.hsc: -------------------------------------------------------------------------------- 1 | module AddOne where 2 | 3 | foreign import ccall "c_add_one" addOne :: Int -> Int 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/library-with-cbits/AddOne2.hs: -------------------------------------------------------------------------------- 1 | module AddOne2 2 | ( addOne2 3 | ) where 4 | 5 | import AddOne 6 | 7 | addOne2 = addOne 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/library-with-includes/Lib.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE CPP #-} 2 | module Lib (x) where 3 | 4 | #include "tests/library-with-includes/a.h" 5 | #include "tests/library-with-includes/b.h" 6 | 7 | x :: Int 8 | x = A + B 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/library-with-includes/b.h: -------------------------------------------------------------------------------- 1 | #define B 17 2 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/library-with-static-cc-dep/cbits/impl.c: -------------------------------------------------------------------------------- 1 | static int thing; 2 | 3 | int get_thing(void) { 4 | return thing; 5 | } 6 | 7 | void set_thing(int value) { 8 | thing = value; 9 | } 10 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/library-with-static-cc-dep/src/MyModule.hs: -------------------------------------------------------------------------------- 1 | module MyModule where 2 | 3 | foreign import ccall get_thing :: IO Int 4 | 5 | getThing :: IO Int 6 | getThing = $([| get_thing |]) 7 | 8 | foreign import ccall set_thing :: Int -> IO () 9 | 10 | setThing :: Int -> IO () 11 | setThing = $([| set_thing |]) 12 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/library-with-static-cc-dep/test/Main.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | import qualified MyModule 4 | 5 | main :: IO () 6 | main = do 7 | print =<< MyModule.getThing 8 | MyModule.setThing 123 9 | print =<< MyModule.getThing 10 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/library-with-sysdeps/Lib.hs: -------------------------------------------------------------------------------- 1 | module Lib (crc) where 2 | 3 | import Foreign.Ptr 4 | import Foreign.C.Types 5 | 6 | foreign import ccall crc32 :: CLong -> Ptr () -> CInt -> IO () 7 | 8 | crc = crc32 0 nullPtr 0 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/library-with-sysdeps/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import Lib (crc) 4 | 5 | main = crc 6 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/library-with-sysincludes/IntLib.hsc: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE CPP #-} 2 | 3 | module IntLib (crc) where 4 | 5 | import Foreign.Ptr 6 | import Foreign.C.Types 7 | 8 | #include 9 | #include "foo.h" 10 | 11 | foreign import ccall crc32 :: CLong -> Ptr () -> CInt -> IO () 12 | 13 | crc = crc32 0 nullPtr 0 14 | 15 | z = #{size struct gz_header_s} 16 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/library-with-sysincludes/Lib.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | 3 | module Lib (bar) where 4 | 5 | import TH (foo) 6 | 7 | bar :: IO () 8 | bar = $foo 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/library-with-sysincludes/TH.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | 3 | module TH (foo) where 4 | 5 | import IntLib (crc) 6 | import Language.Haskell.TH 7 | 8 | foo :: Q Exp 9 | foo = [| crc |] 10 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/multi_repl/a/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load( 2 | "@rules_haskell//haskell:defs.bzl", 3 | "haskell_library", 4 | ) 5 | 6 | package(default_visibility = ["//visibility:public"]) 7 | 8 | haskell_library( 9 | name = "a", 10 | srcs = [ 11 | "src/A/A.hs", 12 | ], 13 | src_strip_prefix = "src", 14 | deps = [ 15 | "//tests/hackage:base", 16 | ], 17 | package_name = "a", 18 | version = "0.0.0", 19 | ) 20 | 21 | filegroup( 22 | name = "all_files", 23 | testonly = True, 24 | srcs = glob(["**"]), 25 | visibility = ["//visibility:public"], 26 | ) 27 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/multi_repl/a/src/A/A.hs: -------------------------------------------------------------------------------- 1 | module A.A ( a ) where 2 | 3 | a :: () 4 | a = () 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/multi_repl/bc/src-b/BC/B.hs: -------------------------------------------------------------------------------- 1 | module BC.B ( b ) where 2 | 3 | import A.A ( a ) 4 | 5 | b :: () 6 | b = a 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/multi_repl/bc/src-c/BC/C.hs: -------------------------------------------------------------------------------- 1 | module BC.C ( c ) where 2 | 3 | import BC.B ( b ) 4 | 5 | c :: () 6 | c = b 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/multi_repl/bc/src-d/BC/D.hs: -------------------------------------------------------------------------------- 1 | module BC.D ( d ) where 2 | 3 | import BC.C ( c ) 4 | 5 | d :: () 6 | d = c 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/multi_repl/core_package_dep/Lib.hs: -------------------------------------------------------------------------------- 1 | module Lib (runGhc) where 2 | 3 | import GHC (runGhc) 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/package-id-clash-binary/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import Foo 4 | import Baz 5 | 6 | main = print $ x + y 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/package-id-clash-binary/a/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load( 2 | "@rules_haskell//haskell:defs.bzl", 3 | "haskell_library", 4 | ) 5 | 6 | haskell_library( 7 | name = "foo", 8 | srcs = ["Foo.hs"], 9 | visibility = ["//visibility:public"], 10 | deps = ["//tests/hackage:base"], 11 | ) 12 | 13 | filegroup( 14 | name = "all_files", 15 | testonly = True, 16 | srcs = glob(["**"]), 17 | visibility = ["//visibility:public"], 18 | ) 19 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/package-id-clash-binary/a/Foo.hs: -------------------------------------------------------------------------------- 1 | module Foo where 2 | 3 | x = 2 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/package-id-clash-binary/b/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load( 2 | "@rules_haskell//haskell:defs.bzl", 3 | "haskell_library", 4 | ) 5 | 6 | haskell_library( 7 | name = "foo", 8 | srcs = ["Baz.hs"], 9 | visibility = ["//visibility:public"], 10 | deps = ["//tests/hackage:base"], 11 | ) 12 | 13 | filegroup( 14 | name = "all_files", 15 | testonly = True, 16 | srcs = glob(["**"]), 17 | visibility = ["//visibility:public"], 18 | ) 19 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/package-id-clash-binary/b/Baz.hs: -------------------------------------------------------------------------------- 1 | module Baz where 2 | 3 | y = 2 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/package-id-clash/Baz.hs: -------------------------------------------------------------------------------- 1 | module Baz (baz) where 2 | 3 | import Foo (foo) 4 | import Bar (bar) 5 | 6 | baz :: Int 7 | baz = foo + bar 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/package-id-clash/Foo.hs: -------------------------------------------------------------------------------- 1 | module Foo (foo) where 2 | 3 | foo :: Int 4 | foo = 5 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/package-id-clash/sublib/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load( 2 | "@rules_haskell//haskell:defs.bzl", 3 | "haskell_library", 4 | ) 5 | 6 | package(default_testonly = 1) 7 | 8 | haskell_library( 9 | name = "sublib", 10 | srcs = ["Bar.hs"], 11 | visibility = ["//visibility:public"], 12 | deps = ["//tests/hackage:base"], 13 | ) 14 | 15 | filegroup( 16 | name = "all_files", 17 | testonly = True, 18 | srcs = glob(["**"]), 19 | visibility = ["//visibility:public"], 20 | ) 21 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/package-id-clash/sublib/Bar.hs: -------------------------------------------------------------------------------- 1 | module Bar (bar) where 2 | 3 | bar :: Int 4 | bar = 6 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/package-name/Lib.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE CPP #-} 2 | module Lib (foo, libPackageKey) where 3 | 4 | foo :: Integer 5 | foo = 42 6 | 7 | libPackageKey :: String 8 | libPackageKey = CURRENT_PACKAGE_KEY 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/package-reexport-transitive/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import Root 4 | 5 | main :: IO () 6 | main = print root 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/package-reexport-transitive/Root.hs: -------------------------------------------------------------------------------- 1 | module Root where 2 | 3 | root :: Int 4 | root = 42 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/package-reexport/Dep.hs: -------------------------------------------------------------------------------- 1 | module Dep where 2 | 3 | import qualified TransitiveDep 4 | 5 | whoAmI :: String 6 | whoAmI = "Dep" 7 | 8 | whoIsMyDep :: String 9 | whoIsMyDep = TransitiveDep.whoAmI 10 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/package-reexport/Final.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import qualified TransitiveDep 4 | import qualified Dep 5 | import Control.Exception (assert) 6 | 7 | main :: IO () 8 | main = assert (TransitiveDep.whoAmI == Dep.whoIsMyDep) (pure ()) 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/package-reexport/TransitiveDep.hs: -------------------------------------------------------------------------------- 1 | module TransitiveDep where 2 | 3 | whoAmI :: String 4 | whoAmI = "TransitiveDep" 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/plugin-install-order/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | main = putStrLn "hello world" 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/plugin-install-order/Plugin1.hs: -------------------------------------------------------------------------------- 1 | module Plugin1 (plugin) where 2 | 3 | import Control.Monad (when) 4 | import GHC.Driver.Plugins 5 | import GHC.Core 6 | import GHC.Core.Opt.Monad 7 | import GHC.Types.Literal 8 | import GHC.Unit.Module.ModGuts 9 | import GHC.Plugins 10 | import System.Process (readProcess) 11 | 12 | plugin :: Plugin 13 | plugin = defaultPlugin { installCoreToDos = install } 14 | 15 | install :: [CommandLineOption] -> [CoreToDo] -> CoreM [CoreToDo] 16 | install _args todo = do 17 | pure $ todo ++ [CoreDoPluginPass "192839898888299" pure] 18 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/recompilation/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//tests/integration_testing:rules_haskell_integration_test.bzl", "rules_haskell_integration_test") 2 | 3 | rules_haskell_integration_test( 4 | name = "recompilation_test", 5 | srcs = ["SomeTest.hs"], 6 | workspace_path = "recompilation_workspace", 7 | deps = [ 8 | "//tests/hackage:process", 9 | ], 10 | ) 11 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/recompilation/recompilation_workspace/patch1: -------------------------------------------------------------------------------- 1 | diff --git a/src/A.hs b/src/A.hs 2 | index 3da440be..a63b1242 100644 3 | --- a/src/A.hs 4 | +++ b/src/A.hs 5 | @@ -1,4 +1,4 @@ 6 | -module A (f, g, T, a) where 7 | +module A (f, g, T) where 8 | 9 | data T = T0 | T1 10 | 11 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/recompilation/recompilation_workspace/patch2: -------------------------------------------------------------------------------- 1 | diff --git a/src/A.hs b/src/A.hs 2 | index 3da440be..67790a51 100644 3 | --- a/src/A.hs 4 | +++ b/src/A.hs 5 | @@ -5,8 +5,8 @@ data T = T0 | T1 6 | a :: T 7 | a = T1 8 | 9 | -f :: a -> b -> a 10 | -f x y = x 11 | +f :: a -> b -> b 12 | +f x y = y 13 | 14 | g :: T -> T 15 | g T0 = a 16 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/recompilation/recompilation_workspace/patch3: -------------------------------------------------------------------------------- 1 | diff --git a/src/A.hs b/src/A.hs 2 | index 3da440be..cf3da883 100644 3 | --- a/src/A.hs 4 | +++ b/src/A.hs 5 | @@ -5,5 +5,6 @@ data T = T0 | T1 6 | a :: T 7 | a = T1 8 | 9 | +{-# INLINE f #-} 10 | f :: a -> b -> a 11 | f x y = x 12 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/recompilation/recompilation_workspace/patch4: -------------------------------------------------------------------------------- 1 | diff --git a/src/B.hs b/src/B.hs 2 | index 1e79718d..181a011b 100644 3 | --- a/src/B.hs 4 | +++ b/src/B.hs 5 | @@ -1,5 +1,5 @@ 6 | module B where 7 | -import qualified A (f, g, T) 8 | +import qualified A (f, g, T, a) 9 | 10 | f :: A.T -> A.T 11 | f x = A.f (A.g x) x 12 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/recompilation/recompilation_workspace/src/A.hs: -------------------------------------------------------------------------------- 1 | module A (f, g, T, a) where 2 | 3 | data T = T0 | T1 4 | 5 | a :: T 6 | a = T1 7 | 8 | f :: a -> b -> a 9 | f x y = x 10 | 11 | g :: T -> T 12 | g T0 = a 13 | g T1 = T1 14 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/recompilation/recompilation_workspace/src/B.hs: -------------------------------------------------------------------------------- 1 | module B where 2 | import qualified A (f, g, T) 3 | 4 | f :: A.T -> A.T 5 | f x = A.f (A.g x) x 6 | 7 | g :: a -> a -> a -> a 8 | g x y = A.f (A.f x) (A.f x) 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/recompilation/recompilation_workspace/src/C.hs: -------------------------------------------------------------------------------- 1 | module C where 2 | import qualified B 3 | 4 | data N = Z | S N 5 | 6 | f :: a -> a -> a 7 | f x = B.g x x 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/repl-flags/CompilerFlags.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE CPP #-} 2 | 3 | module Main where 4 | 5 | import Data.ByteString 6 | 7 | #ifdef TESTS_TOOLCHAIN_COMPILER_FLAGS 8 | main = print ("hello" :: ByteString) 9 | #endif 10 | 11 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/repl-flags/ReplFlags.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE CPP #-} 2 | module Main where 3 | 4 | import Data.ByteString 5 | 6 | -- Ensure that `compiler-flags` are correctly set 7 | #ifdef TESTS_TOOLCHAIN_COMPILER_FLAGS 8 | main = print "hello" 9 | #endif 10 | 11 | -- Ensure that `repl_ghci_args` are correctly set 12 | -- OverloadedString is passed by toolchain 13 | -- The CPP constant is unset by toolchain and set by rule, so ordering must be ensured 14 | #ifdef TESTS_TOOLCHAIN_REPL_FLAGS 15 | foo = ("world" :: ByteString) 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/repl-make-variables/data.txt: -------------------------------------------------------------------------------- 1 | 42 2 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/repl-multiple-definition/intermediate/Intermediate.hs: -------------------------------------------------------------------------------- 1 | module Intermediate where 2 | 3 | import Root 4 | 5 | intermediate :: Root -> () 6 | intermediate (Root ()) = () 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/repl-multiple-definition/src/Final.hs: -------------------------------------------------------------------------------- 1 | module Final where 2 | 3 | import Intermediate 4 | import Root 5 | 6 | final :: () 7 | final = intermediate (Root ()) 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/repl-multiple-definition/src/Root.hs: -------------------------------------------------------------------------------- 1 | module Root where 2 | 3 | data Root = Root () 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/repl-name-conflicts/PreludeShadowing.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE NoImplicitPrelude #-} 2 | {-# LANGUAGE OverloadedStrings #-} 3 | 4 | module PreludeShadowing where 5 | 6 | import Data.ByteString 7 | 8 | (>>=) :: ByteString -> ByteString -> ByteString 9 | _ >>= _ = "blah" 10 | 11 | stdin :: ByteString 12 | stdin = "stdin" 13 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/repl-targets/Bad.hs: -------------------------------------------------------------------------------- 1 | module Bad 2 | ( bad ) 3 | where 4 | 5 | bad :: Into 6 | bad = "foo" 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/repl-targets/Chs.chs: -------------------------------------------------------------------------------- 1 | module Chs 2 | ( baz ) 3 | where 4 | 5 | baz :: String 6 | baz = "baz" 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/repl-targets/Foo.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE ForeignFunctionInterface #-} 2 | 3 | module Foo (foo) where 4 | 5 | foreign import ccall "c_add_one" 6 | c_add_one :: Int -> Int 7 | 8 | foo :: Int -> Int 9 | foo = (+ 5) . c_add_one 10 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/repl-targets/HsBinReplTest.hs: -------------------------------------------------------------------------------- 1 | {-# OPTIONS -Wall #-} 2 | 3 | import Test.Hspec (hspec, it) 4 | import IntegrationTesting 5 | 6 | main :: IO () 7 | main = hspec $ do 8 | it "bazel run repl" $ do 9 | bazel <- setupTestBazel 10 | let p (stdout, _stderr) = lines stdout == ["Hello GHCi!"] 11 | in 12 | outputSatisfy p (bazel ["run", "//:hs-bin@repl", "--", "-ignore-dot-ghci", "-e", ":main"]) 13 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/repl-targets/HsLibReplTest.hs: -------------------------------------------------------------------------------- 1 | {-# OPTIONS -Wall #-} 2 | 3 | import Test.Hspec (hspec, it) 4 | import IntegrationTesting 5 | 6 | main :: IO () 7 | main = hspec $ do 8 | it "bazel run repl" $ do 9 | bazel <- setupTestBazel 10 | let p (stdout, _stderr) = lines stdout == ["\"16barbazgen\""] 11 | in 12 | outputSatisfy p (bazel ["run", "//:hs-lib@repl", "--", "-ignore-dot-ghci", "-e", "show (foo 10) ++ bar ++ baz ++ gen"]) 13 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/repl-targets/Hsc.hsc: -------------------------------------------------------------------------------- 1 | module Hsc 2 | ( bar ) 3 | where 4 | 5 | #ifndef _INTERNAL_HSC_DO_NOT_DEFINE_ME 6 | bar :: String 7 | bar = "bar" 8 | #endif 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/repl-targets/Quux.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | import QuuxLib (message) 4 | 5 | main :: IO () 6 | main = putStrLn message 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/repl-targets/QuuxLib.hs: -------------------------------------------------------------------------------- 1 | module QuuxLib (message) where 2 | 3 | message :: String 4 | message = "Hello GHCi!" 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/repl-targets/hs_bin_repl_test/Quux.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | import QuuxLib (message) 4 | 5 | main :: IO () 6 | main = putStrLn message 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/repl-targets/hs_bin_repl_test/QuuxLib.hs: -------------------------------------------------------------------------------- 1 | module QuuxLib (message) where 2 | 3 | message :: String 4 | message = "Hello GHCi!" 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/repl-targets/hs_lib_repl_test/Chs.chs: -------------------------------------------------------------------------------- 1 | module Chs 2 | ( baz ) 3 | where 4 | 5 | baz :: String 6 | baz = "baz" 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/repl-targets/hs_lib_repl_test/Foo.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE ForeignFunctionInterface #-} 2 | 3 | module Foo (foo) where 4 | 5 | foreign import ccall "c_add_one" 6 | c_add_one :: Int -> Int 7 | 8 | foo :: Int -> Int 9 | foo = (+ 5) . c_add_one 10 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/repl-targets/hs_lib_repl_test/Hsc.hs: -------------------------------------------------------------------------------- 1 | module Hsc 2 | ( bar ) 3 | where 4 | 5 | #ifndef _INTERNAL_HSC_DO_NOT_DEFINE_ME 6 | bar :: String 7 | bar = "bar" 8 | #endif 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/repl-targets/hs_lib_repl_test/Hsc.hsc: -------------------------------------------------------------------------------- 1 | module Hsc 2 | ( bar ) 3 | where 4 | 5 | #ifndef _INTERNAL_HSC_DO_NOT_DEFINE_ME 6 | bar :: String 7 | bar = "bar" 8 | #endif 9 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/repl-targets/hs_lib_repl_test/maybe_cc_shared_library.bzl: -------------------------------------------------------------------------------- 1 | load("@bazel_features//:features.bzl", "bazel_features") 2 | 3 | def maybe_cc_shared_library(name, **kwargs): 4 | if _has_cc_shared_library(): 5 | shared_name = "%s_shared" % name 6 | native.cc_shared_library( 7 | name = shared_name, 8 | deps = [name], 9 | **kwargs, 10 | ) 11 | return shared_name 12 | return name 13 | 14 | 15 | 16 | def _has_cc_shared_library(): 17 | return bazel_features.globals.CcSharedLibraryInfo != None 18 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/repl-targets/hs_lib_repl_test/ourclibrary.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int32_t c_add_one(int32_t x) { 4 | return 1 + x; 5 | } 6 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/repl-targets/src/Bar.hs: -------------------------------------------------------------------------------- 1 | module Bar (bar) where 2 | 3 | bar :: Int 4 | bar = 4 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/repl-targets/src/Baz.hsc: -------------------------------------------------------------------------------- 1 | module Baz (baz) where 2 | 3 | baz :: Int 4 | baz = 8 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/rule_test_exe.bzl: -------------------------------------------------------------------------------- 1 | load("@bazel_tools//tools/build_rules:test_rules.bzl", "rule_test") 2 | 3 | def rule_test_exe(generates, **kwargs): 4 | """ 5 | Like 'rule_test' but appends ".exe" to the elements of 6 | "generates". 7 | """ 8 | 9 | new_generates = select({ 10 | "@bazel_tools//src/conditions:windows": [e + ".exe" for e in generates], 11 | "//conditions:default": generates, 12 | }) 13 | 14 | rule_test(generates = new_generates, **kwargs) 15 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/runfiles/bar.txt: -------------------------------------------------------------------------------- 1 | bar 2 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/runfiles/foo.txt: -------------------------------------------------------------------------------- 1 | foo 2 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/sandwich/Lib.hs: -------------------------------------------------------------------------------- 1 | module Lib where 2 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/sandwich/Main.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | main :: IO () 4 | main = return () 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/sandwich/test.c: -------------------------------------------------------------------------------- 1 | int a = 0; 2 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/scripts/exec.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | exec "$1" 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/stack-snapshot-deps/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | main = putStrLn "hello world" 4 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/stack-snapshot-deps/hs_override_stack_test/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load( 2 | "@rules_haskell//haskell:defs.bzl", 3 | "haskell_test", 4 | ) 5 | 6 | haskell_test( 7 | name = "hs-bin", 8 | srcs = ["Quux.hs"], 9 | visibility = ["//visibility:public"], 10 | deps = ["@stackage//:base"], 11 | ) 12 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/stack-snapshot-deps/hs_override_stack_test/Quux.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | main :: IO () 4 | main = putStrLn "Hello GHCi!" 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/stack-snapshot-deps/hs_override_stack_test/stack: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo 2.3.1 3 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/stackage_sublibrary/BUILD: -------------------------------------------------------------------------------- 1 | load( 2 | "@rules_haskell//haskell:defs.bzl", 3 | "haskell_test", 4 | "haskell_toolchain_library", 5 | ) 6 | 7 | package(default_testonly = 1) 8 | 9 | haskell_toolchain_library(name = "base") 10 | 11 | # We directly depend on the "sublib" sublibrary of the "package1" package. 12 | haskell_test( 13 | name = "stackage_sublibrary", 14 | srcs = ["Main.hs"], 15 | deps = [ 16 | ":base", 17 | "@stackage-pinning-test//package1", 18 | "@stackage-pinning-test//package1:sublib", 19 | ], 20 | ) 21 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/stackage_sublibrary/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | import SubLib 3 | 4 | main :: IO () 5 | main = print subLibVal 6 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/stackage_zlib_runpath/cabal-binary/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | main :: IO () 4 | main = pure () 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/stackage_zlib_runpath/cabal-binary/cabal-binary.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: >=1.10 2 | name: cabal-binary 3 | version: 0.1.0.0 4 | build-type: Simple 5 | 6 | executable cabal-binary 7 | build-depends: 8 | base, 9 | zlib 10 | default-language: Haskell2010 11 | main-is: Main.hs 12 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/target-name/Lib.hs: -------------------------------------------------------------------------------- 1 | module Lib where 2 | 3 | value :: Int 4 | value = 42 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/target-name/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import Lib (value) 4 | 5 | main :: IO () 6 | main = print value 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/template-haskell-with-cbits/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | 3 | module Main where 4 | 5 | import Control.Monad (unless) 6 | import System.Exit (exitFailure) 7 | import System.IO (hPutStrLn, stderr) 8 | import TH (value) 9 | 10 | main :: IO () 11 | main = 12 | unless ($(value) == 42) $ do 13 | hPutStrLn stderr "Expected 42" 14 | exitFailure 15 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/template-haskell-with-cbits/TH.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | 3 | module TH where 4 | 5 | import Language.Haskell.TH 6 | 7 | foreign import ccall "c_add_one" c_add_one' :: Int -> Int 8 | 9 | value :: Q Exp 10 | value = [| c_add_one' 41 |] 11 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/textual-hdrs/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load( 2 | "@rules_haskell//haskell:defs.bzl", 3 | "haskell_test", 4 | ) 5 | 6 | package(default_testonly = 1) 7 | 8 | haskell_test( 9 | name = "textual-hdrs", 10 | srcs = [ 11 | "Main.hs", 12 | "include/main_definition.h", 13 | ], 14 | ghcopts = ["-Itests/textual-hdrs/include"], 15 | visibility = ["//visibility:public"], 16 | deps = ["//tests/hackage:base"], 17 | ) 18 | 19 | filegroup( 20 | name = "all_files", 21 | testonly = True, 22 | srcs = glob(["**"]), 23 | visibility = ["//visibility:public"], 24 | ) 25 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/textual-hdrs/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE CPP #-} 2 | 3 | module Main (main) where 4 | 5 | #include "main_definition.h" 6 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/textual-hdrs/include/main_definition.h: -------------------------------------------------------------------------------- 1 | main :: IO () 2 | main = putStrLn "extras-included-during-comp" 3 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/two-libs/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import Two (two) 4 | 5 | main :: IO () 6 | main = putStrLn ("Two: " ++ show two) 7 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/two-libs/One.hs: -------------------------------------------------------------------------------- 1 | module One (one) where 2 | 3 | one :: Int 4 | one = 1 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/two-libs/Two.hs: -------------------------------------------------------------------------------- 1 | module Two (two) where 2 | 3 | import One (one) 4 | 5 | two :: Int 6 | two = 7 | if True then 8 | one + one 9 | else 10 | if True then 11 | 1 12 | else 13 | 2 14 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/two-same-file/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | main :: IO () 4 | main = putStrLn "Yiha" 5 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/version-macros/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import qualified HscLib 4 | import qualified HsLib 5 | 6 | main :: IO () 7 | main = do 8 | HscLib.check 9 | HsLib.check 10 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/version-macros/MainC2hs.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import qualified C2hsLib 4 | 5 | main :: IO () 6 | main = do 7 | C2hsLib.check 8 | -------------------------------------------------------------------------------- /rules_haskell_tests/tests/version-macros/VersionedLib.hs: -------------------------------------------------------------------------------- 1 | module VersionedLib where 2 | -------------------------------------------------------------------------------- /stackage_snapshot.json: -------------------------------------------------------------------------------- 1 | stackage_snapshot_9.4.8.json -------------------------------------------------------------------------------- /stackage_snapshot.yaml: -------------------------------------------------------------------------------- 1 | stackage_snapshot_9.4.8.yaml -------------------------------------------------------------------------------- /stackage_snapshot_9.6.5.yaml: -------------------------------------------------------------------------------- 1 | resolver: lts-22.27 2 | 3 | packages: 4 | - proto-lens-protoc-0.8.0.1 5 | - ghc-source-gen-0.4.4.1 6 | -------------------------------------------------------------------------------- /tests/haskell_tests/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load(":bazel_platforms_tests.bzl", "bazel_platforms_test_suite") 2 | 3 | bazel_platforms_test_suite() 4 | -------------------------------------------------------------------------------- /tests/package_configuration/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@rules_python//python:defs.bzl", "py_test") 2 | 3 | py_test( 4 | name = "package_configuration_test", 5 | srcs = ["package_configuration_test.py"], 6 | deps = ["@rules_haskell//haskell:package_configuration"], 7 | ) 8 | 9 | filegroup( 10 | name = "all_files", 11 | testonly = True, 12 | srcs = glob(["**"]), 13 | visibility = ["//visibility:public"], 14 | ) 15 | -------------------------------------------------------------------------------- /tests/shellcheck/shellcheck.bzl: -------------------------------------------------------------------------------- 1 | load("//tests:inline_tests.bzl", "sh_inline_test") 2 | 3 | def shellcheck(name, args, data, sh_flavor = "sh", visibility = None): 4 | fst_args = ["--color=always"] 5 | if sh_flavor != None: 6 | fst_args += ["--shell", sh_flavor] 7 | sh_inline_test( 8 | name = name, 9 | visibility = visibility, 10 | size = "small", 11 | args = fst_args + args, 12 | data = data, 13 | script = """\ 14 | shellcheck "$@" 15 | """, 16 | tags = ["requires_shellcheck"], 17 | ) 18 | -------------------------------------------------------------------------------- /tools/BUILD.bazel: -------------------------------------------------------------------------------- 1 | filegroup( 2 | name = "all_files", 3 | testonly = True, 4 | srcs = glob(["**"]) + [ 5 | "//tools/ghc-paths:all_files", 6 | "//tools/runfiles:all_files", 7 | "//tools/worker:all_files", 8 | ], 9 | visibility = ["//visibility:public"], 10 | ) 11 | -------------------------------------------------------------------------------- /tools/README.md: -------------------------------------------------------------------------------- 1 | Note: `py_library`s cannot be put into this folder, lest they produce 2 | a namespace collision with `@bazel_tools/tools`. 3 | See https://github.com/bazelbuild/bazel/issues/7051 4 | -------------------------------------------------------------------------------- /tools/coverage-reports/.gitignore: -------------------------------------------------------------------------------- 1 | # Stack uses this directory as scratch space. 2 | /.stack-work/ 3 | # Stack generates the Cabal file from `package.yaml` through hpack. 4 | /*.cabal 5 | -------------------------------------------------------------------------------- /tools/coverage-reports/Setup.hs: -------------------------------------------------------------------------------- 1 | import qualified Distribution.Simple 2 | 3 | main :: IO () 4 | main = Distribution.Simple.defaultMain 5 | -------------------------------------------------------------------------------- /tools/coverage-reports/stack.yaml: -------------------------------------------------------------------------------- 1 | resolver: lts-13.20 2 | packages: 3 | - . 4 | extra-deps: 5 | - hxt-xpath-9.1.2.2@sha256:9cd590ae93a04573db8f90fa4094625ebd97dded45da7667c577ce6b38a42900 -------------------------------------------------------------------------------- /tools/ghc-paths/ghc-paths.cabal: -------------------------------------------------------------------------------- 1 | -- Dummy Cabal file. It is not used to build ghc-paths, but required for 2 | -- dependency resolution in stack_snapshot. 3 | name: ghc-paths 4 | version: 0.1.0.11 5 | cabal-version: >= 1.6 6 | library 7 | build-depends: base 8 | exposed-modules: GHC.Paths 9 | -------------------------------------------------------------------------------- /tools/runfiles/bin-data.txt: -------------------------------------------------------------------------------- 1 | bar 2 | -------------------------------------------------------------------------------- /tools/runfiles/bin/Bin.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | import qualified Bazel.Runfiles as Runfiles 4 | import Control.Monad (when) 5 | import System.FilePath (()) 6 | 7 | main :: IO () 8 | main = do 9 | r <- Runfiles.create 10 | bar <- readFile (Runfiles.rlocation r "rules_haskell/tools/runfiles/bin-data.txt") 11 | when (lines bar /= ["bar"]) -- ignore trailing newline 12 | $ error $ "Incorrect contents: got: " ++ show bar 13 | -------------------------------------------------------------------------------- /tools/runfiles/stack.yaml: -------------------------------------------------------------------------------- 1 | resolver: lts-20.3 2 | packages: 3 | - . 4 | -------------------------------------------------------------------------------- /tools/runfiles/test-data.txt: -------------------------------------------------------------------------------- 1 | foo 2 | -------------------------------------------------------------------------------- /tools/worker/Setup.hs: -------------------------------------------------------------------------------- 1 | import Distribution.Simple 2 | main = defaultMain 3 | -------------------------------------------------------------------------------- /tutorial/.bazelrc: -------------------------------------------------------------------------------- 1 | ../.bazelrc -------------------------------------------------------------------------------- /tutorial/.bazelrc.bzlmod: -------------------------------------------------------------------------------- 1 | common:bzlmod --enable_bzlmod 2 | common:common --registry=file://%workspace%/../registry --registry=https://bcr.bazel.build 3 | -------------------------------------------------------------------------------- /tutorial/.bazelrc.common: -------------------------------------------------------------------------------- 1 | ../.bazelrc.common -------------------------------------------------------------------------------- /tutorial/.bazelrc.local: -------------------------------------------------------------------------------- 1 | ../.bazelrc.local -------------------------------------------------------------------------------- /tutorial/.gitignore: -------------------------------------------------------------------------------- 1 | /bazel-* 2 | -------------------------------------------------------------------------------- /tutorial/BUILD.bazel: -------------------------------------------------------------------------------- 1 | filegroup( 2 | name = "all_files", 3 | testonly = True, 4 | srcs = [ 5 | "BUILD.bazel", 6 | "WORKSPACE", 7 | "//lib:all_files", 8 | "//main:all_files", 9 | "//tools/build_rules:all_files", 10 | ], 11 | visibility = ["//visibility:public"], 12 | ) 13 | -------------------------------------------------------------------------------- /tutorial/MODULE.bazel: -------------------------------------------------------------------------------- 1 | bazel_dep( 2 | name = "platforms", 3 | version = "0.0.11", 4 | ) 5 | 6 | # rules_haskell_nix must come before rules_haskell so that nix 7 | # toolchains are considered first 8 | bazel_dep( 9 | name = "rules_haskell_nix", 10 | version = "1.0", 11 | ) 12 | bazel_dep( 13 | name = "rules_haskell", 14 | version = "1.0", 15 | ) 16 | bazel_dep( 17 | name = "rules_nixpkgs_core", 18 | version = "0.13.0", 19 | ) 20 | -------------------------------------------------------------------------------- /tutorial/lib/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load( 2 | "@rules_haskell//haskell:defs.bzl", 3 | "haskell_library", 4 | ) 5 | 6 | haskell_library( 7 | name = "booleans", 8 | srcs = ["Bool.hs"], 9 | visibility = ["//main:__pkg__"], 10 | ) 11 | 12 | filegroup( 13 | name = "all_files", 14 | testonly = True, 15 | srcs = glob(["**"]), 16 | visibility = ["//visibility:public"], 17 | ) 18 | -------------------------------------------------------------------------------- /tutorial/lib/Bool.hs: -------------------------------------------------------------------------------- 1 | -- base is not available when no dependencies, so we have to define everything 2 | -- from scratch. 3 | {-# LANGUAGE NoImplicitPrelude #-} 4 | 5 | module Bool where 6 | 7 | data Bool = False | True 8 | 9 | not :: Bool -> Bool 10 | not False = True 11 | not True = False 12 | 13 | and :: Bool -> Bool -> Bool 14 | and True True = True 15 | and _ _ = False 16 | 17 | or :: Bool -> Bool -> Bool 18 | or False False = False 19 | or _ _ = True 20 | -------------------------------------------------------------------------------- /tutorial/main/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load( 2 | "@rules_haskell//haskell:defs.bzl", 3 | "haskell_test", 4 | "haskell_toolchain_library", 5 | ) 6 | 7 | haskell_toolchain_library(name = "base") 8 | 9 | haskell_test( 10 | name = "demorgan", 11 | srcs = ["Main.hs"], 12 | ghcopts = ["-threaded"], 13 | deps = [ 14 | ":base", 15 | "//lib:booleans", 16 | ], 17 | ) 18 | 19 | filegroup( 20 | name = "all_files", 21 | testonly = True, 22 | srcs = glob(["**"]), 23 | visibility = ["//visibility:public"], 24 | ) 25 | -------------------------------------------------------------------------------- /tutorial/main/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE StandaloneDeriving #-} 2 | 3 | module Main where 4 | 5 | import Bool 6 | import qualified Prelude 7 | import Prelude ((++), (==), ($)) 8 | 9 | deriving instance Prelude.Eq Bool 10 | 11 | bools :: [Bool] 12 | bools = [False, True] 13 | 14 | main = 15 | Prelude.print $ Prelude.and $ 16 | [ not (x `and` y) == not x `or` not y | x <- bools, y <- bools] 17 | -------------------------------------------------------------------------------- /tutorial/tools/build_rules/BUILD.bazel: -------------------------------------------------------------------------------- 1 | filegroup( 2 | name = "all_files", 3 | testonly = True, 4 | srcs = glob(["**"]), 5 | visibility = ["//visibility:public"], 6 | ) 7 | -------------------------------------------------------------------------------- /tutorial/tools/build_rules/prelude_bazel: -------------------------------------------------------------------------------- 1 | load("@rules_haskell//haskell:defs.bzl", 2 | "haskell_binary", 3 | "haskell_toolchain_library", 4 | "haskell_library", 5 | ) 6 | --------------------------------------------------------------------------------