update instructions list/formatting
This commit is contained in:
parent
899aaa93a7
commit
84e5c7b1df
2
Makefile
2
Makefile
@ -15,7 +15,7 @@ test: # Runs unit tests.
|
||||
runghc -i./src/ test/Main.hs
|
||||
|
||||
format: # Formats code using ormolu.
|
||||
ormolu --mode inplace app/*.hs src/*.hs test/*.hs
|
||||
ormolu --mode inplace app/*.hs src/HushGP/*.hs test/*.hs
|
||||
|
||||
hlint: # HLint for lint suggestions.
|
||||
hlint src/*.hs
|
||||
|
2
TODO.md
2
TODO.md
@ -13,7 +13,7 @@
|
||||
- [X] Write haddock documentation for each function
|
||||
- [X] Refactor all functions to take state as the final parameter
|
||||
- [X] Standardize the pattern matching parameter names, such as c1 : cs
|
||||
- [ ] Write unit/quickcheck tests for all of the instructions
|
||||
- [ ] Write unit/quickcheck tests for the generic functions
|
||||
~~[ ] Use template haskell to generate function lists~~
|
||||
- [X] Move utility functions to their own file
|
||||
- [ ] Make add/sub/mult/div/mod instructions generic
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -3,7 +3,6 @@ module HushGP.Instructions.StringInstructions where
|
||||
import HushGP.State
|
||||
import HushGP.Instructions.GenericInstructions
|
||||
import HushGP.Instructions.Utility
|
||||
import Control.Lens
|
||||
|
||||
-- |Concats the top two strings on the string stack and pushes the result.
|
||||
instructionStringConcat :: State -> State
|
||||
@ -221,14 +220,6 @@ instructionStringStripWhitespace :: State -> State
|
||||
instructionStringStripWhitespace state@(State {_string = s1 : ss}) = state{_string = strip s1 : ss}
|
||||
instructionStringStripWhitespace state = state
|
||||
|
||||
-- |Utility Function: Casts a type based on a lens to a string. Pushes the result
|
||||
-- to the string stack.
|
||||
instructionStringFromLens :: Show a => Lens' State [a] -> State -> State
|
||||
instructionStringFromLens accessor state@(State {_string = ss}) =
|
||||
case uncons (view accessor state) of
|
||||
Nothing -> state
|
||||
Just (x1,_) -> state{_string = show x1 : ss}
|
||||
|
||||
-- |Converts the top bool from the bool stack to a string. Pushes the result to
|
||||
-- the string stack.
|
||||
instructionStringFromBool :: State -> State
|
||||
|
@ -247,3 +247,13 @@ lstrip s = case s of
|
||||
-- this is a tad inefficient
|
||||
rstrip :: String -> String
|
||||
rstrip = reverse . lstrip . reverse
|
||||
|
||||
-- string utility
|
||||
|
||||
-- |Utility Function: Casts a type based on a lens to a string. Pushes the result
|
||||
-- to the string stack.
|
||||
instructionStringFromLens :: Show a => Lens' State [a] -> State -> State
|
||||
instructionStringFromLens accessor state@(State {_string = ss}) =
|
||||
case uncons (view accessor state) of
|
||||
Nothing -> state
|
||||
Just (x1,_) -> state{_string = show x1 : ss}
|
||||
|
Loading…
x
Reference in New Issue
Block a user