graphql-api icon indicating copy to clipboard operation
graphql-api copied to clipboard

Fix overlapping errors and improve diagnostics

Open dminuoso opened this issue 7 years ago • 2 comments

This fix is similar to: https://github.com/haskell-graphql/graphql-api/pull/178

The existing code has overlapping instances, namely for:

(l :+: r) and (C1 (...) :+: r)

The second instance is unnecessary, since the instance for C1 (...) (S1 sa sb) will produce a type error already.

Some code that triggers the overlapping instances error:

{-# LANGUAGE DeriveGeneric    #-}
{-# LANGUAGE TypeApplications #-}

import GraphQL.Internal.API.Enum (GraphQLEnum(..))
import GHC.Generics (from, to, Generic)

data Magic = Left Int | Right deriving (Eq, Show, Generic)

instance GraphQLEnum Magic

main = main

f = enumValues @Magic

Also an unary constructor is one that takes one argument, so I took the liberty to rename the diagnostics to nullary constructors.

A test case would be a bit more difficult because it still fails compilation.

dminuoso avatar Aug 25 '18 09:08 dminuoso

Looks good, thank you! To make the test pass can you adjust COVERAGE_TOLERANCE like in this diff?

teh avatar Aug 25 '18 13:08 teh

@teh Done

dminuoso avatar Aug 25 '18 16:08 dminuoso