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_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"],
)

View 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

View 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

View 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 |]

View 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

View 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

View file

@ -0,0 +1 @@
#define MAGIC_NUMBER 100

View 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;
}) {})

View file

@ -0,0 +1 @@
Некоторый текст на русском.