I have a class that imposes a restriction KnownNat:
class KnownNat (Card a) => HasFin a where
type Card a :: Nat
...
And I have instances of this class for several basic types of "building block":
instance HasFin () where
type Card () = 1
...
instance HasFin Bool where
type Card Bool = 2
...
I plan to build many “composite” types from these types of building blocks using amounts and products. Currently, I have to explicitly write a compound constraint KnownNatwhen I instantiate HasFinfor one of these composite types:
instance (HasFin a, HasFin b, KnownNat (Card a + Card b)) => HasFin (Either a b) where
type Card (Either a b) = Card a + Card b
...
I would really like not to write:, KnownNat (Card a + Card b)in the code above.
Is there any type checking plugin that can automatically extrapolate from (HasFin a, HasFin b) =>to (KnownNat (Card a + Card b)) =>?
, ?