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

Can not infer Max 1 n ~ n when given 1 <= n #56

Open
lmbollen opened this issue Aug 5, 2024 · 1 comment
Open

Can not infer Max 1 n ~ n when given 1 <= n #56

lmbollen opened this issue Aug 5, 2024 · 1 comment

Comments

@lmbollen
Copy link

lmbollen commented Aug 5, 2024

Reproducer:

{-# LANGUAGE DataKinds #-}
{-# OPTIONS_GHC -fplugin GHC.TypeLits.Extra.Solver #-}

import GHC.TypeLits
import GHC.TypeLits.Extra
import Data.Proxy

data QQ x where
    QQ :: 1 <= x => Proxy x -> QQ x

f :: QQ x -> Proxy (Max 1 x)
f (QQ z) = z

Produces:

[1 of 2] Compiling Main             ( Test.hs, interpreted )
Test.hs:12:12: error: [GHC-25897]
    • Could not deduce 'Max 1 x ~ x'
      from the context: 1 <= x
        bound by a pattern with constructor:
                   QQ :: forall (x :: Natural). (1 <= x) => Proxy x -> QQ x,
                 in an equation for 'f'
        at Test.hs:12:4-7
      Expected: Proxy (Max 1 x)
        Actual: Proxy x
      'x' is a rigid type variable bound by
        the type signature for:
          f :: forall (x :: Natural). QQ x -> Proxy (Max 1 x)
        at Test.hs:11:1-28
    • In the expression: z
      In an equation for 'f': f (QQ z) = z
    • Relevant bindings include
        z :: Proxy x (bound at Test.hs:12:7)
        f :: QQ x -> Proxy (Max 1 x) (bound at Test.hs:12:1)
   |
12 | f (QQ z) = z
   |            ^
@lmbollen
Copy link
Author

lmbollen commented Aug 5, 2024

Ideally after solving this we'd change https://github.com/clash-lang/clash-compiler/blob/master/clash-prelude/src/Clash/Signal/Internal.hs#L351
to return Max 1 period or similar solution to make sure that DomainPeriod dom is always at least 1 on type level.

lmbollen added a commit to bittide/bittide-hardware that referenced this issue Aug 5, 2024
Do note that we currently retain our local version of `PeriodToCycles`.
This version still has the `Max` types which greatly improves usability.
Related issue: clash-lang/ghc-typelits-extra#56
lmbollen added a commit to bittide/bittide-hardware that referenced this issue Aug 5, 2024
Do note that we currently retain our local version of `PeriodToCycles`.
This version still has the `Max` types which greatly improves usability.
Related issue: clash-lang/ghc-typelits-extra#56
lmbollen added a commit to bittide/bittide-hardware that referenced this issue Aug 5, 2024
Do note that we currently retain our local version of `PeriodToCycles`.
This version still has the `Max` types which greatly improves usability.
Related issue: clash-lang/ghc-typelits-extra#56
lmbollen added a commit to bittide/bittide-hardware that referenced this issue Aug 6, 2024
Do note that we currently retain our local version of `PeriodToCycles`.
This version still has the `Max` types which greatly improves usability.
Related issue: clash-lang/ghc-typelits-extra#56
lmbollen added a commit to bittide/bittide-hardware that referenced this issue Aug 6, 2024
Do note that we currently retain our local version of `PeriodToCycles`.
This version still has the `Max` types which greatly improves usability.
Related issue: clash-lang/ghc-typelits-extra#56
lmbollen added a commit to bittide/bittide-hardware that referenced this issue Aug 6, 2024
Do note that we currently retain our local version of `PeriodToCycles`.
This version still has the `Max` types which greatly improves usability.
Related issue: clash-lang/ghc-typelits-extra#56
lmbollen added a commit to bittide/bittide-hardware that referenced this issue Aug 6, 2024
Do note that we currently retain our local version of `PeriodToCycles`.
This version still has the `Max` types which greatly improves usability.
Related issue: clash-lang/ghc-typelits-extra#56
lmbollen added a commit to bittide/bittide-hardware that referenced this issue Aug 6, 2024
Do note that we currently retain our local version of `PeriodToCycles`.
This version still has the `Max` types which greatly improves usability.
Related issue: clash-lang/ghc-typelits-extra#56
lmbollen added a commit to bittide/bittide-hardware that referenced this issue Aug 6, 2024
Do note that we currently retain our local version of `PeriodToCycles`.
This version still has the `Max` types which greatly improves usability.
Related issue: clash-lang/ghc-typelits-extra#56
martijnbastiaan pushed a commit to bittide/bittide-hardware that referenced this issue Aug 6, 2024
Do note that we currently retain our local version of `PeriodToCycles`.
This version still has the `Max` types which greatly improves usability.
Related issue: clash-lang/ghc-typelits-extra#56
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