feat(third_party/bazel): Check in rules_haskell from Tweag

This commit is contained in:
Vincent Ambo 2019-07-04 11:18:12 +01:00
parent 2eb1dc26e4
commit f723b8b878
479 changed files with 51484 additions and 0 deletions

View file

@ -0,0 +1,73 @@
load(
"@io_tweag_rules_haskell//haskell:haskell.bzl",
"haskell_doctest",
"haskell_library",
"haskell_test",
)
package(default_testonly = 1)
haskell_library(
name = "lib-a",
srcs = ["Foo.hs"],
tags = ["requires_zlib"],
deps = [
"//tests/data:ourclibrary",
"//tests/hackage:base",
"@zlib.dev//:zlib",
],
)
haskell_library(
name = "lib-b",
srcs = [
"Bar.hs",
"Baz.hs",
"Quux.hsc",
],
tags = ["requires_zlib"],
deps = [
":lib-a",
"//tests/hackage:base",
],
)
haskell_doctest(
name = "doctest-lib-all-fail",
tags = ["manual"], # must FAIL
visibility = ["//visibility:public"],
deps = [":lib-b"],
)
haskell_doctest(
name = "doctest-lib-all-success",
doctest_flags = ["-DMAGIC_DOCTEST_THING"],
tags = ["requires_doctest"],
visibility = ["//visibility:public"],
deps = [":lib-b"],
)
haskell_doctest(
name = "doctest-lib",
modules = ["Bar"], # exclude Baz and succeed
tags = ["requires_doctest"],
visibility = ["//visibility:public"],
deps = [":lib-b"],
)
haskell_test(
name = "bin",
srcs = ["Main.hs"],
tags = ["requires_zlib"],
deps = [
":lib-a",
"//tests/hackage:base",
],
)
haskell_doctest(
name = "doctest-bin",
tags = ["requires_doctest"],
visibility = ["//visibility:public"],
deps = [":bin"],
)

View file

@ -0,0 +1,13 @@
module Bar (bar) where
import Foo (foo)
import Numeric
-- |
-- >>> bar
-- 9
-- >>> showInt bar "" ++ "!"
-- "9!"
bar :: Int
bar = 4 + foo

View file

@ -0,0 +1,14 @@
{-# LANGUAGE CPP #-}
module Baz (baz) where
-- |
-- >>> baz
-- 101
baz :: Int
#ifndef MAGIC_DOCTEST_THING
baz = 100
#else
baz = 101
#endif

View file

@ -0,0 +1,14 @@
{-# LANGUAGE ForeignFunctionInterface #-}
module Foo (foo) where
import Foreign.C.Types (CInt(..))
foreign import ccall "c_add_one"
c_add_one :: CInt -> CInt
-- |
-- >>> foo
-- 5
foo :: Int
foo = fromIntegral (c_add_one 4)

View file

@ -0,0 +1,6 @@
module Main (main) where
import Foo (foo)
main :: IO ()
main = print foo

View file

@ -0,0 +1,11 @@
-- | This module is in a .hsc file, this way we test that improt directories
-- are passed correctly to the doctest executable.
module Quux (quux) where
-- |
-- >>> quux
-- 68
quux :: Int
quux = 68