module Crypto.Lol.Reflects
( Reflects(..)
) where
import Crypto.Lol.Factored
import Data.Functor.Trans.Tagged
import Data.Proxy
import Data.Reflection
import GHC.TypeLits as TL
class Reflects a i where
value :: Tagged a i
instance (KnownNat a, Integral i) => Reflects (a :: TL.Nat) i where
value = return $ fromIntegral $ natVal (Proxy::Proxy a)
instance (NatC a, Integral i) => Reflects a i where
value = fmap fromIntegral valueNatC
instance (PPow pp, Integral i) => Reflects pp i where
value = fmap fromIntegral valuePPow
instance (Fact m, Integral i) => Reflects m i where
value = fmap fromIntegral valueFact
instance (Reifies rei a) => Reflects (rei :: *) a where
value = tag $ reflect (Proxy::Proxy rei)