From f274db5fbe827b208688946703beec2640741279 Mon Sep 17 00:00:00 2001 From: shu Date: Wed, 11 Dec 2019 20:45:43 +0100 Subject: [PATCH] Day 9: I like error more than custom exceptions --- 2019/day9/Intcode.hs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/2019/day9/Intcode.hs b/2019/day9/Intcode.hs index fcbd2c5..94bb100 100644 --- a/2019/day9/Intcode.hs +++ b/2019/day9/Intcode.hs @@ -46,12 +46,6 @@ data TuringMachine = } deriving (Show) -data IntcodeExcept = - UnknownOpCodeException - deriving (Show) - -instance Exception IntcodeExcept - tapePreprocess :: Vector Integer -> Vector Integer tapePreprocess t = (V.++) t $ V.replicate 105 0 @@ -124,7 +118,7 @@ step tm = else 0) "9" -> tmn {pointerOffset = pointerOffset tm + (params ! 0)} "99" -> tm {state = Halt} - _ -> throw UnknownOpCodeException + _ -> error "Illegal Opcode." where pNew = pointer tm + opLength (tape tm ! fromInteger (pointer tm)) tmn = tm {pointer = pNew}