disambiguate isEmpty and isStackEmpty

This commit is contained in:
Rowan Torbitzky-Lane 2025-02-07 14:46:18 -06:00
parent ad4b7a2341
commit 0b280af591
15 changed files with 39 additions and 39 deletions

View File

@ -7,7 +7,7 @@
- [X] Implement all functions as seen in the specification - [X] Implement all functions as seen in the specification
- [ ] Implement Linear Algebra functions as specified in the previous papers - [ ] Implement Linear Algebra functions as specified in the previous papers
- [X] Add a function to sort a vector forward and backwards - [X] Add a function to sort a vector forward and backwards
- [ ] Disambiguate isEmpty and stackIsEmpty - [X] Disambiguate isEmpty and stackIsEmpty
- [X] Rename Logical to Bool - [X] Rename Logical to Bool
- [X] Make int yank, shove, yankdup, and shovedup generic - [X] Make int yank, shove, yankdup, and shovedup generic
- [ ] Write hackage documentation for each function - [ ] Write hackage documentation for each function

View File

@ -70,7 +70,7 @@ allIntInstructions = map StateFunc [
(instructionIntYank, "instructionIntYank"), (instructionIntYank, "instructionIntYank"),
(instructionIntYankDup, "instructionIntYankDup"), (instructionIntYankDup, "instructionIntYankDup"),
(instructionIntShove, "instructionIntShove"), (instructionIntShove, "instructionIntShove"),
(instructionIntIsEmpty, "instructionIntIsEmpty"), (instructionIntIsStackEmpty, "instructionIntIsStackEmpty"),
(instructionIntFromChar, "instructionIntFromChar"), (instructionIntFromChar, "instructionIntFromChar"),
(instructionIntFromString, "instructionIntFromString"), (instructionIntFromString, "instructionIntFromString"),
(instructionIntDupItems, "instructionIntDupItems") (instructionIntDupItems, "instructionIntDupItems")
@ -103,7 +103,7 @@ allFloatInstructions = map StateFunc [
(instructionFloatYank, "instructionFloatYank"), (instructionFloatYank, "instructionFloatYank"),
(instructionFloatYankDup, "instructionFloatYankDup"), (instructionFloatYankDup, "instructionFloatYankDup"),
(instructionFloatShove, "instructionFloatShove"), (instructionFloatShove, "instructionFloatShove"),
(instructionFloatIsEmpty, "instructionFloatIsEmpty"), (instructionFloatIsStackEmpty, "instructionFloatIsStackEmpty"),
(instructionFloatFromChar, "instructionFloatFromChar"), (instructionFloatFromChar, "instructionFloatFromChar"),
(instructionFloatFromString, "instructionFloatFromString"), (instructionFloatFromString, "instructionFloatFromString"),
(instructionFloatDupItems, "instructionFloatDupItems") (instructionFloatDupItems, "instructionFloatDupItems")
@ -130,7 +130,7 @@ allBoolInstructions = map StateFunc [
(instructionBoolYankDup, "instructionBoolYankDup"), (instructionBoolYankDup, "instructionBoolYankDup"),
(instructionBoolShove, "instructionBoolShove"), (instructionBoolShove, "instructionBoolShove"),
(instructionBoolShoveDup, "instructionBoolShoveDup"), (instructionBoolShoveDup, "instructionBoolShoveDup"),
(instructionBoolIsEmpty, "instructionBoolIsEmpty"), (instructionBoolIsStackEmpty, "instructionBoolIsStackEmpty"),
(instructionBoolDupItems, "instructionBoolDupItems") (instructionBoolDupItems, "instructionBoolDupItems")
] ]
@ -159,7 +159,7 @@ allCharInstructions = map StateFunc [
(instructionCharYankDup, "instructionCharYankDup"), (instructionCharYankDup, "instructionCharYankDup"),
(instructionCharShove, "instructionCharShove"), (instructionCharShove, "instructionCharShove"),
(instructionCharShoveDup, "instructionCharShoveDup"), (instructionCharShoveDup, "instructionCharShoveDup"),
(instructionCharIsEmpty, "instructionCharIsEmpty"), (instructionCharIsStackEmpty, "instructionCharIsStackEmpty"),
(instructionCharDupItems, "instructionCharDupItems") (instructionCharDupItems, "instructionCharDupItems")
] ]
@ -206,7 +206,7 @@ allCodeInstructions = map StateFunc [
(instructionCodeYankDup, "instructionCodeYankDup"), (instructionCodeYankDup, "instructionCodeYankDup"),
(instructionCodeShove, "instructionCodeShove"), (instructionCodeShove, "instructionCodeShove"),
(instructionCodeShoveDup, "instructionCodeShoveDup"), (instructionCodeShoveDup, "instructionCodeShoveDup"),
(instructionCodeStackIsEmpty, "instructionCodeStackIsEmpty"), (instructionCodeIsStackEmpty, "instructionCodeIsStackEmpty"),
(instructionCodeFromBool, "instructionCodeFromBool"), (instructionCodeFromBool, "instructionCodeFromBool"),
(instructionCodeFromInt, "instructionCodeFromInt"), (instructionCodeFromInt, "instructionCodeFromInt"),
(instructionCodeFromChar, "instructionCodeFromChar"), (instructionCodeFromChar, "instructionCodeFromChar"),
@ -240,7 +240,7 @@ allExecInstructions = map StateFunc [
(instructionExecYankDup, "instructionExecYankDup"), (instructionExecYankDup, "instructionExecYankDup"),
(instructionExecShove, "instructionExecShove"), (instructionExecShove, "instructionExecShove"),
(instructionExecShoveDup, "instructionExecShoveDup"), (instructionExecShoveDup, "instructionExecShoveDup"),
(instructionExecIsEmpty, "instructionExecIsEmpty"), (instructionExecIsStackEmpty, "instructionExecIsStackEmpty"),
(instructionExecDoRange, "instructionExecDoRange"), (instructionExecDoRange, "instructionExecDoRange"),
(instructionExecDoCount, "instructionExecDoCount"), (instructionExecDoCount, "instructionExecDoCount"),
(instructionExecDoTimes, "instructionExecDoTimes"), (instructionExecDoTimes, "instructionExecDoTimes"),
@ -312,7 +312,7 @@ allStringInstructions = map StateFunc [
(instructionStringYankDup, "instructionStringYankDup"), (instructionStringYankDup, "instructionStringYankDup"),
(instructionStringShove, "instructionStringShove"), (instructionStringShove, "instructionStringShove"),
(instructionStringShoveDup, "instructionStringShoveDup"), (instructionStringShoveDup, "instructionStringShoveDup"),
(instructionStringIsEmpty, "instructionStringIsEmpty"), (instructionStringIsStackEmpty, "instructionStringIsStackEmpty"),
(instructionStringSort, "instructionStringSort"), (instructionStringSort, "instructionStringSort"),
(instructionStringSortReverse, "instructionStringSortReverse"), (instructionStringSortReverse, "instructionStringSortReverse"),
(instructionStringDupItems, "instructionStringDupItems"), (instructionStringDupItems, "instructionStringDupItems"),
@ -354,7 +354,7 @@ allVectorIntInstructions = map StateFunc [
(instructionVectorIntYankDup, "instructionVectorIntYankDup"), (instructionVectorIntYankDup, "instructionVectorIntYankDup"),
(instructionVectorIntShove, "instructionVectorIntShove"), (instructionVectorIntShove, "instructionVectorIntShove"),
(instructionVectorIntShoveDup, "instructionVectorIntShoveDup"), (instructionVectorIntShoveDup, "instructionVectorIntShoveDup"),
(instructionVectorIntStackIsEmpty, "instructionVectorIntStackIsEmpty"), (instructionVectorIntIsStackEmpty, "instructionVectorIntIsStackEmpty"),
(instructionVectorIntSort, "instructionVectorIntSort"), (instructionVectorIntSort, "instructionVectorIntSort"),
(instructionVectorIntSortReverse, "instructionVectorIntSortReverse"), (instructionVectorIntSortReverse, "instructionVectorIntSortReverse"),
(instructionVectorIntDupItems, "instructionVectorIntDupItems") (instructionVectorIntDupItems, "instructionVectorIntDupItems")
@ -395,7 +395,7 @@ allVectorFloatInstructions = map StateFunc [
(instructionVectorFloatYankDup, "instructionVectorFloatYankDup"), (instructionVectorFloatYankDup, "instructionVectorFloatYankDup"),
(instructionVectorFloatShove, "instructionVectorFloatShove"), (instructionVectorFloatShove, "instructionVectorFloatShove"),
(instructionVectorFloatShoveDup, "instructionVectorFloatShoveDup"), (instructionVectorFloatShoveDup, "instructionVectorFloatShoveDup"),
(instructionVectorFloatStackIsEmpty, "instructionVectorFloatStackIsEmpty"), (instructionVectorFloatIsStackEmpty, "instructionVectorFloatIsStackEmpty"),
(instructionVectorFloatSort, "instructionVectorFloatSort"), (instructionVectorFloatSort, "instructionVectorFloatSort"),
(instructionVectorFloatSortReverse, "instructionVectorFloatSortReverse"), (instructionVectorFloatSortReverse, "instructionVectorFloatSortReverse"),
(instructionVectorFloatDupItems, "instructionVectorFloatDupItems") (instructionVectorFloatDupItems, "instructionVectorFloatDupItems")
@ -436,7 +436,7 @@ allVectorCharInstructions = map StateFunc [
(instructionVectorCharYankDup, "instructionVectorCharYankDup"), (instructionVectorCharYankDup, "instructionVectorCharYankDup"),
(instructionVectorCharShove, "instructionVectorCharShove"), (instructionVectorCharShove, "instructionVectorCharShove"),
(instructionVectorCharShoveDup, "instructionVectorCharShoveDup"), (instructionVectorCharShoveDup, "instructionVectorCharShoveDup"),
(instructionVectorCharStackIsEmpty, "instructionVectorCharStackIsEmpty"), (instructionVectorCharIsStackEmpty, "instructionVectorCharIsStackEmpty"),
(instructionVectorCharSort, "instructionVectorCharSort"), (instructionVectorCharSort, "instructionVectorCharSort"),
(instructionVectorCharSortReverse, "instructionVectorCharSortReverse"), (instructionVectorCharSortReverse, "instructionVectorCharSortReverse"),
(instructionVectorCharDupItems, "instructionVectorCharDupItems") (instructionVectorCharDupItems, "instructionVectorCharDupItems")
@ -477,7 +477,7 @@ allVectorStringInstructions = map StateFunc [
(instructionVectorStringYankDup, "instructionVectorStringYankDup"), (instructionVectorStringYankDup, "instructionVectorStringYankDup"),
(instructionVectorStringShove, "instructionVectorStringShove"), (instructionVectorStringShove, "instructionVectorStringShove"),
(instructionVectorStringShoveDup, "instructionVectorStringShoveDup"), (instructionVectorStringShoveDup, "instructionVectorStringShoveDup"),
(instructionVectorStringStackIsEmpty, "instructionVectorStringStackIsEmpty"), (instructionVectorStringIsStackEmpty, "instructionVectorStringIsStackEmpty"),
(instructionVectorStringSort, "instructionVectorStringSort"), (instructionVectorStringSort, "instructionVectorStringSort"),
(instructionVectorStringSortReverse, "instructionVectorStringSortReverse"), (instructionVectorStringSortReverse, "instructionVectorStringSortReverse"),
(instructionVectorStringDupItems, "instructionVectorStringDupItems") (instructionVectorStringDupItems, "instructionVectorStringDupItems")
@ -518,7 +518,7 @@ allVectorBoolInstructions = map StateFunc [
(instructionVectorBoolYankDup, "instructionVectorBoolYankDup"), (instructionVectorBoolYankDup, "instructionVectorBoolYankDup"),
(instructionVectorBoolShove, "instructionVectorBoolShove"), (instructionVectorBoolShove, "instructionVectorBoolShove"),
(instructionVectorBoolShoveDup, "instructionVectorBoolShoveDup"), (instructionVectorBoolShoveDup, "instructionVectorBoolShoveDup"),
(instructionVectorBoolStackIsEmpty, "instructionVectorBoolStackIsEmpty"), (instructionVectorBoolIsStackEmpty, "instructionVectorBoolIsStackEmpty"),
(instructionVectorBoolSort, "instructionVectorBoolSort"), (instructionVectorBoolSort, "instructionVectorBoolSort"),
(instructionVectorBoolSortReverse, "instructionVectorBoolSortReverse"), (instructionVectorBoolSortReverse, "instructionVectorBoolSortReverse"),
(instructionVectorBoolDupItems, "instructionVectorBoolDupItems") (instructionVectorBoolDupItems, "instructionVectorBoolDupItems")

View File

@ -75,8 +75,8 @@ instructionBoolShove state = instructionShove state bool
instructionBoolShoveDup :: State -> State instructionBoolShoveDup :: State -> State
instructionBoolShoveDup state = instructionShoveDup state bool instructionBoolShoveDup state = instructionShoveDup state bool
instructionBoolIsEmpty :: State -> State instructionBoolIsStackEmpty :: State -> State
instructionBoolIsEmpty state = instructionIsEmpty state bool instructionBoolIsStackEmpty state = instructionIsStackEmpty state bool
instructionBoolDupItems :: State -> State instructionBoolDupItems :: State -> State
instructionBoolDupItems = instructionDupItems bool instructionBoolDupItems = instructionDupItems bool

View File

@ -79,8 +79,8 @@ instructionCharYank state = instructionYank state char
instructionCharYankDup :: State -> State instructionCharYankDup :: State -> State
instructionCharYankDup state = instructionYankDup state char instructionCharYankDup state = instructionYankDup state char
instructionCharIsEmpty :: State -> State instructionCharIsStackEmpty :: State -> State
instructionCharIsEmpty state = instructionIsEmpty state char instructionCharIsStackEmpty state = instructionIsStackEmpty state char
instructionCharShove :: State -> State instructionCharShove :: State -> State
instructionCharShove state = instructionShove state char instructionCharShove state = instructionShove state char

View File

@ -294,8 +294,8 @@ instructionCodeYank state = instructionYank state code
instructionCodeYankDup :: State -> State instructionCodeYankDup :: State -> State
instructionCodeYankDup state = instructionYankDup state code instructionCodeYankDup state = instructionYankDup state code
instructionCodeStackIsEmpty :: State -> State instructionCodeIsStackEmpty :: State -> State
instructionCodeStackIsEmpty state = instructionIsEmpty state code instructionCodeIsStackEmpty state = instructionIsStackEmpty state code
instructionCodeShove :: State -> State instructionCodeShove :: State -> State
instructionCodeShove state = instructionShove state code instructionCodeShove state = instructionShove state code

View File

@ -47,8 +47,8 @@ instructionExecShove state = instructionShove state exec
instructionExecShoveDup :: State -> State instructionExecShoveDup :: State -> State
instructionExecShoveDup state = instructionShoveDup state exec instructionExecShoveDup state = instructionShoveDup state exec
instructionExecIsEmpty :: State -> State instructionExecIsStackEmpty :: State -> State
instructionExecIsEmpty state = instructionIsEmpty state exec instructionExecIsStackEmpty state = instructionIsStackEmpty state exec
execDoRange :: Gene execDoRange :: Gene
execDoRange = StateFunc (instructionExecDoRange, "instructionExecDoRange") execDoRange = StateFunc (instructionExecDoRange, "instructionExecDoRange")

View File

@ -112,8 +112,8 @@ instructionFloatShoveDup state = instructionShoveDup state float
instructionFloatShove :: State -> State instructionFloatShove :: State -> State
instructionFloatShove state = instructionShove state float instructionFloatShove state = instructionShove state float
instructionFloatIsEmpty :: State -> State instructionFloatIsStackEmpty :: State -> State
instructionFloatIsEmpty state = instructionIsEmpty state float instructionFloatIsStackEmpty state = instructionIsStackEmpty state float
instructionFloatSin :: State -> State instructionFloatSin :: State -> State
instructionFloatSin state@(State {_float = f1 : fs}) = state {_float = sin f1 : fs} instructionFloatSin state@(State {_float = f1 : fs}) = state {_float = sin f1 : fs}

View File

@ -96,8 +96,8 @@ instructionDup state accessor =
instructionPop :: State -> Lens' State [a] -> State instructionPop :: State -> Lens' State [a] -> State
instructionPop state accessor = state & accessor .~ drop 1 (view accessor state) instructionPop state accessor = state & accessor .~ drop 1 (view accessor state)
instructionIsEmpty :: State -> Lens' State [a] -> State instructionIsStackEmpty :: State -> Lens' State [a] -> State
instructionIsEmpty state@(State {_bool = bs}) accessor = state{_bool = null (view accessor state) : bs} instructionIsStackEmpty state@(State {_bool = bs}) accessor = state{_bool = null (view accessor state) : bs}
-- instructionPop :: State -> Lens' State [a] -> State -- instructionPop :: State -> Lens' State [a] -> State
-- instructionPop state accessor = if notEmptyStack state accessor then instructionPop state accessor else state -- instructionPop state accessor = if notEmptyStack state accessor then instructionPop state accessor else state

View File

@ -112,8 +112,8 @@ instructionIntShove state = instructionShove state int
instructionIntShoveDup :: State -> State instructionIntShoveDup :: State -> State
instructionIntShoveDup state = instructionShoveDup state int instructionIntShoveDup state = instructionShoveDup state int
instructionIntIsEmpty :: State -> State instructionIntIsStackEmpty :: State -> State
instructionIntIsEmpty state = instructionIsEmpty state int instructionIntIsStackEmpty state = instructionIsStackEmpty state int
instructionIntDupItems :: State -> State instructionIntDupItems :: State -> State
instructionIntDupItems = instructionDupItems int instructionIntDupItems = instructionDupItems int

View File

@ -224,8 +224,8 @@ instructionStringYank state = instructionYank state string
instructionStringYankDup :: State -> State instructionStringYankDup :: State -> State
instructionStringYankDup state = instructionYankDup state string instructionStringYankDup state = instructionYankDup state string
instructionStringIsEmpty :: State -> State instructionStringIsStackEmpty :: State -> State
instructionStringIsEmpty state = instructionIsEmpty state string instructionStringIsStackEmpty state = instructionIsStackEmpty state string
instructionStringShove :: State -> State instructionStringShove :: State -> State
instructionStringShove state = instructionShove state string instructionStringShove state = instructionShove state string

View File

@ -96,8 +96,8 @@ instructionVectorBoolYank state = instructionYank state vectorBool
instructionVectorBoolYankDup :: State -> State instructionVectorBoolYankDup :: State -> State
instructionVectorBoolYankDup state = instructionYankDup state vectorBool instructionVectorBoolYankDup state = instructionYankDup state vectorBool
instructionVectorBoolStackIsEmpty :: State -> State instructionVectorBoolIsStackEmpty :: State -> State
instructionVectorBoolStackIsEmpty state = instructionIsEmpty state vectorBool instructionVectorBoolIsStackEmpty state = instructionIsStackEmpty state vectorBool
instructionVectorBoolShove :: State -> State instructionVectorBoolShove :: State -> State
instructionVectorBoolShove state = instructionShove state vectorBool instructionVectorBoolShove state = instructionShove state vectorBool

View File

@ -96,8 +96,8 @@ instructionVectorCharYank state = instructionYank state vectorChar
instructionVectorCharYankDup :: State -> State instructionVectorCharYankDup :: State -> State
instructionVectorCharYankDup state = instructionYankDup state vectorChar instructionVectorCharYankDup state = instructionYankDup state vectorChar
instructionVectorCharStackIsEmpty :: State -> State instructionVectorCharIsStackEmpty :: State -> State
instructionVectorCharStackIsEmpty state = instructionIsEmpty state vectorChar instructionVectorCharIsStackEmpty state = instructionIsStackEmpty state vectorChar
instructionVectorCharShove :: State -> State instructionVectorCharShove :: State -> State
instructionVectorCharShove state = instructionShove state vectorChar instructionVectorCharShove state = instructionShove state vectorChar

View File

@ -96,8 +96,8 @@ instructionVectorFloatYank state = instructionYank state vectorFloat
instructionVectorFloatYankDup :: State -> State instructionVectorFloatYankDup :: State -> State
instructionVectorFloatYankDup state = instructionYankDup state vectorFloat instructionVectorFloatYankDup state = instructionYankDup state vectorFloat
instructionVectorFloatStackIsEmpty :: State -> State instructionVectorFloatIsStackEmpty :: State -> State
instructionVectorFloatStackIsEmpty state = instructionIsEmpty state vectorFloat instructionVectorFloatIsStackEmpty state = instructionIsStackEmpty state vectorFloat
instructionVectorFloatShove :: State -> State instructionVectorFloatShove :: State -> State
instructionVectorFloatShove state = instructionShove state vectorFloat instructionVectorFloatShove state = instructionShove state vectorFloat

View File

@ -96,8 +96,8 @@ instructionVectorIntYank state = instructionYank state vectorChar
instructionVectorIntYankDup :: State -> State instructionVectorIntYankDup :: State -> State
instructionVectorIntYankDup state = instructionYankDup state vectorChar instructionVectorIntYankDup state = instructionYankDup state vectorChar
instructionVectorIntStackIsEmpty :: State -> State instructionVectorIntIsStackEmpty :: State -> State
instructionVectorIntStackIsEmpty state = instructionIsEmpty state vectorChar instructionVectorIntIsStackEmpty state = instructionIsStackEmpty state vectorChar
instructionVectorIntShove :: State -> State instructionVectorIntShove :: State -> State
instructionVectorIntShove state = instructionShove state vectorChar instructionVectorIntShove state = instructionShove state vectorChar

View File

@ -96,8 +96,8 @@ instructionVectorStringYank state = instructionYank state vectorString
instructionVectorStringYankDup :: State -> State instructionVectorStringYankDup :: State -> State
instructionVectorStringYankDup state = instructionYankDup state vectorString instructionVectorStringYankDup state = instructionYankDup state vectorString
instructionVectorStringStackIsEmpty :: State -> State instructionVectorStringIsStackEmpty :: State -> State
instructionVectorStringStackIsEmpty state = instructionIsEmpty state vectorString instructionVectorStringIsStackEmpty state = instructionIsStackEmpty state vectorString
instructionVectorStringShove :: State -> State instructionVectorStringShove :: State -> State
instructionVectorStringShove state = instructionShove state vectorString instructionVectorStringShove state = instructionShove state vectorString