There's a number of Haskell modular arithmetic modules that implement type safe modular arithmetic with type annotations. Is it possible to pass in a variable in the type annotation?
For example in the mod module the following works
let x = 4 :: Mod 7
let y = 5 :: Mod 7
print x + y
Is there any way to achieve something similar to the following
let base = 7
let x = 4 :: Mod base
let y = 5 :: Mod base
print x + y
My problem here is that base
is not a type. I'm unsure of the correct way to approach this problem or whether I'm thinking about this in the wrong way for functional languages. Thanks.
Update
In practice base will be the result of some computation I do not know in advance.