sdiehl / galois-field

Finite field and algebraic extension field arithmetic
MIT License
50 stars 13 forks source link

galois-field-0.4.1 fails to build with poly-0.3.2.0 #22

Closed DanBurton closed 4 years ago

DanBurton commented 4 years ago

I was able to reproduce this locally like so:

stack unpack galois-field-0.4.1 && cd galois-field-0.4.1
edit stack.yaml # add the following stack.yaml
stack build --test --bench --no-run-benchmarks --fast
# stack.yaml
resolver: nightly-2019-09-21
extra-deps:
- poly-0.3.2.0

The build errors being as follows:

[ 2 of 10] Compiling ExtensionField [Data.Poly.Semiring changed]

/Users/dan/scratch/galois-field-0.4.1/src/ExtensionField.hs:44:32: error:
    • Could not deduce (Data.Euclidean.Field k)
        arising from a use of ‘degree’
      from the context: IrreducibleMonic k im
        bound by the class declaration for ‘IrreducibleMonic’
        at src/ExtensionField.hs:38:24-39
      Possible fix:
        add (Data.Euclidean.Field k) to the context of
          the class declaration for ‘IrreducibleMonic’
    • In the first argument of ‘(.)’, namely ‘degree’
      In the second argument of ‘(.)’, namely ‘degree . split’
      In the second argument of ‘(.)’, namely
        ‘fromIntegral . degree . split’
   |
44 |   deg' = pred . fromIntegral . degree . split
   |                                ^^^^^^

/Users/dan/scratch/galois-field-0.4.1/src/ExtensionField.hs:75:23: error:
    • Could not deduce (Data.Euclidean.Field k)
        arising from a use of ‘rem’
      from the context: IrreducibleMonic k im
        bound by the instance declaration at src/ExtensionField.hs:72:10-59
      Possible fix:
        add (Data.Euclidean.Field k) to the context of
          the instance declaration
    • In the first argument of ‘EF’, namely
        ‘(rem (times x y) (split (witness :: ExtensionField k im)))’
      In the expression:
        EF (rem (times x y) (split (witness :: ExtensionField k im)))
      In an equation for ‘*’:
          EF x * EF y
            = EF (rem (times x y) (split (witness :: ExtensionField k im)))
   |
75 |   EF x * EF y   = EF (rem (times x y) (split (witness :: ExtensionField k im)))
   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/Users/dan/scratch/galois-field-0.4.1/src/ExtensionField.hs:159:21: error:
    • Could not deduce (Data.Euclidean.Field k)
        arising from a use of ‘rem’
      from the context: IrreducibleMonic k im
        bound by the type signature for:
                   toField :: forall k im.
                              IrreducibleMonic k im =>
                              [k] -> ExtensionField k im
        at src/ExtensionField.hs:158:1-76
      Possible fix:
        add (Data.Euclidean.Field k) to the context of
          the type signature for:
            toField :: forall k im.
                       IrreducibleMonic k im =>
                       [k] -> ExtensionField k im
    • In the first argument of ‘flip’, namely ‘rem’
      In the first argument of ‘(.)’, namely
        ‘flip rem (split (witness :: ExtensionField k im))’
      In the second argument of ‘(.)’, namely
        ‘flip rem (split (witness :: ExtensionField k im))
           . toPoly . fromList’
    |
159 | toField = EF . flip rem (split (witness :: ExtensionField k im)) . toPoly . fromList
    |                     ^^^

/Users/dan/scratch/galois-field-0.4.1/src/ExtensionField.hs:191:31: error:
    • Could not deduce (Data.Euclidean.Field k)
        arising from a use of ‘quot’
      from the context: GaloisField k
        bound by the type signature for:
                   polyGCD :: forall k.
                              GaloisField k =>
                              VPoly k -> VPoly k -> (VPoly k, VPoly k)
        at src/ExtensionField.hs:186:1-79
      Possible fix:
        add (Data.Euclidean.Field k) to the context of
          the type signature for:
            polyGCD :: forall k.
                       GaloisField k =>
                       VPoly k -> VPoly k -> (VPoly k, VPoly k)
    • In the expression: quot r r'
      In the expression:
        case quot r r' of {
          q -> polyGCD' s' (s - times q s') r' (r - times q r') }
      In an equation for ‘polyGCD'’:
          polyGCD' s s' r r'
            = case quot r r' of {
                q -> polyGCD' s' (s - times q s') r' (r - times q r') }
    |
191 |     polyGCD' s s' r r' = case quot r r' of
    |                               ^^^^^^^^^
Multramate commented 4 years ago

It seems like poly-0.3.2.0 had an unexpected change in the Euclidean (Poly v a) class constraints, so it is advisable to use this version with poly-0.3.1.0 or earlier.

sdiehl commented 4 years ago

Going to mark this as closed. The latest library should build fine on Hackage.

sumo commented 4 years ago

Same issue in cabal new-build with latest hackage snapshot. Fix for cabal is to add a constraint in cabal.project(.local) of semirings == 0.4.2.

Permanent fix would be to add this constraint to package.yaml, but it would impact pairing-0.4.2 as well as it is tied to galois-field-0.4.0.