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

EAPI=8

# ebuild generated by hackport 0.9.0.0.9999

CABAL_HACKAGE_REVISION=1

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"

# 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/hashable-1.6:=[profile?]
	>=dev-haskell/monad-loops-0.4.3:=[profile?] <dev-haskell/monad-loops-0.5:=[profile?]
	>=dev-haskell/parsec-3.1.14:=[profile?] <dev-haskell/parsec-3.2:=[profile?]
	dev-haskell/quickcheck:=[profile?]
	>=dev-haskell/text-1.2.4:=[profile?] <dev-haskell/text-2.2:=[profile?]
	>=dev-haskell/unordered-containers-0.2.13:=[profile?] <dev-haskell/unordered-containers-0.3:=[profile?]
	>=dev-lang/ghc-9.0.2:=
"
DEPEND="${RDEPEND}
	>=dev-haskell/cabal-3.4.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
}