Skip to content

Regression: Could not deduce ‘((n * 3) + b0) ~ ((3 * (n - 1)) + 1)’ #126

@rowanG077

Description

@rowanG077

Basically the same symptom as #124 (also from bittide):

zeroExtendTimesThree :: forall n. (1 <= n, KnownNat n) => Index n -> Index (n * 3)
zeroExtendTimesThree = truncateB . mul (3 :: Index 4)

Leads to:

src/Bittide/SwitchDemoProcessingElement.hs:24:36: error: [GHC-05617]
    • Could not deduce ‘((n * 3) + b0) ~ ((3 * (n - 1)) + 1)’
      from the context: (1 <= n, KnownNat n)
        bound by the type signature for:
                   zeroExtendTimesThree :: forall (n :: Natural).
                                           (1 <= n, KnownNat n) =>
                                           Index n -> Index (n * 3)
        at src/Bittide/SwitchDemoProcessingElement.hs:23:1-82
      Expected: Index n -> Index ((n * 3) + b0)
        Actual: Index n -> MResult (Index 4) (Index n)
      NB: ‘+’ is a non-injective type family
      The type variable ‘b0’ is ambiguous
    • In the second argument of ‘(.)’, namely ‘mul (3 :: Index 4)’
      In the expression: truncateB . mul (3 :: Index 4)
      In an equation for ‘zeroExtendTimesThree’:
          zeroExtendTimesThree = truncateB . mul (3 :: Index 4)
    • Relevant bindings include
        zeroExtendTimesThree :: Index n -> Index (n * 3)
          (bound at src/Bittide/SwitchDemoProcessingElement.hs:24:1)
   |
24 | zeroExtendTimesThree = truncateB . mul (3 :: Index 4)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions