You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Warn about unusable instances when types are missing from exports #3394
Both @thomashoneyman and I have run into this - it can be very difficult to figure out why instance resolution is failing, so having a warning about it would save many hours of wasted time for the few people that encounter it!
The case we encountered it is creating an "app monad" that also has a parallel version as a newtype, and then forgetting to export the parallel version - the Parallel instance exists, but any attempts to resolve the Parallel constraint for the app monad outside of the defining module fails with a missing instance error.
I think I also ran into this while trying to put together a generic implementation of the Debug class in https://github.com/hdgarrood/purescript-debugged/, by exporting GenericDebug but forgetting to export GenericDebugArgs. Just to check, is this what you had in mind?
moduleMain (Tuple(..), classY, y) wheredataTupleab = TupleabclassXawherex::ainstancexInt :: XIntwhere
x = 0classYabwherey::TupleabinstanceyInt :: Xa=>YaIntwhere
y = Tuple x 1
Then any attempt to write e.g. (y :: Tuple Int Int) in another module will give you
No type class instance was found for class
Main.X
because the class was not in scope. Perhaps it was not exported.
while solving type class constraint
Main.X Int
Have we considered having a non-exported type or class appear in an instance for an exported class be an error? It seems consistent with the existing behaviour of requiring members of an exported class to be exported, and I don't think it ever makes sense to export a class but make one or more of its instances unusable by not exporting things they reference.
Activity
hdgarrood commentedon Dec 17, 2018
I think I also ran into this while trying to put together a generic implementation of the
Debugclass in https://github.com/hdgarrood/purescript-debugged/, by exportingGenericDebugbut forgetting to exportGenericDebugArgs. Just to check, is this what you had in mind?Then any attempt to write e.g.
(y :: Tuple Int Int)in another module will give youHave we considered having a non-exported type or class appear in an instance for an exported class be an error? It seems consistent with the existing behaviour of requiring members of an exported class to be exported, and I don't think it ever makes sense to export a class but make one or more of its instances unusable by not exporting things they reference.
garyb commentedon Dec 17, 2018
Yeah, that's essentially how I'd like to fix this.
edit: Oh, I see what you mean - I said warning, but it could be an error immediately. Yeah, that works too!