Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not deduce KnownNat (F ((2 * a) + a) b + (2 * F (a + (2 * a)) b)) from KnownNat (F (a * 3) b * 3) #47

Open
christiaanb opened this issue Apr 8, 2020 · 0 comments

Comments

@christiaanb
Copy link
Member

This happens with:

type family F (a :: Nat) (b :: Nat) :: Nat

proxyEq5
  :: forall a b
   . KnownNat (F (a * 3) b * 3)
  => Proxy a
  -> Proxy b
  -> Proxy (3 * F (3 * a) b)
proxyEq5 = theProxy
 where
  theProxy
    :: forall a b
     . KnownNat (F (2 * a + a) b + (2 * F (a + 2 * a) b))
    => Proxy a
    -> Proxy b
    -> Proxy (3 * F (3 * a) b)
  theProxy _ _ = Proxy

The issue seems to be with http://hackage.haskell.org/package/ghc-tcplugins-extra-0.4/docs/GHC-TcPluginM-Extra.html#v:flattenGivens

because looking at givens + flattened givens I see:

  [[G] $dKnownNat_aCr3 {0}:: KnownNat fsk_aCre[fsk:1] (CDictCan),
   [G] co_aCrd {0}:: F fsk_aCra[fsk:1] b_aCr1[sk:1]
                     GHC.Prim.~# fsk_aCrc[fsk:1] (CFunEqCan),
   [G] co_aCrb {0}:: (a_aCr0[sk:1] * 3)
                     GHC.Prim.~# fsk_aCra[fsk:1] (CFunEqCan),
   [G] co_aCrf {0}:: (fsk_aCrc[fsk:1] * 3)
                     GHC.Prim.~# fsk_aCre[fsk:1] (CFunEqCan),
   [G] $dKnownNat_aCr3 {0}:: KnownNat
                               (F fsk_aCra[fsk:1] b_aCr1[sk:1] * 3) (CDictCan),
   [G] co_aCrd {0}:: F (a_aCr0[sk:1] * 3) b_aCr1[sk:1]
                     GHC.Prim.~# F (a_aCr0[sk:1] * 3) b_aCr1[sk:1] (CFunEqCan),
   [G] co_aCrb {0}:: (a_aCr0[sk:1] * 3)
                     GHC.Prim.~# (a_aCr0[sk:1] * 3) (CFunEqCan),
   [G] co_aCrf {0}:: (F (a_aCr0[sk:1] * 3) b_aCr1[sk:1] * 3)
                     GHC.Prim.~# (F fsk_aCra[fsk:1] b_aCr1[sk:1] * 3) (CFunEqCan)]

where the important given is the flattened:

[G] $dKnownNat_aCr3 {0}:: KnownNat
                               (F fsk_aCra[fsk:1] b_aCr1[sk:1] * 3) (CDictCan),

where fsk_aCra[fsk:1] hasn't been fully expanded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant