Is there a reason why coerce does not have a default for the identity with respect to constraints ?
import Data.Coerce
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
newtype Id a = Id a
a :: Id Int
a = coerce 3 -- bad
-- • Couldn't match representation of type ‘a0’ with that of ‘Int’ arising from a use of ‘coerce’
-- • Ambiguous type variable ‘a0’ arising from the literal ‘3’
-- prevents the constraint ‘(Num a0)’ from being solved.
-- Probable fix: use a type annotation to specify what ‘a0’ should be.
-- These potential instances exist:
-- instance Num Integer -- Defined in ‘GHC.Num’
-- instance Num Double -- Defined in ‘GHC.Float’
-- instance Num Float -- Defined in ‘GHC.Float’
b :: Id Int
b = coerce (3 :: Int)
I imagined that it could attempt to solve that with a0 ~ Int (or other constraints in general), as the identity (and merging contraints) seems always an option