Skip to content

Simplify GenericInputObjectFieldDefinitions #195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 29, 2018

Conversation

Shou
Copy link
Contributor

@Shou Shou commented Aug 20, 2018

We simplify GenericInputObjectFieldDefinitions by using
tree-recursion, resulting in better error messages. Example
code to reproduce below, where the 'true' error is usage of
lists.

data family Test :: Nat -> Type
data instance Test 1 = Test
  { testField1 :: Int32
  , testField2 :: Text
  , testField3 :: Text
  , testField4 :: [Int32]
  } deriving (Show, Generic)
instance HasAnnotatedInputType Test

Before

        • No instance for (GraphQL.Internal.API.GenericInputObjectFieldDefinitions
                             ((S1
                                 ('MetaSel
                                    ('Just "testField1")
                                    'NoSourceUnpackedness
                                    'NoSourceStrictness
                                    'DecidedLazy)
                                 (Rec0 Int32)
                               :*: S1
                                     ('MetaSel
                                        ('Just "testField2")
                                        'NoSourceUnpackedness
                                        'NoSourceStrictness
                                        'DecidedLazy)
                                     (Rec0 Text))
                              :*: (S1
                                     ('MetaSel
                                        ('Just "testField3")
                                        'NoSourceUnpackedness
                                        'NoSourceStrictness
                                        'DecidedLazy)
                                     (Rec0 Text)
                                   :*: S1
                                         ('MetaSel
                                            ('Just "testField4")
                                            'NoSourceUnpackedness
                                            'NoSourceStrictness
                                            'DecidedLazy)
                                         (Rec0 [Int32]))))
            arising from a use of ‘GraphQL.Internal.API.$dmgetAnnotatedInputType’
        • In the expression:
            GraphQL.Internal.API.$dmgetAnnotatedInputType @(Test 1)
          In an equation for ‘QL.getAnnotatedInputType’:
              QL.getAnnotatedInputType
                = GraphQL.Internal.API.$dmgetAnnotatedInputType @(Test 1)
          In the instance declaration for ‘QL.HasAnnotatedInputType (Test 1)’
       |
    72 | instance QL.HasAnnotatedInputType (Test 1)
       |

After

    • No instance for (QL.HasAnnotatedInputType [Int32])
      arising from a use of ‘GraphQL.Internal.API.$dmgetAnnotatedInputType’
    • In the expression:
        GraphQL.Internal.API.$dmgetAnnotatedInputType @(Test 1)
      In an equation for ‘QL.getAnnotatedInputType’:
          QL.getAnnotatedInputType
            = GraphQL.Internal.API.$dmgetAnnotatedInputType @(Test 1)
      In the instance declaration for ‘QL.HasAnnotatedInputType (Test 1)’
    |
72  | instance QL.HasAnnotatedInputType (Test 1)
    |

@Shou Shou force-pushed the annotated-input-error-messages branch 2 times, most recently from 9793f68 to 30f58e4 Compare August 20, 2018 20:00
@jml
Copy link
Collaborator

jml commented Aug 21, 2018

Thanks for the PR. The test failure is due to our coverage ratchet. Because you improve the test coverage (yay!), you need to update the COVERAGE_TOLERANCE dict in scripts/hpc-ratchet to have the new values.

Copy link
Collaborator

@jml jml left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Need to bump the coverage ratchet as mentioned in my earlier comment.

We simplify `GenericInputObjectFieldDefinitions` by using
tree-recursion, resulting in better error messages. Example
code to reproduce below, where the 'true' error is usage of
lists.

```hs
data family Test :: Nat -> Type
data instance Test 1 = Test
  { testField1 :: Int32
  , testField2 :: Text
  , testField3 :: Text
  , testField4 :: [Int32]
  } deriving (Show, Generic)
instance HasAnnotatedInputType Test
```

Before
```
        • No instance for (GraphQL.Internal.API.GenericInputObjectFieldDefinitions
                             ((S1
                                 ('MetaSel
                                    ('Just "testField1")
                                    'NoSourceUnpackedness
                                    'NoSourceStrictness
                                    'DecidedLazy)
                                 (Rec0 Int32)
                               :*: S1
                                     ('MetaSel
                                        ('Just "testField2")
                                        'NoSourceUnpackedness
                                        'NoSourceStrictness
                                        'DecidedLazy)
                                     (Rec0 Text))
                              :*: (S1
                                     ('MetaSel
                                        ('Just "testField3")
                                        'NoSourceUnpackedness
                                        'NoSourceStrictness
                                        'DecidedLazy)
                                     (Rec0 Text)
                                   :*: S1
                                         ('MetaSel
                                            ('Just "testField4")
                                            'NoSourceUnpackedness
                                            'NoSourceStrictness
                                            'DecidedLazy)
                                         (Rec0 [Int32]))))
            arising from a use of ‘GraphQL.Internal.API.$dmgetAnnotatedInputType’
        • In the expression:
            GraphQL.Internal.API.$dmgetAnnotatedInputType @(Test 1)
          In an equation for ‘QL.getAnnotatedInputType’:
              QL.getAnnotatedInputType
                = GraphQL.Internal.API.$dmgetAnnotatedInputType @(Test 1)
          In the instance declaration for ‘QL.HasAnnotatedInputType (Test 1)’
       |
    72 | instance QL.HasAnnotatedInputType (Test 1)
       |
```

After
```
    • No instance for (QL.HasAnnotatedInputType [Int32])
      arising from a use of ‘GraphQL.Internal.API.$dmgetAnnotatedInputType’
    • In the expression:
        GraphQL.Internal.API.$dmgetAnnotatedInputType @(Test 1)
      In an equation for ‘QL.getAnnotatedInputType’:
          QL.getAnnotatedInputType
            = GraphQL.Internal.API.$dmgetAnnotatedInputType @(Test 1)
      In the instance declaration for ‘QL.HasAnnotatedInputType (Test 1)’
    |
72  | instance QL.HasAnnotatedInputType (Test 1)
    |
```
@Shou Shou force-pushed the annotated-input-error-messages branch from 30f58e4 to 5747b88 Compare August 21, 2018 11:37
@Shou
Copy link
Contributor Author

Shou commented Aug 21, 2018

Done! Tests are looking good now.

@dminuoso dminuoso mentioned this pull request Aug 25, 2018
@Shou
Copy link
Contributor Author

Shou commented Aug 29, 2018

@jml anything else I can do to get the PR merged?

@jml
Copy link
Collaborator

jml commented Aug 29, 2018

All good. Sorry for the delay.

@jml jml merged commit 1f39e22 into haskell-graphql:master Aug 29, 2018
@Shou Shou deleted the annotated-input-error-messages branch August 29, 2018 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants