Created
January 26, 2024 18:22
-
-
Save adamgundry/5446f390ee84254c43a0425e821dc930 to your computer and use it in GitHub Desktop.
Haskell program to test whether ScopedTypeVariables is enabled
This file contains 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 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