bennofs / th-lift-instances

Lift instances for common haskell data types
http://hackage.haskell.org/package/th-lift-instances
Other
12 stars 11 forks source link

Implement liftTyped on template-haskell-2.16+ #18

Closed RyanGlScott closed 4 years ago

RyanGlScott commented 4 years ago

template-haskell-2.16.0.0 (bundled with GHC 8.10.1) introduces a new liftTyped method to the Lift class of type a -> Q (TExp a). lift's default definition is now in terms of liftTyped, but because all of the Lift instances in this library are defined by hand, compiling them with GHC 8.10.1 will result in a volley of warnings:

[1 of 1] Compiling Instances.TH.Lift ( src/Instances/TH/Lift.hs, interpreted )

src/Instances/TH/Lift.hs:181:10: warning: [-Wmissing-methods]
    • No explicit implementation for
        ‘liftTyped’
    • In the instance declaration for ‘Lift (IntMap.IntMap v)’
    |
181 | instance Lift v => Lift (IntMap.IntMap v) where
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Instances/TH/Lift.hs:185:10: warning: [-Wmissing-methods]
    • No explicit implementation for
        ‘liftTyped’
    • In the instance declaration for ‘Lift IntSet.IntSet’
    |
185 | instance Lift IntSet.IntSet where
    |          ^^^^^^^^^^^^^^^^^^

src/Instances/TH/Lift.hs:189:10: warning: [-Wmissing-methods]
    • No explicit implementation for
        ‘liftTyped’
    • In the instance declaration for ‘Lift (Map.Map k v)’
    |
189 | instance (Lift k, Lift v) => Lift (Map.Map k v) where
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Instances/TH/Lift.hs:193:10: warning: [-Wmissing-methods]
    • No explicit implementation for
        ‘liftTyped’
    • In the instance declaration for ‘Lift (Sequence.Seq a)’
    |
193 | instance Lift a => Lift (Sequence.Seq a) where
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Instances/TH/Lift.hs:197:10: warning: [-Wmissing-methods]
    • No explicit implementation for
        ‘liftTyped’
    • In the instance declaration for ‘Lift (Set.Set a)’
    |
197 | instance Lift a => Lift (Set.Set a) where
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Instances/TH/Lift.hs:201:10: warning: [-Wmissing-methods]
    • No explicit implementation for
        ‘liftTyped’
    • In the instance declaration for ‘Lift (Tree.Tree a)’
    |
201 | instance Lift a => Lift (Tree.Tree a) where
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Instances/TH/Lift.hs:207:10: warning: [-Wmissing-methods]
    • No explicit implementation for
        ‘liftTyped’
    • In the instance declaration for ‘Lift Text.Text’
    |
207 | instance Lift Text.Text where
    |          ^^^^^^^^^^^^^^

src/Instances/TH/Lift.hs:211:10: warning: [-Wmissing-methods]
    • No explicit implementation for
        ‘liftTyped’
    • In the instance declaration for ‘Lift Text.Lazy.Text’
    |
211 | instance Lift Text.Lazy.Text where
    |          ^^^^^^^^^^^^^^^^^^^

src/Instances/TH/Lift.hs:218:10: warning: [-Wmissing-methods]
    • No explicit implementation for
        ‘liftTyped’
    • In the instance declaration for ‘Lift ByteString.ByteString’
    |
218 | instance Lift ByteString.ByteString where
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Instances/TH/Lift.hs:231:10: warning: [-Wmissing-methods]
    • No explicit implementation for
        ‘liftTyped’
    • In the instance declaration for ‘Lift ByteString.Lazy.ByteString’
    |
231 | instance Lift ByteString.Lazy.ByteString where
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Instances/TH/Lift.hs:240:10: warning: [-Wmissing-methods]
    • No explicit implementation for
        ‘liftTyped’
    • In the instance declaration for
        ‘Lift (Vector.Primitive.Vector a)’
    |
240 | instance (Vector.Primitive.Prim a, Lift a) => Lift (Vector.Primitive.Vector a) where
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Instances/TH/Lift.hs:244:10: warning: [-Wmissing-methods]
    • No explicit implementation for
        ‘liftTyped’
    • In the instance declaration for ‘Lift (Vector.Storable.Vector a)’
    |
244 | instance (Vector.Storable.Storable a, Lift a) => Lift (Vector.Storable.Vector a) where
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Instances/TH/Lift.hs:248:10: warning: [-Wmissing-methods]
    • No explicit implementation for
        ‘liftTyped’
    • In the instance declaration for ‘Lift (Vector.Unboxed.Vector a)’
    |
248 | instance (Vector.Unboxed.Unbox a, Lift a) => Lift (Vector.Unboxed.Vector a) where
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Instances/TH/Lift.hs:252:10: warning: [-Wmissing-methods]
    • No explicit implementation for
        ‘liftTyped’
    • In the instance declaration for ‘Lift (Vector.Boxed.Vector a)’
    |
252 | instance Lift a => Lift (Vector.Boxed.Vector a) where
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Instances/TH/Lift.hs:258:10: warning: [-Wmissing-methods]
    • No explicit implementation for
        ‘liftTyped’
    • In the instance declaration for ‘Lift (Identity a)’
    |
258 | instance Lift a => Lift (Identity a) where
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Instances/TH/Lift.hs:261:10: warning: [-Wmissing-methods]
    • No explicit implementation for
        ‘liftTyped’
    • In the instance declaration for ‘Lift (Const a b)’
    |
261 | instance Lift a => Lift (Const a b) where
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^

This patch fixes these warnings by defining liftTyped on the appropriate versions of template-haskell.

RyanGlScott commented 4 years ago

Hm... Travis is failing because hlint stumbles over a parse error only on GHC 8.0.1:

$ hlint --cpp-simple src
src/Instances/TH/Lift.hs:195:1: Error: Parse error
Found:
      LIFT_TYPED_DEFAULT

  > instance Lift IntSet.IntSet where
      lift s = [| IntSet.fromList s' |] where
        s' = IntSet.toList s

1 hint

I can reproduce this locally. I can also confirm that the error goes away if you don't pass --cpp-simple to hlint:

$ hlint src
No hints
bennofs commented 4 years ago

Thanks for the PR! I'll take a closer look this week.