summaryrefslogtreecommitdiff
path: root/benchmarks/hs/gen-program.hs
blob: 1ecc84d60ec5c12b7e63953a2afdceab5ee28d10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import qualified Data.Graph.Dynamic.Program as Program
import qualified Data.Text.Lazy.IO          as TL
import           System.Environment         (getArgs, getProgName)
import           System.Exit                (exitFailure)
import qualified System.IO                  as IO
import qualified Test.QuickCheck            as QC
import           Text.Read                  (readMaybe)

main :: IO ()
main = do
    progName <- getProgName
    args     <- getArgs
    case args of
        [sizeStr] | Just size <- readMaybe sizeStr -> do
            Program.IntGraphProgram sample <- head <$>
                QC.sample' (QC.resize size QC.arbitrary)
            TL.putStrLn $ Program.encodeProgram Program.encodeInt sample
        _ -> do
            IO.hPutStrLn IO.stderr $ "Usage: " ++ progName ++ " size"
            exitFailure