Skip to content

Commit

Permalink
Use TypeApplications uniformly in magic* definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanGlScott committed May 12, 2024
1 parent c608582 commit f7220fe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Data/Constraint/Nat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ magicNNN :: forall n m o. (Nat.Natural -> Nat.Natural -> Nat.Natural) -> (KnownN
#if MIN_VERSION_base(4,18,0)
magicNNN f = Sub $ withKnownNat @o (unsafeSNat (natVal (Proxy @n) `f` natVal (Proxy @m))) Dict
#else
magicNNN f = Sub $ unsafeCoerce (Magic Dict) (natVal (Proxy :: Proxy n) `f` natVal (Proxy :: Proxy m))
magicNNN f = Sub $ unsafeCoerce (Magic Dict) (natVal (Proxy @n) `f` natVal (Proxy @m))
#endif

magicNN :: forall n m. (Nat.Natural -> Nat.Natural) -> KnownNat n :- KnownNat m
Expand Down
6 changes: 3 additions & 3 deletions src/Data/Constraint/Symbol.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,21 @@ magicNSS :: forall n m o. (Int -> String -> String) -> (KnownNat n, KnownSymbol
#if MIN_VERSION_base(4,18,0)
magicNSS f = Sub $ withKnownSymbol (unsafeSSymbol @o (fromIntegral (natVal (Proxy @n)) `f` symbolVal (Proxy @m))) Dict
#else
magicNSS f = Sub $ unsafeCoerce (Magic Dict) (fromIntegral (natVal (Proxy :: Proxy n)) `f` symbolVal (Proxy :: Proxy m))
magicNSS f = Sub $ unsafeCoerce (Magic Dict) (fromIntegral (natVal (Proxy @n)) `f` symbolVal (Proxy @m))
#endif

magicSSS :: forall n m o. (String -> String -> String) -> (KnownSymbol n, KnownSymbol m) :- KnownSymbol o
#if MIN_VERSION_base(4,18,0)
magicSSS f = Sub $ withKnownSymbol (unsafeSSymbol @o (symbolVal (Proxy @n) `f` symbolVal (Proxy @m))) Dict
#else
magicSSS f = Sub $ unsafeCoerce (Magic Dict) (symbolVal (Proxy :: Proxy n) `f` symbolVal (Proxy :: Proxy m))
magicSSS f = Sub $ unsafeCoerce (Magic Dict) (symbolVal (Proxy @n) `f` symbolVal (Proxy @m))
#endif

magicSN :: forall a n. (String -> Int) -> KnownSymbol a :- KnownNat n
#if MIN_VERSION_base(4,18,0)
magicSN f = Sub $ TN.withKnownNat (unsafeSNat @n (fromIntegral (f (symbolVal (Proxy :: Proxy a))))) Dict
#else
magicSN f = Sub $ unsafeCoerce (Magic Dict) (toInteger (f (symbolVal (Proxy :: Proxy a))))
magicSN f = Sub $ unsafeCoerce (Magic Dict) (toInteger (f (symbolVal (Proxy @a))))
#endif

-- operations
Expand Down

0 comments on commit f7220fe

Please sign in to comment.