Skip to content

Instantly share code, notes, and snippets.

View adamgundry's full-sized avatar

Adam Gundry adamgundry

View GitHub Profile
{-# LANGUAGE DataKinds, PolyKinds, StandaloneKindSignatures, TypeFamilies, UndecidableInstances #-}
import GHC.TypeLits
import Data.Kind
-- This is the proposed API for Warning/WarningBin
type Warning :: Symbol -> WarningBin -> ErrorMessage -> Constraint
class Warning flag bin msg
@adamgundry
adamgundry / SafeByteStringLiterals.hs
Created December 10, 2023 21:31
OverloadedLabels for checked ByteString literals
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
import qualified Data.ByteString.Char8 as BS
import Data.Kind
import Data.Proxy
import GHC.OverloadedLabels
@adamgundry
adamgundry / DetectScopedTypeVariables.hs
Created January 26, 2024 18:22
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