initial commit

This commit is contained in:
Nicole Dresselhaus 2013-11-14 13:28:05 +01:00
commit cf6a581e9e
12 changed files with 215 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
*.o
*~

6
Setup.lhs Normal file
View File

@ -0,0 +1,6 @@
#!/usr/bin/runhaskell
> module Main where
> import Distribution.Simple
> main :: IO ()
> main = defaultMain

36
dist/build/autogen/Paths_hgraph.hs vendored Normal file
View File

@ -0,0 +1,36 @@
module Paths_hgraph (
version,
getBinDir, getLibDir, getDataDir, getLibexecDir,
getDataFileName, getSysconfDir
) where
import qualified Control.Exception as Exception
import Data.Version (Version(..))
import System.Environment (getEnv)
import Prelude
catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a
catchIO = Exception.catch
version :: Version
version = Version {versionBranch = [0,0,1], versionTags = []}
bindir, libdir, datadir, libexecdir, sysconfdir :: FilePath
bindir = "/home/sdressel/.cabal/bin"
libdir = "/home/sdressel/.cabal/lib/x86_64-linux-ghc-7.6.3/hgraph-0.0.1"
datadir = "/home/sdressel/.cabal/share/x86_64-linux-ghc-7.6.3/hgraph-0.0.1"
libexecdir = "/home/sdressel/.cabal/libexec"
sysconfdir = "/home/sdressel/.cabal/etc"
getBinDir, getLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath
getBinDir = catchIO (getEnv "hgraph_bindir") (\_ -> return bindir)
getLibDir = catchIO (getEnv "hgraph_libdir") (\_ -> return libdir)
getDataDir = catchIO (getEnv "hgraph_datadir") (\_ -> return datadir)
getLibexecDir = catchIO (getEnv "hgraph_libexecdir") (\_ -> return libexecdir)
getSysconfDir = catchIO (getEnv "hgraph_sysconfdir") (\_ -> return sysconfdir)
getDataFileName :: FilePath -> IO FilePath
getDataFileName name = do
dir <- getDataDir
return (dir ++ "/" ++ name)

51
dist/build/autogen/cabal_macros.h vendored Normal file
View File

@ -0,0 +1,51 @@
/* DO NOT EDIT: This file is automatically generated by Cabal */
/* package QuickCheck-2.6 */
#define VERSION_QuickCheck "2.6"
#define MIN_VERSION_QuickCheck(major1,major2,minor) (\
(major1) < 2 || \
(major1) == 2 && (major2) < 6 || \
(major1) == 2 && (major2) == 6 && (minor) <= 0)
/* package Stream-0.4.6.1 */
#define VERSION_Stream "0.4.6.1"
#define MIN_VERSION_Stream(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 4 || \
(major1) == 0 && (major2) == 4 && (minor) <= 6)
/* package base-4.6.0.1 */
#define VERSION_base "4.6.0.1"
#define MIN_VERSION_base(major1,major2,minor) (\
(major1) < 4 || \
(major1) == 4 && (major2) < 6 || \
(major1) == 4 && (major2) == 6 && (minor) <= 0)
/* package bytestring-0.10.0.2 */
#define VERSION_bytestring "0.10.0.2"
#define MIN_VERSION_bytestring(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 10 || \
(major1) == 0 && (major2) == 10 && (minor) <= 0)
/* package ghc-7.6.3 */
#define VERSION_ghc "7.6.3"
#define MIN_VERSION_ghc(major1,major2,minor) (\
(major1) < 7 || \
(major1) == 7 && (major2) < 6 || \
(major1) == 7 && (major2) == 6 && (minor) <= 3)
/* package monad-par-0.3.4.5 */
#define VERSION_monad_par "0.3.4.5"
#define MIN_VERSION_monad_par(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 3 || \
(major1) == 0 && (major2) == 3 && (minor) <= 4)
/* package parallel-3.2.0.3 */
#define VERSION_parallel "3.2.0.3"
#define MIN_VERSION_parallel(major1,major2,minor) (\
(major1) < 3 || \
(major1) == 3 && (major2) < 2 || \
(major1) == 3 && (major2) == 2 && (minor) <= 0)

BIN
dist/build/hgraph/hgraph vendored Executable file

Binary file not shown.

BIN
dist/build/hgraph/hgraph-tmp/Main.hi vendored Normal file

Binary file not shown.

BIN
dist/build/test-hgraph/test-hgraph vendored Executable file

Binary file not shown.

Binary file not shown.

1
dist/package.conf.inplace vendored Normal file
View File

@ -0,0 +1 @@
[]

2
dist/setup-config vendored Normal file

File diff suppressed because one or more lines are too long

24
hgraph.cabal Normal file
View File

@ -0,0 +1,24 @@
name: hgraph
version: 0.0.1
cabal-version: >=1.2
build-type: Simple
license: AllRightsReserved
license-file: ""
description:
data-dir: ""
executable hgraph
build-depends: QuickCheck -any, Stream -any, base -any,
bytestring -any, ghc -any, monad-par -any, parallel -any
main-is: Main.hs
buildable: True
hs-source-dirs: src
test-suite test-hgraph
build-depends: QuickCheck -any, Stream -any, base -any,
bytestring -any, ghc -any, monad-par -any, parallel -any
type: exitcode-stdio-1.0
main-is: Main.hs
buildable: True
cpp-options: -DMAIN_FUNCTION=testMain
hs-source-dirs: src

92
src/Main.hs Normal file
View File

@ -0,0 +1,92 @@
{-# LANGUAGE CPP, TemplateHaskell #-}
-----------------------------------------------------------------------------
--
-- Module : Main
-- Copyright :
-- License : AllRightsReserved
--
-- Maintainer :
-- Stability :
-- Portability :
--
-- |
--
-----------------------------------------------------------------------------
module Main (
main
) where
import Control.Monad (unless)
import Control.Parallel.Strategies
import Data.List
import System.Exit (exitFailure)
import System.Environment
import Test.QuickCheck.All (quickCheckAll)
import qualified Data.ByteString.Lazy.Char8 as B
import Data.ByteString.Lazy.Char8 (ByteString)
import Control.Monad.Par.Scheds.Trace
import qualified Data.Stream as S
import Data.Either (lefts, rights)
import Stream
-- TODO: implement parser!
createGraph :: ByteString -> Either [Int] String
createGraph _ = Left [1,2,3]
graphFolder :: [Either [Int] String] -> (Either [[Int]] String)
graphFolder [] = Right "empty Graph"
graphFolder l = graphFolder' l (Left [[]])
where
graphFolder' :: [Either [Int] String] -> (Either [[Int]] String) -> (Either [[Int]] String)
graphFolder' [] r = r
graphFolder' (a:as) r =
case a of
-- we have an intact [Int]
Left b ->
case graphFolder' as r of
-- append if rest is ok.
Left xs -> Left (b:xs)
-- ooops. Error-String -> Discard result
Right s -> Right s
-- we have an Error-String -> ignore results, append errors if possible
Right s ->
case graphFolder' as r of
Left x -> Right s
Right ss -> Right (ss ++ "\n" ++ s)
concatWith :: String -> String -> String -> String
concatWith d a b = a ++ d ++ b
exeMain = do
args <- getArgs
input <- case args of
["-"] -> B.getContents
[] -> error "Error: No filename or stdinput (-) given."
[file] -> B.readFile file
-- unrefined_graph::[Either [Int] String] - [Int] is Adjacency-Line, String is parse-Error
unrefined_graph <- return $ parMap (rparWith rdeepseq) (createGraph) (B.split '\n' input)
--egraph <- return $ graphFolder unrefined_graph
(graph, log) <- return (lefts unrefined_graph, rights unrefined_graph)
--do stuff with graph
B.putStr $ B.pack (foldl (concatWith "\n") "" log) -- Print output
-- Entry point for unit tests.
testMain = do
allPass <- $quickCheckAll -- Run QuickCheck on all prop_ functions
unless allPass exitFailure
-- This is a clunky, but portable, way to use the same Main module file
-- for both an application and for unit tests.
-- MAIN_FUNCTION is preprocessor macro set to exeMain or testMain.
-- That way we can use the same file for both an application and for tests.
#ifndef MAIN_FUNCTION
#define MAIN_FUNCTION exeMain
#endif
main = MAIN_FUNCTION