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

EAPI=8

# ebuild generated by hackport 0.9.1.0.9999
CABAL_HACKAGE_REVISION=1

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

DESCRIPTION="Disambiguate obvious uses of effects"
HOMEPAGE="https://github.com/polysemy-research/polysemy#readme"

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

RESTRICT="test"

RDEPEND=">=dev-haskell/ghc-tcplugins-extra-0.3:=[profile?] <dev-haskell/ghc-tcplugins-extra-0.6:=[profile?]
	>=dev-haskell/polysemy-1.7:=[profile?]
	>=dev-haskell/syb-0.7:=[profile?] <dev-haskell/syb-0.8:=[profile?]
	>=dev-lang/ghc-9.0.2:=
"
DEPEND="${RDEPEND}
	>=dev-haskell/cabal-3.4.1.0
	dev-haskell/cabal-doctest
"

src_prepare() {
	default
	
	# Fix cabal-doctest import issue by creating a simple Setup.hs
	# if the original Setup.hs uses cabal-doctest
	if grep -q "Distribution.Extra.Doctest" Setup.hs 2>/dev/null; then
		einfo "Replacing Setup.hs to avoid cabal-doctest issues"
		cat > Setup.hs <<-EOF
		import Distribution.Simple
		main = defaultMain
		EOF
	fi
}

src_configure() {
	haskell-cabal_src_configure \
		$(cabal_flag corelint corelint)
}