Closed ysangkok closed 1 year ago
Let's simply deactivate -Wunticked-promoted-constructors
for all GHC versions?
Let's simply deactivate -Wunticked-promoted-constructors for all GHC versions?
I don't think this works. The issue is not caused by warnings, but it is caused by types in error messages not having the tick as they previously had. To verify this, I added -Wunticked-promoted-constructors
to the test-suite
of servant-server
, and reran the doctest. I still get the failures. I suspect I'd be another flag we'd need to set for older GHCs, one about formatting errors. And I am not sure that exists, since the change of heart on unticked promoted constructors might not have been anticipated such that it'd be available in all the GHC versions we run the doctests for.
Solutions I can think of:
Verb 'GET
with Verb GET
.-- | This instance prevents from accidentally using '->' instead of ':>'
--
#if __GLASGOW_HASKELL__ >= 906
-- >>> serve (Proxy :: Proxy (Capture "foo" Int -> Get '[JSON] Int)) (error "...")
-- ...
-- ...No instance HasServer (a -> b).
-- ...Maybe you have used '->' instead of ':>' between
-- ...Capture' '[] "foo" Int
-- ...and
-- ...Verb GET 200 [JSON] Int
-- ...
#else
-- >>> serve (Proxy :: Proxy (Capture "foo" Int -> Get '[JSON] Int)) (error "...")
-- ...
-- ...No instance HasServer (a -> b).
-- ...Maybe you have used '->' instead of ':>' between
-- ...Capture' '[] "foo" Int
-- ...and
-- ...Verb 'GET 200 '[JSON] Int
-- ...
#endif
We could also add -fprint-redundant-promotion-ticks
to have GHC print it in the old style.
@voidus Thank you! I have added the flag in #1680 . I would appreciate a review if you have time.
Setting
allow-newer
and running the doctests reveals that this new version of GHC (or is it doctest?) prefers not to have ticks. That makes sense because unticked promoted constructors are now encouraged. But I am not sure how the tests can be made compatible such that they work for both old and new GHCs.