You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE NoStarIsType #-}
{-# OPTIONS_GHC -fplugin GHC.TypeLits.KnownNat.Solver #-}
moduleTestwhereimportData.ConstraintimportGHC.TypeLitsimportUnsafe.Coercef::forall (m::Nat).SNatm->SNat (2*m+1)
f SNat=SNatg::foralln. (1<=n, n `Mod` 2~1) =>SNatn->SNatn
g s@SNat|Dict<- divOdd @n= f $SNat@((n-1) `Div` 2)
-- evidence that n mod 2 == 1 implies 2 * ((n - 1) div 2) + 1 == ndivOdd::foralln. (n `Mod` 2~1, 1<=n) =>Dict ((2*Div (n-1) 2) +1~n)
divOdd = unsafeCoerce (Dict::Dict (0~0))
does not type check returning
• Cannot satisfy: 1 <= n
• In the second argument of ‘($)’, namely ‘SNat @((n - 1) `Div` 2)’
In the expression: f $ SNat @((n - 1) `Div` 2)
In an equation for ‘g’:
g s@SNat | Dict <- divOdd @n = f $ SNat @((n - 1) `Div` 2)
|
16 | g s@SNat | Dict <- divOdd @n = f $ SNat @((n - 1) `Div` 2)
|
| ^^^^
However, disabling the plugin and introducing the KnownNat constraints manually works, e.g.,
f::forall (m::Nat).KnownNat ((2*m) +1) =>SNatm->SNat (2*m+1)
f SNat=SNatg::foralln. (KnownNat (Div (n-1) 2), 1<=n, n `Mod` 2~1) =>SNatn->SNatn
g s@SNat|Dict<- divOdd @n= f $SNat@((n-1) `Div` 2)
Note that the reported 1 <= n constraint is obviously given in the type signature, so it seems that it get's lost when the plugin is on.
The text was updated successfully, but these errors were encountered:
kleinreact
changed the title
Constraint get lost by enabling the plugin
Constraint gets lost by enabling the plugin
Nov 15, 2024
The following example
does not type check returning
However, disabling the plugin and introducing the
KnownNat
constraints manually works, e.g.,Note that the reported
1 <= n
constraint is obviously given in the type signature, so it seems that it get's lost when the plugin is on.The text was updated successfully, but these errors were encountered: