Skip to content

Instantly share code, notes, and snippets.

@danidiaz
Last active February 8, 2026 21:14
Show Gist options
  • Select an option

  • Save danidiaz/257bac0a6a0fedc57a8c1cc108d1b9fc to your computer and use it in GitHub Desktop.

Select an option

Save danidiaz/257bac0a6a0fedc57a8c1cc108d1b9fc to your computer and use it in GitHub Desktop.
{-# LANGUAGE GHC2024 #-}
{-# OPTIONS_GHC -Wincomplete-patterns #-}
module Main where
import Data.Kind
import GHC.Exts
import Data.Void
-- Unlifted types
--
type Brancho :: Type -> Type
data Brancho e =
MkBrancho !e
| MkAnotherBrancho Int
deriving Show
branchy1 :: Brancho ()
branchy1 = MkAnotherBrancho 0
branchy2 :: Brancho Void
branchy2 = MkAnotherBrancho 0
main :: IO ()
main = do
case branchy1 of
MkBrancho () -> putStrLn "foo"
MkAnotherBrancho _ -> putStrLn "foo"
case branchy2 of
-- compiler is smart enough to know one branch is impossible
MkAnotherBrancho _ -> putStrLn "foo"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment