From 9ee668daad683292a9a3e61a8084b078ee292c05 Mon Sep 17 00:00:00 2001 From: Adam Wick Date: Sun, 12 Apr 2020 19:53:42 -0700 Subject: [PATCH] Replace Variable Strings with Words. --- generation/src/Karatsuba.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/generation/src/Karatsuba.hs b/generation/src/Karatsuba.hs index bbabda5..0aab1aa 100644 --- a/generation/src/Karatsuba.hs +++ b/generation/src/Karatsuba.hs @@ -53,7 +53,7 @@ generateInstructions numdigits = -- -- ----------------------------------------------------------------------------- -newtype Variable = V String +newtype Variable = V Word deriving (Eq, Ord, Show) -- these are in Intel form, as I was corrupted young, so the first argument @@ -136,9 +136,9 @@ replaceVar ls (from, to) = map replace ls -- -- ----------------------------------------------------------------------------- -newtype Math a = Math { unMath :: RWS () [Instruction] Integer a } +newtype Math a = Math { unMath :: RWS () [Instruction] Word a } deriving (Applicative, Functor, Monad, - MonadState Integer, + MonadState Word, MonadWriter [Instruction]) instance MonadFail Math where @@ -150,7 +150,7 @@ emit instr = tell [instr] newVariable :: Math Variable newVariable = do x <- state (\ i -> (i, i + 1)) - return (V (show x)) + return (V x) runMath :: Math a -> (a, [Instruction]) runMath m = evalRWS (unMath m) () 0