Permalink
Browse files

[ADD] Haskell support

Added the Haskell bash script to compile and run.
Added a cleanup phase to remove all outputed files from
compiling/running, mainly as I don't know of any force
compile setting for ghc.
  • Loading branch information...
1 parent 5f34d56 commit 781a6fd57d8fd3ba6bcd4d107682af548f5ca8e6 @nathanrosspowell committed Jan 15, 2012
Showing with 23 additions and 2 deletions.
  1. +1 −0 README.markdown
  2. +1 −0 source/haskell/0001/0001.hs
  3. +4 −0 testing/cleanup.bash
  4. +5 −0 testing/haskell.bash
  5. +12 −2 testing/runall.py
View
@@ -6,6 +6,7 @@ and secondly to aid in the learning of new programming languages
## Languages
* C plus plus
+* Haskell
## Executing
This repro is tested against these versions:
@@ -0,0 +1 @@
+main = print 233168
View
@@ -0,0 +1,4 @@
+#!/bin/bash
+pushd $1 1>/dev/null
+ls * | grep -v $2 | xargs rm -rf 1>/dev/null
+popd 1>/dev/null
View
@@ -0,0 +1,5 @@
+#!/bin/bash
+pushd $1 1>/dev/null
+ghc -O $2 1>/dev/null
+./a.out
+popd 1>/dev/null
View
@@ -76,6 +76,7 @@ class Execute:
# Bash format.
bashFormat = "bash %s.bash %s"
answer = "%.4d.txt"
+ cleanUp = "bash %s/cleanup.bash %s"
def __init__( self, folders, language, problemNumber, problemPath, answer ):
self.folders = folders
@@ -90,19 +91,28 @@ def run( self ):
startTime = time()
status, output = commands.getstatusoutput( self.cmd )
endTime = time()
- print "problem:", self.problemNumber, "",
+ print "Problem:", self.problemNumber, "",
if status == 0 and output.strip() == self.answer:
print "Complete:", endTime - startTime
else:
print "Error", status, output, self.answer, self.language
-
+ args = "%s %s" % os.path.split( self.problemPath )
+ os.system( self.cleanUp % ( self.folders.path, args ) )
+
class ExecuteCpp( Execute ):
def createCmd( self ):
folder, fileName = os.path.split( self.problemPath )
args = "%s %s" % ( folder, self.problemPath )
bash = os.path.join( self.folders.path, self.language )
self.cmd = self.bashFormat % ( bash, args )
+class ExecuteHaskell( Execute ):
+ def createCmd( self ):
+ folder, fileName = os.path.split( self.problemPath )
+ args = "%s %s %.4d.o" % ( folder, self.problemPath, self.problemNumber )
+ bash = os.path.join( self.folders.path, self.language )
+ self.cmd = self.bashFormat % ( bash, args )
+
def createExecInstance( folders, **kwargs ):
className = eval( "Execute%s" % ( kwargs[ "language" ].title(), ) )
return className( folders, **kwargs )

0 comments on commit 781a6fd

Please sign in to comment.