IntersectMBO / cardano-prelude

A protolude-based custom prelude for the Cardano project
Apache License 2.0
15 stars 11 forks source link

Build fails with `Could not deduce ...` errors #167

Open omefire opened 2 years ago

omefire commented 2 years ago

I have included cardano-prelude as a dependency in my project's cabal.project file: https://github.com/omefire/api-server/blob/main/cabal.project

However, when I try to build the project with cabal build, I always end up getting this error:

[ 7 of 14] Compiling Cardano.Prelude.GHC.Heap ( src/Cardano/Prelude/GHC/Heap.hs, dist/build/Cardano/Prelude/GHC/Heap.o, dist/build/Cardano/Prelude/GHC/Heap.dyn_o )
[ 8 of 14] Compiling Cardano.Prelude.HeapWords ( src/Cardano/Prelude/HeapWords.hs, dist/build/Cardano/Prelude/HeapWords.o, dist/build/Cardano/Prelude/HeapWords.dyn_o )
[ 9 of 14] Compiling Cardano.Prelude.Json.Parse ( src/Cardano/Prelude/Json/Parse.hs, dist/build/Cardano/Prelude/Json/Parse.o, dist/build/Cardano/Prelude/Json/Parse.dyn_o )
[10 of 14] Compiling Cardano.Prelude.Json.Canonical ( src/Cardano/Prelude/Json/Canonical.hs, dist/build/Cardano/Prelude/Json/Canonical.o, dist/build/Cardano/Prelude/Json/Canonical.dyn_o )

src/Cardano/Prelude/Json/Canonical.hs:110:14: error:
    • Could not deduce (Buildable e2)
        arising from a use of ‘parseJSString’
      from the context: ReportSchemaErrors m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:109:10-50
      The type variable ‘e2’ is ambiguous
      These potential instances exist:
        instance Buildable Void -- Defined in ‘Formatting.Buildable’
        instance Buildable IntPtr -- Defined in ‘Formatting.Buildable’
        instance Buildable WordPtr -- Defined in ‘Formatting.Buildable’
        ...plus 24 others
        ...plus 12 instances involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the expression: parseJSString (readEither . toS)
      In an equation for ‘fromJSON’:
          fromJSON = parseJSString (readEither . toS)
      In the instance declaration for ‘FromJSON m Word64’
    |
110 |   fromJSON = parseJSString (readEither . toS)
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Cardano/Prelude/Json/Canonical.hs:110:29: error:
    • Could not deduce (Protolude.Conv.StringConv e2 GHC.Base.String)
        arising from a use of ‘readEither’
      from the context: ReportSchemaErrors m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:109:10-50
      The type variable ‘e2’ is ambiguous
      These potential instances exist:
        instance Protolude.Conv.StringConv ByteString GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        instance Protolude.Conv.StringConv LB.ByteString GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        instance Protolude.Conv.StringConv Text GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        ...plus one other
        ...plus one instance involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the first argument of ‘(.)’, namely ‘readEither’
      In the first argument of ‘parseJSString’, namely
        ‘(readEither . toS)’
      In the expression: parseJSString (readEither . toS)
    |
110 |   fromJSON = parseJSString (readEither . toS)
    |                             ^^^^^^^^^^

src/Cardano/Prelude/Json/Canonical.hs:110:42: error:
    • Could not deduce (ConvertText Text e2)
        arising from a use of ‘toS’
      from the context: ReportSchemaErrors m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:109:10-50
      The type variable ‘e2’ is ambiguous
      These potential instances exist:
        instance [safe] ConvertText Text Text
          -- Defined in ‘Protolude.ConvertText’
        instance [safe] ConvertText Text GHC.Base.String
          -- Defined in ‘Protolude.ConvertText’
        ...plus one instance involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the second argument of ‘(.)’, namely ‘toS’
      In the first argument of ‘parseJSString’, namely
        ‘(readEither . toS)’
      In the expression: parseJSString (readEither . toS)
    |
110 |   fromJSON = parseJSString (readEither . toS)
    |                                          ^^^

src/Cardano/Prelude/Json/Canonical.hs:113:14: error:
    • Could not deduce (Buildable e1)
        arising from a use of ‘parseJSString’
      from the context: ReportSchemaErrors m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:112:10-51
      The type variable ‘e1’ is ambiguous
      These potential instances exist:
        instance Buildable Void -- Defined in ‘Formatting.Buildable’
        instance Buildable IntPtr -- Defined in ‘Formatting.Buildable’
        instance Buildable WordPtr -- Defined in ‘Formatting.Buildable’
        ...plus 24 others
        ...plus 12 instances involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the expression: parseJSString (readEither . toS)
      In an equation for ‘fromJSON’:
          fromJSON = parseJSString (readEither . toS)
      In the instance declaration for ‘FromJSON m Integer’
    |
113 |   fromJSON = parseJSString (readEither . toS)
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Cardano/Prelude/Json/Canonical.hs:113:29: error:
    • Could not deduce (Protolude.Conv.StringConv e1 GHC.Base.String)
        arising from a use of ‘readEither’
      from the context: ReportSchemaErrors m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:112:10-51
      The type variable ‘e1’ is ambiguous
      These potential instances exist:
        instance Protolude.Conv.StringConv ByteString GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        instance Protolude.Conv.StringConv LB.ByteString GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        instance Protolude.Conv.StringConv Text GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        ...plus one other
        ...plus one instance involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the first argument of ‘(.)’, namely ‘readEither’
      In the first argument of ‘parseJSString’, namely
        ‘(readEither . toS)’
      In the expression: parseJSString (readEither . toS)
    |
113 |   fromJSON = parseJSString (readEither . toS)
    |                             ^^^^^^^^^^

src/Cardano/Prelude/Json/Canonical.hs:113:42: error:
    • Could not deduce (ConvertText Text e1)
        arising from a use of ‘toS’
      from the context: ReportSchemaErrors m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:112:10-51
      The type variable ‘e1’ is ambiguous
      These potential instances exist:
        instance [safe] ConvertText Text Text
          -- Defined in ‘Protolude.ConvertText’
        instance [safe] ConvertText Text GHC.Base.String
          -- Defined in ‘Protolude.ConvertText’
        ...plus one instance involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the second argument of ‘(.)’, namely ‘toS’
      In the first argument of ‘parseJSString’, namely
        ‘(readEither . toS)’
      In the expression: parseJSString (readEither . toS)
    |
113 |   fromJSON = parseJSString (readEither . toS)
    |                                          ^^^

src/Cardano/Prelude/Json/Canonical.hs:116:14: error:
    • Could not deduce (Buildable e0)
        arising from a use of ‘parseJSString’
      from the context: MonadError SchemaError m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:115:10-55
      The type variable ‘e0’ is ambiguous
      These potential instances exist:
        instance Buildable Void -- Defined in ‘Formatting.Buildable’
        instance Buildable IntPtr -- Defined in ‘Formatting.Buildable’
        instance Buildable WordPtr -- Defined in ‘Formatting.Buildable’
        ...plus 24 others
        ...plus 12 instances involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the expression: parseJSString (readEither . toS)
      In an equation for ‘fromJSON’:
          fromJSON = parseJSString (readEither . toS)
      In the instance declaration for ‘FromJSON m Natural’
    |
116 |   fromJSON = parseJSString (readEither . toS)
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Cardano/Prelude/Json/Canonical.hs:116:29: error:
    • Could not deduce (Protolude.Conv.StringConv e0 GHC.Base.String)
        arising from a use of ‘readEither’
      from the context: MonadError SchemaError m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:115:10-55
      The type variable ‘e0’ is ambiguous
      These potential instances exist:
        instance Protolude.Conv.StringConv ByteString GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        instance Protolude.Conv.StringConv LB.ByteString GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        instance Protolude.Conv.StringConv Text GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        ...plus one other
        ...plus one instance involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the first argument of ‘(.)’, namely ‘readEither’
      In the first argument of ‘parseJSString’, namely
        ‘(readEither . toS)’
      In the expression: parseJSString (readEither . toS)
    |
116 |   fromJSON = parseJSString (readEither . toS)
    |                             ^^^^^^^^^^

src/Cardano/Prelude/Json/Canonical.hs:116:42: error:
    • Could not deduce (ConvertText Text e0)
        arising from a use of ‘toS’
      from the context: MonadError SchemaError m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:115:10-55
      The type variable ‘e0’ is ambiguous
      These potential instances exist:
        instance [safe] ConvertText Text Text
          -- Defined in ‘Protolude.ConvertText’
        instance [safe] ConvertText Text GHC.Base.String
          -- Defined in ‘Protolude.ConvertText’
        ...plus one instance involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the second argument of ‘(.)’, namely ‘toS’
      In the first argument of ‘parseJSString’, namely
        ‘(readEither . toS)’
      In the expression: parseJSString (readEither . toS)
    |
116 |   fromJSON = parseJSString (readEither . toS)
    |                                          ^^^
cabal: Failed to build cardano-prelude-0.1.0.0 (which is required by
exe:api-server-exe from api-server-0.1.0.0). See the build log
above for details.
zmrocze commented 1 year ago

Having same issue

coot commented 1 year ago

it seems like one of the packages is using newer version that is supported by cardano-prelude. If you are using cabal you could try to use the same index-state as in cabal.project in this repo.

zmrocze commented 1 year ago

anyone knows which dependency is at fault and has the incorrect bound?