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
When doing some field testing today, I noticed that swagger2 fails to build with GHC 8.2:
$ cabal build
Building swagger2-2.1.3...
Preprocessing library swagger2-2.1.3...
[ 9 of 14] Compiling Data.Swagger.Internal.Schema ( src/Data/Swagger/Internal/Schema.hs, dist/build/Data/Swagger/Internal/Schema.o )
src/Data/Swagger/Internal/Schema.hs:638:25: error:
• Overlapping instances for GSumToSchema (C1 c U1)
arising from a use of ‘gdeclareNamedSumSchema’
Matching instances:
two instances involving out-of-scope types
(use -fprint-potential-instances to see them all)
• In the expression: gdeclareNamedSumSchema
In an equation for ‘gdeclareNamedSchema’:
gdeclareNamedSchema = gdeclareNamedSumSchema
In the instance declaration for ‘GToSchema (C1 c U1)’
|
638 | gdeclareNamedSchema = gdeclareNamedSumSchema
| ^^^^^^^^^^^^^^^^^^^^^^
src/Data/Swagger/Internal/Schema.hs:763:84: error:
• Couldn't match kind ‘k’ with ‘*’
‘k’ is a rigid type variable bound by
the instance declaration
at src/Data/Swagger/Internal/Schema.hs:762:10-48
When matching the kind of ‘proxy’
Expected type: proxy (C1 c U1)
Actual type: proxy (C1 c U1)
• In the third argument of ‘gsumConToSchemaWith’, namely ‘proxy’
In the second argument of ‘(.)’, namely
‘gsumConToSchemaWith (Inline nullarySchema) opts proxy’
In the expression:
pure . gsumConToSchemaWith (Inline nullarySchema) opts proxy
• Relevant bindings include
proxy :: proxy (C1 c U1)
(bound at src/Data/Swagger/Internal/Schema.hs:763:21)
gsumToSchema :: SchemaOptions
-> proxy (C1 c U1)
-> Schema
-> WriterT AllNullary (Declare (Definitions Schema)) Schema
(bound at src/Data/Swagger/Internal/Schema.hs:763:3)
|
763 | gsumToSchema opts proxy = pure . gsumConToSchemaWith (Inline nullarySchema) opts proxy
| ^^^^^
The issue is that starting in GHC 8.2, the datatypes in GHC.Genericsbecame poly-kinded. There are two ways one could fix this problem:
Use an explicit kind signature for GSumToSchema:
diff --git a/src/Data/Swagger/Internal/Schema.hs b/src/Data/Swagger/Internal/Schema.hs
index ae6a7b2..1f6b3dd 100644
--- a/src/Data/Swagger/Internal/Schema.hs+++ b/src/Data/Swagger/Internal/Schema.hs@@ -727,7 +727,7 @@ gdeclareNamedSumSchema opts proxy s
type AllNullary = All
-class GSumToSchema f where+class GSumToSchema (f :: * -> *) where
gsumToSchema :: SchemaOptions -> proxy f -> Schema -> WriterT AllNullary (Declare (Defi
instance (GSumToSchema f, GSumToSchema g) => GSumToSchema (f :+: g) where
This would be identical to inferred kind signature prior to GHC 8.2.
Generalize the kind signature of GToSchema:
diff --git a/src/Data/Swagger/Internal/Schema.hs b/src/Data/Swagger/Internal/Schema.hs
index ae6a7b2..d5965d5 100644
--- a/src/Data/Swagger/Internal/Schema.hs+++ b/src/Data/Swagger/Internal/Schema.hs@@ -404,7 +404,7 @@ sketchStrictSchema = go . toJSON
where
names = HashMap.keys o
-class GToSchema (f :: * -> *) where+class GToSchema (f :: k -> *) where
gdeclareNamedSchema :: SchemaOptions -> proxy f -> Schema -> Declare (Definitions Schem
instance OVERLAPPABLE_ ToSchema a => ToSchema [a] where
Which option sounds better to you?
The text was updated successfully, but these errors were encountered:
I assume both variants works with GHC>=7.8? I have no opinion on this, I assume generics functors are always instantiated as * -> * when used in deriving (Generic)?
When doing some field testing today, I noticed that
swagger2
fails to build with GHC 8.2:The issue is that starting in GHC 8.2, the datatypes in
GHC.Generics
became poly-kinded. There are two ways one could fix this problem:Use an explicit kind signature for
GSumToSchema
:This would be identical to inferred kind signature prior to GHC 8.2.
Generalize the kind signature of
GToSchema
:Which option sounds better to you?
The text was updated successfully, but these errors were encountered: