Created
September 21, 2025 13:42
-
-
Save qexat/5fa4818f1467f15d05ca95383ed5757e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE AllowAmbiguousTypes #-} | |
| {-# LANGUAGE FunctionalDependencies #-} | |
| {-# LANGUAGE UndecidableSuperClasses #-} | |
| import Data.Kind | |
| class (c a, c b) => SafeCoercible (c :: Type -> Constraint) a b | c a -> b where | |
| safeCoerce :: a -> b | |
| instance SafeCoercible Num Int Float where | |
| safeCoerce = fromIntegral | |
| main = print (safeCoerce @Num (3 :: Int)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment