about summary refs log tree commit diff
path: root/third_party/bazel/rules_haskell/tests/repl-targets
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/bazel/rules_haskell/tests/repl-targets')
-rw-r--r--third_party/bazel/rules_haskell/tests/repl-targets/BUILD.bazel81
-rw-r--r--third_party/bazel/rules_haskell/tests/repl-targets/Bad.hs6
-rw-r--r--third_party/bazel/rules_haskell/tests/repl-targets/Chs.chs6
-rw-r--r--third_party/bazel/rules_haskell/tests/repl-targets/Foo.hs9
-rw-r--r--third_party/bazel/rules_haskell/tests/repl-targets/Hsc.hsc8
-rw-r--r--third_party/bazel/rules_haskell/tests/repl-targets/Quux.hs6
-rw-r--r--third_party/bazel/rules_haskell/tests/repl-targets/QuuxLib.hs4
-rw-r--r--third_party/bazel/rules_haskell/tests/repl-targets/src/Bar.hs4
-rw-r--r--third_party/bazel/rules_haskell/tests/repl-targets/src/Baz.hsc4
9 files changed, 128 insertions, 0 deletions
diff --git a/third_party/bazel/rules_haskell/tests/repl-targets/BUILD.bazel b/third_party/bazel/rules_haskell/tests/repl-targets/BUILD.bazel
new file mode 100644
index 000000000000..2fd78bfd6621
--- /dev/null
+++ b/third_party/bazel/rules_haskell/tests/repl-targets/BUILD.bazel
@@ -0,0 +1,81 @@
+load("@io_tweag_rules_haskell//haskell:c2hs.bzl", "c2hs_library")
+load(
+    "@io_tweag_rules_haskell//haskell:haskell.bzl",
+    "haskell_library",
+    "haskell_test",
+)
+
+package(default_testonly = 1)
+
+genrule(
+    name = "codegen",
+    outs = [
+        "Gen.hs",
+    ],
+    cmd = """
+  echo "module Gen (gen) where" >> $(location :Gen.hs)
+  echo "gen :: String" >> $(location :Gen.hs)
+  echo "gen = \\"gen\\"" >> $(location :Gen.hs)
+""",
+)
+
+c2hs_library(
+    name = "chs",
+    srcs = ["Chs.chs"],
+    tags = ["requires_c2hs"],
+)
+
+haskell_library(
+    name = "hs-lib",
+    srcs = [
+        "Foo.hs",
+        "Hsc.hsc",
+        ":chs",
+        ":codegen",
+    ],
+    tags = [
+        "requires_hackage",
+        "requires_zlib",
+    ],
+    visibility = ["//visibility:public"],
+    deps = [
+        "//tests/data:ourclibrary",
+        "//tests/hackage:array",
+        "//tests/hackage:base",
+        "@zlib",
+    ],
+)
+
+haskell_library(
+    name = "hs-lib-bad",
+    srcs = [
+        "Bad.hs",
+    ],
+    tags = [
+        "manual",
+        "requires_zlib",
+    ],
+    visibility = ["//visibility:public"],
+    deps = [
+        "//tests/data:ourclibrary",
+        "//tests/hackage:base",
+        "@hackage//:array",
+        "@zlib",
+    ],
+)
+
+haskell_library(
+    name = "QuuxLib",
+    srcs = ["QuuxLib.hs"],
+    deps = ["//tests/hackage:base"],
+)
+
+haskell_test(
+    name = "hs-bin",
+    srcs = ["Quux.hs"],
+    visibility = ["//visibility:public"],
+    deps = [
+        ":QuuxLib",
+        "//tests/hackage:base",
+    ],
+)
diff --git a/third_party/bazel/rules_haskell/tests/repl-targets/Bad.hs b/third_party/bazel/rules_haskell/tests/repl-targets/Bad.hs
new file mode 100644
index 000000000000..2889be2ba757
--- /dev/null
+++ b/third_party/bazel/rules_haskell/tests/repl-targets/Bad.hs
@@ -0,0 +1,6 @@
+module Bad
+  ( bad )
+where
+
+bad :: Into
+bad = "foo"
diff --git a/third_party/bazel/rules_haskell/tests/repl-targets/Chs.chs b/third_party/bazel/rules_haskell/tests/repl-targets/Chs.chs
new file mode 100644
index 000000000000..c66bae7d60fd
--- /dev/null
+++ b/third_party/bazel/rules_haskell/tests/repl-targets/Chs.chs
@@ -0,0 +1,6 @@
+module Chs
+  ( baz )
+where
+
+baz :: String
+baz = "baz"
diff --git a/third_party/bazel/rules_haskell/tests/repl-targets/Foo.hs b/third_party/bazel/rules_haskell/tests/repl-targets/Foo.hs
new file mode 100644
index 000000000000..5e5138418d5d
--- /dev/null
+++ b/third_party/bazel/rules_haskell/tests/repl-targets/Foo.hs
@@ -0,0 +1,9 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
+
+module Foo (foo) where
+
+foreign import ccall "c_add_one"
+  c_add_one :: Int -> Int
+
+foo :: Int -> Int
+foo = (+ 5) . c_add_one
diff --git a/third_party/bazel/rules_haskell/tests/repl-targets/Hsc.hsc b/third_party/bazel/rules_haskell/tests/repl-targets/Hsc.hsc
new file mode 100644
index 000000000000..d4e3d6605c00
--- /dev/null
+++ b/third_party/bazel/rules_haskell/tests/repl-targets/Hsc.hsc
@@ -0,0 +1,8 @@
+module Hsc
+  ( bar )
+where
+
+#ifndef _INTERNAL_HSC_DO_NOT_DEFINE_ME
+bar :: String
+bar = "bar"
+#endif
diff --git a/third_party/bazel/rules_haskell/tests/repl-targets/Quux.hs b/third_party/bazel/rules_haskell/tests/repl-targets/Quux.hs
new file mode 100644
index 000000000000..2e67d221fb22
--- /dev/null
+++ b/third_party/bazel/rules_haskell/tests/repl-targets/Quux.hs
@@ -0,0 +1,6 @@
+module Main (main) where
+
+import QuuxLib (message)
+
+main :: IO ()
+main = putStrLn message
diff --git a/third_party/bazel/rules_haskell/tests/repl-targets/QuuxLib.hs b/third_party/bazel/rules_haskell/tests/repl-targets/QuuxLib.hs
new file mode 100644
index 000000000000..d321de2adda3
--- /dev/null
+++ b/third_party/bazel/rules_haskell/tests/repl-targets/QuuxLib.hs
@@ -0,0 +1,4 @@
+module QuuxLib (message) where
+
+message :: String
+message = "Hello GHCi!"
diff --git a/third_party/bazel/rules_haskell/tests/repl-targets/src/Bar.hs b/third_party/bazel/rules_haskell/tests/repl-targets/src/Bar.hs
new file mode 100644
index 000000000000..18fe359e0a2a
--- /dev/null
+++ b/third_party/bazel/rules_haskell/tests/repl-targets/src/Bar.hs
@@ -0,0 +1,4 @@
+module Bar (bar) where
+
+bar :: Int
+bar = 4
diff --git a/third_party/bazel/rules_haskell/tests/repl-targets/src/Baz.hsc b/third_party/bazel/rules_haskell/tests/repl-targets/src/Baz.hsc
new file mode 100644
index 000000000000..984ec4ff0ad9
--- /dev/null
+++ b/third_party/bazel/rules_haskell/tests/repl-targets/src/Baz.hsc
@@ -0,0 +1,4 @@
+module Baz (baz) where
+
+baz :: Int
+baz = 8