Skip to content

Instantly share code, notes, and snippets.

@appositum
Last active February 9, 2024 20:32
Show Gist options
  • Save appositum/48064937bdead1b757ccb0f02603a057 to your computer and use it in GitHub Desktop.
Save appositum/48064937bdead1b757ccb0f02603a057 to your computer and use it in GitHub Desktop.
Type inequality constraint in Haskell
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
type family TypeEq a b where
TypeEq a a = True
TypeEq a b = False
type a /= b = TypeEq a b ~ False
f :: (a /= b) => (a -> b) -> a -> b
f g a = g a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment