{-# LANGUAGE ExistentialQuantification #-}
module System.Console.CmdArgs.Test.Util where
import System.Console.CmdArgs.Explicit
import Data.Maybe
import Data.Typeable
failure :: String -> [(String,String)] -> IO()failurexys = putStr$unlines$"":"":"FAILURE":x: [a++": "++b | (a,b) <- ys]
success :: IO()success = putChar'.'-- seq used to obtain better program coveragehpc = seq-- Demo - wrap a demo up hiding the real type of it
data Demo = forall a . Typeable a => Demo (a -> IO()) arunDemo :: Demo -> IO()runDemo (Demofa) = fa-- Question: Is it possible to do this without the Typeable constraint?newDemo :: Typeable a => (a -> IO()) -> Modea -> ModeDemonewDemoact = remap (Demoact) (\(Demofx) -> (coercex, Demof.coerce))
where
coerce :: (Typeable a, Typeable b) =>a -> bcoerce = fromMaybe (error"Type issue in CmdArgs.coerce") .cast