From 86fc353738356698d39c33429ca6ceaeaa32bba6 Mon Sep 17 00:00:00 2001 From: Taylor Date: Thu, 16 Jan 2025 13:14:08 -0600 Subject: [PATCH] cabal co-exists beside Makefile --- .gitignore | 1 + Makefile | 17 +++++++++-------- src/.ghci | 1 - src/Main.hs | 5 ----- src/Push.hs | 2 +- tests/.ghci | 3 --- tests/Main.hs | 26 -------------------------- 7 files changed, 11 insertions(+), 44 deletions(-) delete mode 100644 src/Main.hs delete mode 100644 tests/.ghci delete mode 100644 tests/Main.hs diff --git a/.gitignore b/.gitignore index 683c20e..807514f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +dist-* *$py.class **/*.DS_Store **/*__pycache__ diff --git a/Makefile b/Makefile index 1b84f2a..0dea7bb 100644 --- a/Makefile +++ b/Makefile @@ -8,25 +8,26 @@ run: target/Main.out # Runs your compiled main code. ./target/Main.out target/Main.out: src/* - ghc -g -fprof-auto -prof -Wall src/*.hs -o target/Main.out + ghc -g -fprof-auto -prof -Wall app/*.hs src/*.hs -o target/Main.out @rm -f src/*.o src/*.hi -test: tests/*.hs # Runs unit tests. - runghc -i./src/ tests/Main.hs +test: test/*.hs # Runs unit tests. + runghc -i./src/ test/Main.hs format: src/* # Formats code using ormolu. - ormolu --mode inplace src/*.hs tests/*.hs + ormolu --mode inplace app/*.hs src/*.hs test/*.hs hlint: src/*.hs # HLint for lint suggestions. hlint src/*.hs stan: src/*.hs # Stan for more optimization suggestions. - ghc -fwrite-ide-info src/*.hs -o target/temp.out + ghc -fwrite-ide-info app/*.hs src/*.hs -o target/temp.out stan --hiedir src/ - rm -f target/temp.out src/*.hi src/*.o src/*.hie + rm -f target/temp.out src/*.hi src/*.o src/*.hie app/*.o app/*.hi app/*.hie clean: # Cleans up all the generated logfiles and outfiles. @rm -rf *.out *.o *.hi @rm -rf target/* - @rm -rf */*.out */*.o */*.hi - @rm -rf */*/*.out */*/*.o */*/*.hi + @rm -rf */*.out */*.o */*.hi */*.hie + @rm -rf */*/*.out */*/*.o */*/*.hi */*.hie + @rm -rf dist-* diff --git a/src/.ghci b/src/.ghci index 44a0883..96db894 100644 --- a/src/.ghci +++ b/src/.ghci @@ -1,3 +1,2 @@ :set stop :list :set prompt "\ESC[1;34m%s \ESC[0;35mλ>\ESC[m " -:load Main diff --git a/src/Main.hs b/src/Main.hs deleted file mode 100644 index 56457c9..0000000 --- a/src/Main.hs +++ /dev/null @@ -1,5 +0,0 @@ -import GP -import Push - -main :: IO () -main = do pure () diff --git a/src/Push.hs b/src/Push.hs index 3154933..383fb80 100644 --- a/src/Push.hs +++ b/src/Push.hs @@ -1,6 +1,6 @@ module Push where -import qualified Data.Map as Map +import Data.Map qualified as Map -- import Debug.Trace (trace, traceStack) diff --git a/tests/.ghci b/tests/.ghci deleted file mode 100644 index d5be5bc..0000000 --- a/tests/.ghci +++ /dev/null @@ -1,3 +0,0 @@ -:set stop :list -:set prompt "\ESC[1;34m%s \ESC[0;35mλ>\ESC[m " -:load Main ../src/Push ../src/GP diff --git a/tests/Main.hs b/tests/Main.hs deleted file mode 100644 index d101105..0000000 --- a/tests/Main.hs +++ /dev/null @@ -1,26 +0,0 @@ -import Control.Exception (assert) -import GP -import Push - -intTestFunc :: String -> [Int] -> [Gene] -> State -> IO () -intTestFunc name goal genome startState = - let state = loadProgram genome startState - in assert (goal == int (interpretExec state)) putStrLn (name ++ " passed test.") - -main :: IO () -main = do - intTestFunc "instructionIntAdd" [8] [GeneInt 6, GeneInt 2, StateFunc instructionIntAdd] emptyState - intTestFunc "instructionIntSub" [4] [GeneInt 6, GeneInt 2, StateFunc instructionIntSub] emptyState - intTestFunc "instructionIntMul" [12] [GeneInt 6, GeneInt 2, StateFunc instructionIntMul] emptyState - intTestFunc "instructionIntDiv" [3] [GeneInt 6, GeneInt 2, StateFunc instructionIntDiv] emptyState - intTestFunc "instructionExecIf" [6, 5] [GeneBool True, StateFunc instructionExecIf, Block [GeneInt 5, GeneInt 6], Block [GeneInt 7, GeneInt 8]] emptyState - intTestFunc "instructionExecDup" [8] [StateFunc instructionExecDup, GeneInt 4, StateFunc instructionIntAdd] emptyState - intTestFunc "instructionExecDoRange" [12] [GeneInt 2, Block [GeneInt 4, GeneInt 1, StateFunc instructionExecDoRange], StateFunc instructionIntAdd] emptyState - intTestFunc "instructionExecDoCount" [8] [GeneInt 2, Block [GeneInt 4, StateFunc instructionExecDoCount], StateFunc instructionIntAdd] emptyState - intTestFunc "instructionIntAdd" [69, 69, 69, 69, 2] [GeneInt 2, Block [GeneInt 4, StateFunc instructionExecDoTimes], GeneInt 69] emptyState - intTestFunc "instructionExecDoTimes" [70, 70] [GeneBool False, GeneBool True, GeneBool True, StateFunc instructionExecWhile, GeneInt 70] emptyState - intTestFunc "instructionExecWhile" [70, 70, 70] [GeneBool False, GeneBool True, GeneBool True, StateFunc instructionExecDoWhile, GeneInt 70] emptyState - intTestFunc "instructionExecDoWhile" [71] [GeneBool True, StateFunc instructionExecWhen, GeneInt 71] emptyState - - let loadedState = loadProgram [GeneBool False, StateFunc instructionExecWhen, GeneInt 71] emptyState - assert (emptyState == interpretExec loadedState) putStrLn "instructionExecWhen passed test."