{-# LANGUAGE RankNTypes, TypeFamilies #-}
import Data.Bits
-- Typeclass to emulate Rust's `core::ops::Not`
class Not a where
type Output a :: *
not :: a -> Output a
instance Not Bool where
type Output Bool = Bool
not = Prelude.not
instance Not Int where
type Output Int = Int
not = complement
foo :: (forall t. Not t => (t -> Output t)) -> (Int, Bool)
foo x = (x (4 :: Int), x False)
bar :: Not t => t -> Output t
bar = Main.not
main :: IO ()
main = putStrLn $ show $ foo bar;