Skip to content

Instantly share code, notes, and snippets.

@qexat
Created September 21, 2025 13:42
Show Gist options
  • Select an option

  • Save qexat/5fa4818f1467f15d05ca95383ed5757e to your computer and use it in GitHub Desktop.

Select an option

Save qexat/5fa4818f1467f15d05ca95383ed5757e to your computer and use it in GitHub Desktop.
{-# 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