Skip to content

Instantly share code, notes, and snippets.

@adamgundry
Created January 26, 2024 18:22
Show Gist options
  • Save adamgundry/5446f390ee84254c43a0425e821dc930 to your computer and use it in GitHub Desktop.
Save adamgundry/5446f390ee84254c43a0425e821dc930 to your computer and use it in GitHub Desktop.
Haskell program to test whether ScopedTypeVariables is enabled
{-# LANGUAGE GHC2021, NoScopedTypeVariables, RequiredTypeArguments, AllowAmbiguousTypes #-}
import Data.Proxy
hasScopedTypeVariables :: Bool
hasScopedTypeVariables = f Char
f :: forall a -> C a => Bool
f a = g @Int
where
g :: forall a . C a => Bool
g = thing (Proxy @a) -- Refers to the inner a iff ScopedTypeVariables is on
class C a where
thing :: Proxy a -> Bool
instance C Int where
thing _ = True
instance C Char where
thing _ = False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment