import Data.StateVar
import Data.Functor.Contravariant
import Data.Functor.Contravariant.Divisible
-- No instance for (Decidable SettableStateVar)
ssv1 :: SettableStateVar String
ssv1 = lose (\_ -> undefined)
-- No instance for (Divisible SettableStateVar)
ssv2 :: SettableStateVar String
ssv2 = conquer
-- Typechecks without error, meaning the Contravariant instance is visible
contra :: SettableStateVar String
contra = contramap length (makeSettableStateVar undefined :: SettableStateVar Int)
Compiling the above program reveals that the Decidable and Divisible instances do not exist for SettableStateVar even though they are clearly defined in the Data.Functor.Contravariant.Divisible. The problem is the use of #if MIN_VERSION_StateVar instead of #ifdef MIN_VERSION_StateVar.
This extremely subtle bug was discovered when trying to compile contravariant with Eta and it resulted in a cpphs failure.
Compiling the above program reveals that the
Decidable
andDivisible
instances do not exist forSettableStateVar
even though they are clearly defined in theData.Functor.Contravariant.Divisible
. The problem is the use of#if MIN_VERSION_StateVar
instead of#ifdef MIN_VERSION_StateVar
.This extremely subtle bug was discovered when trying to compile
contravariant
with Eta and it resulted in acpphs
failure.This PR fixes the problem.