cabal co-exists beside Makefile
This commit is contained in:
parent
920ea92cb9
commit
86fc353738
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
dist-*
|
||||
*$py.class
|
||||
**/*.DS_Store
|
||||
**/*__pycache__
|
||||
|
17
Makefile
17
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-*
|
||||
|
@ -1,3 +1,2 @@
|
||||
:set stop :list
|
||||
:set prompt "\ESC[1;34m%s \ESC[0;35mλ>\ESC[m "
|
||||
:load Main
|
||||
|
@ -1,5 +0,0 @@
|
||||
import GP
|
||||
import Push
|
||||
|
||||
main :: IO ()
|
||||
main = do pure ()
|
@ -1,6 +1,6 @@
|
||||
module Push where
|
||||
|
||||
import qualified Data.Map as Map
|
||||
import Data.Map qualified as Map
|
||||
|
||||
-- import Debug.Trace (trace, traceStack)
|
||||
|
||||
|
@ -1,3 +0,0 @@
|
||||
:set stop :list
|
||||
:set prompt "\ESC[1;34m%s \ESC[0;35mλ>\ESC[m "
|
||||
:load Main ../src/Push ../src/GP
|
@ -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."
|
Loading…
x
Reference in New Issue
Block a user