From 9484d097d4b148e82f8d256097459b0ea284b85e Mon Sep 17 00:00:00 2001 From: VegOwOtenks Date: Thu, 19 Jun 2025 21:51:45 +0200 Subject: [PATCH] feat: StrictData + Unbounded Integer types --- src/Language/Brainfuck/Instruction/Extended.hs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Language/Brainfuck/Instruction/Extended.hs b/src/Language/Brainfuck/Instruction/Extended.hs index e3b8d9d..8bd5a79 100644 --- a/src/Language/Brainfuck/Instruction/Extended.hs +++ b/src/Language/Brainfuck/Instruction/Extended.hs @@ -1,12 +1,16 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE StrictData #-} module Language.Brainfuck.Instruction.Extended (Operation(..), Interaction(..), ExtendedInstruction(Modify, Move, Interact, Jump), pattern IfNonZero, pattern WithOffset, mkIfNonZero, mkWithOffset, translationSize, parse) where + import Data.Word (Word8) -import Language.Brainfuck.Instruction.Compressed (CompressedInstruction) import Data.Vector (Vector) +import Numeric.Natural (Natural) + +import Language.Brainfuck.Instruction.Compressed (CompressedInstruction) + import qualified Data.Vector as Vector import qualified Language.Brainfuck.Instruction.Compressed as CompressedInstruction -import Numeric.Natural (Natural) data Operation = Add @@ -18,7 +22,7 @@ data Interaction | Write deriving (Show) -pattern WithOffset :: Int -> ExtendedInstruction -> ExtendedInstruction +pattern WithOffset :: Integer -> ExtendedInstruction -> ExtendedInstruction pattern WithOffset offset embedded <- AtOffset offset embedded where WithOffset offset embedded = mkWithOffset offset embedded @@ -29,7 +33,7 @@ pattern IfNonZero instruction <- WhenNonZero instruction IfNonZero instruction = mkIfNonZero instruction data ExtendedInstruction - = AtOffset Int ExtendedInstruction -- invariant, WithOffset may not nest itself + = AtOffset Integer ExtendedInstruction -- invariant, WithOffset may not nest itself | WhenNonZero ExtendedInstruction -- invariant, IfNonZero may not nest itself | Modify Operation Word8 | Move Integer @@ -42,7 +46,7 @@ mkIfNonZero = \case WhenNonZero i -> WhenNonZero i instruction -> WhenNonZero instruction -mkWithOffset :: Int -> ExtendedInstruction -> ExtendedInstruction +mkWithOffset :: Integer -> ExtendedInstruction -> ExtendedInstruction mkWithOffset offset = \case AtOffset offset' i -> AtOffset (offset + offset') i instruction -> AtOffset offset instruction