cabal co-exists beside Makefile

This commit is contained in:
Taylor 2025-01-16 13:14:08 -06:00
parent 920ea92cb9
commit 86fc353738
7 changed files with 11 additions and 44 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
dist-*
*$py.class
**/*.DS_Store
**/*__pycache__

View File

@ -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-*

View File

@ -1,3 +1,2 @@
:set stop :list
:set prompt "\ESC[1;34m%s \ESC[0;35mλ>\ESC[m "
:load Main

View File

@ -1,5 +0,0 @@
import GP
import Push
main :: IO ()
main = do pure ()

View File

@ -1,6 +1,6 @@
module Push where
import qualified Data.Map as Map
import Data.Map qualified as Map
-- import Debug.Trace (trace, traceStack)

View File

@ -1,3 +0,0 @@
:set stop :list
:set prompt "\ESC[1;34m%s \ESC[0;35mλ>\ESC[m "
:load Main ../src/Push ../src/GP

View File

@ -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."