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

Derive KnownNat a ~ KnownNat (((a - b) + c) + (b - c))) #46

Merged
merged 2 commits into from
Apr 8, 2020

Conversation

martijnbastiaan
Copy link
Member

'normaliseNatEverywhere' would use 'everywhereM' to walk types and
simplify nats anywhere in it. Because 'everywhereM' doesn't
differentiate between type constructors 'normaliseNat' understands
(i.e., -, +, *, ^) it would also run it on every subexpression.
'normaliseNat' would then yield spurious results it wouldn't have,
if only it had seen the bigger picture..

'normaliseNatEverywhere' would use 'everywhereM' to walk types and
simplify nats anywhere in it. Because 'everywhereM' doesn't
differentiate between type constructors 'normaliseNat' understands
(i.e., -, +, *, ^) it would also run it on every subexpression.
'normaliseNat' would then yield spurious results it wouldn't have,
if only it had seen the bigger picture..
Copy link
Member

@christiaanb christiaanb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I think we should file the following as a new issue:

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

as it might be related to http://hackage.haskell.org/package/ghc-tcplugins-extra-0.4/docs/GHC-TcPluginM-Extra.html#v:flattenGivens

Not urgent though

@christiaanb christiaanb merged commit 91d80e6 into master Apr 8, 2020
@christiaanb christiaanb deleted the no-everywhereM branch April 8, 2020 06:53
@christiaanb
Copy link
Member

Filed as #47

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

Successfully merging this pull request may close these issues.

2 participants