feat(third_party/bazel): Check in rules_haskell from Tweag
This commit is contained in:
parent
2eb1dc26e4
commit
f723b8b878
479 changed files with 51484 additions and 0 deletions
73
third_party/bazel/rules_haskell/tests/haddock/BUILD.bazel
vendored
Normal file
73
third_party/bazel/rules_haskell/tests/haddock/BUILD.bazel
vendored
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
load(
|
||||
"@io_tweag_rules_haskell//haskell:haskell.bzl",
|
||||
"haskell_doc",
|
||||
"haskell_library",
|
||||
"haskell_toolchain_library",
|
||||
)
|
||||
|
||||
package(
|
||||
default_testonly = 1,
|
||||
default_visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
haskell_library(
|
||||
name = "haddock-lib-deep",
|
||||
srcs = ["Deep.hsc"],
|
||||
deps = ["//tests/hackage:base"],
|
||||
)
|
||||
|
||||
haskell_library(
|
||||
name = "haddock-lib-a",
|
||||
srcs = [
|
||||
"LibA.hs",
|
||||
"LibA/A.hs",
|
||||
"header.h",
|
||||
],
|
||||
compiler_flags = ["-I."],
|
||||
deps = [
|
||||
":haddock-lib-deep",
|
||||
"//tests/hackage:base",
|
||||
"//tests/hackage:template-haskell",
|
||||
],
|
||||
)
|
||||
|
||||
haskell_toolchain_library(
|
||||
name = "haddock-lib-c",
|
||||
package = "libc",
|
||||
)
|
||||
|
||||
haskell_library(
|
||||
name = "haddock-lib-b",
|
||||
srcs = [
|
||||
"LibB.hs",
|
||||
"TH.hs",
|
||||
],
|
||||
extra_srcs = [
|
||||
"unicode.txt",
|
||||
],
|
||||
tags = [
|
||||
"requires_hackage",
|
||||
"requires_zlib",
|
||||
],
|
||||
deps = [
|
||||
":haddock-lib-a",
|
||||
"//tests/hackage:base",
|
||||
"//tests/hackage:template-haskell",
|
||||
"@hackage//:libc",
|
||||
"@zlib",
|
||||
],
|
||||
)
|
||||
|
||||
haskell_doc(
|
||||
name = "haddock",
|
||||
index_transitive_deps = False,
|
||||
tags = ["requires_hackage"],
|
||||
deps = [":haddock-lib-b"],
|
||||
)
|
||||
|
||||
haskell_doc(
|
||||
name = "haddock-transitive",
|
||||
index_transitive_deps = True,
|
||||
tags = ["requires_hackage"],
|
||||
deps = [":haddock-lib-b"],
|
||||
)
|
||||
11
third_party/bazel/rules_haskell/tests/haddock/Deep.hsc
vendored
Normal file
11
third_party/bazel/rules_haskell/tests/haddock/Deep.hsc
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
-- | "Deep" doc.
|
||||
module Deep (deep_lib) where
|
||||
|
||||
-- | 'deep_lib' doc.
|
||||
|
||||
#if __GLASGOW_HASKELL__ >= 700
|
||||
#ifndef _INTERNAL_HSC_DO_NOT_DEFINE_ME
|
||||
deep_lib :: Int
|
||||
deep_lib = 100
|
||||
#endif
|
||||
#endif
|
||||
19
third_party/bazel/rules_haskell/tests/haddock/LibA.hs
vendored
Normal file
19
third_party/bazel/rules_haskell/tests/haddock/LibA.hs
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
-- | "LibA" header
|
||||
{-# LANGUAGE CPP #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
|
||||
#include "header.h"
|
||||
|
||||
module LibA where
|
||||
|
||||
import LibA.A (a)
|
||||
import Deep (deep_lib)
|
||||
|
||||
-- | 'A' declaration.
|
||||
data A =
|
||||
-- | 'A' constructor.
|
||||
A
|
||||
|
||||
-- | Doc for 'f' using 'a' and 'deep_lib'.
|
||||
f :: Int
|
||||
f = const $a deep_lib + MAGIC_NUMBER
|
||||
10
third_party/bazel/rules_haskell/tests/haddock/LibA/A.hs
vendored
Normal file
10
third_party/bazel/rules_haskell/tests/haddock/LibA/A.hs
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
-- | "LibA.A" header
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
|
||||
module LibA.A where
|
||||
|
||||
import Language.Haskell.TH
|
||||
|
||||
-- | 'a' doc
|
||||
a :: Q Exp
|
||||
a = [| 5 |]
|
||||
21
third_party/bazel/rules_haskell/tests/haddock/LibB.hs
vendored
Normal file
21
third_party/bazel/rules_haskell/tests/haddock/LibB.hs
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{-# LANGUAGE TemplateHaskell #-}
|
||||
-- | "LibB" doc.
|
||||
|
||||
module LibB where
|
||||
|
||||
import LibA.A (a)
|
||||
import LibA (f)
|
||||
import LibC (mytype, LibCType)
|
||||
import TH (foo)
|
||||
|
||||
-- | Doc for 'x' using 'f' and 'a' and 'Int'.
|
||||
x :: Int
|
||||
x = const f a
|
||||
|
||||
-- | This uses a type from an undocumented package
|
||||
y :: LibCType
|
||||
y = mytype
|
||||
|
||||
-- | A thing generated with TH.
|
||||
z :: String
|
||||
z = $foo
|
||||
7
third_party/bazel/rules_haskell/tests/haddock/TH.hs
vendored
Normal file
7
third_party/bazel/rules_haskell/tests/haddock/TH.hs
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
module TH (foo) where
|
||||
|
||||
import Language.Haskell.TH
|
||||
import Language.Haskell.TH.Syntax (lift)
|
||||
|
||||
foo :: Q Exp
|
||||
foo = runIO (readFile "tests/haddock/unicode.txt") >>= lift
|
||||
1
third_party/bazel/rules_haskell/tests/haddock/header.h
vendored
Normal file
1
third_party/bazel/rules_haskell/tests/haddock/header.h
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
#define MAGIC_NUMBER 100
|
||||
47
third_party/bazel/rules_haskell/tests/haddock/libC.nix
vendored
Normal file
47
third_party/bazel/rules_haskell/tests/haddock/libC.nix
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
# A trivial `haskellPackages` library that has haddock generation disabled
|
||||
self: pkgs:
|
||||
let
|
||||
# pkgs = import ../../nixpkgs.nix {};
|
||||
|
||||
libC = pkgs.writeText "LibC.hs" ''
|
||||
{-# language NoImplicitPrelude #-}
|
||||
module LibC where
|
||||
|
||||
data LibCType = LibCType
|
||||
|
||||
-- | myfunction
|
||||
mytype :: LibCType
|
||||
mytype = LibCType
|
||||
'';
|
||||
|
||||
cabal = pkgs.writeText "libc.cabal" ''
|
||||
name: libc
|
||||
version: 0.1.0.0
|
||||
build-type: Simple
|
||||
cabal-version: >=1.10
|
||||
|
||||
library
|
||||
default-language: Haskell2010
|
||||
exposed-modules: LibC
|
||||
'';
|
||||
|
||||
src = pkgs.runCommand "libc-src" {} ''
|
||||
mkdir $out
|
||||
cp ${libC} $out/LibC.hs
|
||||
cp ${cabal} $out/libc.cabal
|
||||
'';
|
||||
|
||||
in
|
||||
# This call means the `.haddock` file is not generated,
|
||||
# even though the ghc package still references the location
|
||||
# where it would ordinarily be.
|
||||
pkgs.haskell.lib.dontHaddock
|
||||
|
||||
(self.callPackage
|
||||
({ mkDerivation }: mkDerivation {
|
||||
pname = "libc";
|
||||
version = "0.1.0.0";
|
||||
src = src;
|
||||
license = pkgs.lib.licenses.mit;
|
||||
isExecutable = false;
|
||||
}) {})
|
||||
1
third_party/bazel/rules_haskell/tests/haddock/unicode.txt
vendored
Normal file
1
third_party/bazel/rules_haskell/tests/haddock/unicode.txt
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
Некоторый текст на русском.
|
||||
Loading…
Add table
Add a link
Reference in a new issue