{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TypeFamilies #-}
data IsStatus = IsRunning | IsFailed
data Status :: IsStatus -> * where
Running :: Status 'IsRunning
Failed :: Status 'IsFailed
data FailureReason = Unknown | PEBKAC deriving (Show)
type family GarbageCollect s :: * where
GarbageCollect 'IsRunning = IO ()
GarbageCollect 'IsFailed = [FailureReason] -> IO ()
garbageCollect :: Status s -> GarbageCollect s
garbageCollect Running = putStrLn "running"
garbageCollect Failed = \reasons -> putStrLn ("failed " ++ show reasons)
main :: IO ()
main = do
garbageCollect Running
garbageCollect Failed [Unknown, PEBKAC]