[Haskell-cafe] Infer Nat type from Integer argument

Marcin Mrotek marcin.jan.mrotek at gmail.com
Mon Feb 29 22:11:10 UTC 2016


Have you tried using the package
https://hackage.haskell.org/package/reflection ? It won't directly
help you with:

fromN :: forall n. KnownNat n => Integer -> NatString n

but it does provide a function:

reifyNat :: forall r. Integer -> (forall n. KnownNat n => Proxy n -> r) -> r

which could help you if you'd manage to turn your function inside out,
so that the `n` parameter doesn't escape the callback.

Best regards,
Marcin Mrotek

More information about the Haskell-Cafe mailing list