# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

# ebuild generated by hackport 0.7.3.0

CABAL_FEATURES="lib profile haddock hoogle hscolour test-suite"
inherit haskell-cabal optfeature

DESCRIPTION="Rewriting library with online termination checking"
HOMEPAGE="https://hackage.haskell.org/package/rest-rewrite"

LICENSE="BSD"
SLOT="0/${PV}"
KEYWORDS="~amd64"

CABAL_CHDEPS=(
	'hashable             >= 1.3.0 && < 1.4' 'hashable >= 1.3.0'
)

# Without this, './setup haddock' fails when calculating transient dependencies
CABAL_HADDOCK_TARGETS="lib:${CABAL_PN}"

RDEPEND="
	>=dev-haskell/hashable-1.3.0:=[profile?]
	>=dev-haskell/monad-loops-0.4.3:=[profile?] <dev-haskell/monad-loops-0.5:=[profile?]
	dev-haskell/quickcheck:=[profile?]
	>=dev-haskell/unordered-containers-0.2.13:=[profile?] <dev-haskell/unordered-containers-0.3:=[profile?]
	>=dev-lang/ghc-8.8.4:=
"
DEPEND="${RDEPEND}
	>=dev-haskell/cabal-3.0.1.0
	test? (
		>=dev-haskell/quickcheck-2.14.2 <dev-haskell/quickcheck-2.15
	)
"
BDEPEND="
	test? (
		media-gfx/graphviz
		sci-mathematics/z3
	)
"

src_prepare() {
	haskell-cabal_src_prepare

	if use test; then
		# Requires the 'graphs' folder to exist for tests but it is not included in
		# the tarball.
		mkdir -v "${S}/graphs" || die
	fi
}

pkg_postinst() {
	optfeature_header "This library uses external executables for certain features"
	optfeature "SAT solving" sci-mathematics/z3
	optfeature "graph output" media-gfx/graphviz
}