git.iko.soy/ikoHSE/sc-task-3
on master help sign in
bump
commit2169305349ca1c50428793551adf5af9f0866dda authoriko <mail@iko.soy> dateFri 12 Dec 2025, 10:16 (1 year ago) parent9ab4f51
5 files changed+39−15
unifiedsplit
package.yaml+4−1 src/Task.hs+6−6 stack.yaml+18−2 task.cabal+8−4 test/Tests.hs+3−2
package.yaml+4−1
@@ -2,8 +2,11 @@ name: task
22version: 0.1.0.0
33license: Unlicense
44
5+default-extensions:
6+ - DerivingStrategies
7+
58dependencies:
6− - base >= 4.7 && < 5
9+ - base
710
811library:
912 source-dirs: src
src/Task.hs+6−6
@@ -26,8 +26,7 @@ module Task
2626 )
2727where
2828
29−import Data.Char
30−import Data.List
29+import Data.List (intersperse)
3130
3231-- ____ _____ _ _ _
3332-- | __ )| ___| (_)_ __ | |_ ___ _ __ _ __ _ __ ___| |_ ___ _ __
@@ -70,7 +69,7 @@ data Tape a
7069 tapeValue :: a,
7170 rightTape :: [a]
7271 }
73− deriving (Eq, Ord)
72+ deriving stock (Eq, Ord)
7473
7574-- We need a special instance to handle infinite tapes. The derived
7675-- implementation would go into an infinite loop.
@@ -84,6 +83,7 @@ instance Show a => Show (Tape a) where
8483 <> tapeify (take 5 right)
8584 <> "]"
8685 where
86+ tapeify :: Show x => [x] -> String
8787 tapeify = mconcat . intersperse " " . fmap show
8888
8989-- | Creates a tape from a list.
@@ -186,7 +186,7 @@ data BFState
186186 -- | The output stream of the BF interpreter.
187187 bfOutput :: [Int]
188188 }
189− deriving (Eq, Show)
189+ deriving stock (Eq, Show)
190190
191191-- | This represents the errors that can occur while executing a BF program.
192192data BFError
@@ -194,7 +194,7 @@ data BFError
194194 NotEnoughInput
195195 | -- | Tried going past the end of the data tape (if it was finite).
196196 DataTapeExhausted
197− deriving (Show, Eq)
197+ deriving stock (Show, Eq)
198198
199199-- | The monad in which we will interpreting the BF commands.
200200type BFMonad a = ErrorState BFError BFState a
@@ -259,7 +259,7 @@ data BFCommand
259259 ReadInput
260260 | -- | The `.` command.
261261 WriteOutput
262− deriving (Eq, Show)
262+ deriving stock (Eq, Show)
263263
264264type BFProgram = [BFCommand]
265265
stack.yaml+18−2
@@ -1,7 +1,23 @@
1−resolver: lts-20.4
1+resolver: lts-24.23
22
33packages:
44- .
55
66ghc-options:
7− "$locals": -ddump-to-file -ddump-hi -fwarn-unused-binds -fwarn-unused-imports -Wall -Wincomplete-uni-patterns -Wincomplete-record-updates -Wpartial-fields -Werror=missing-home-modules -Wmissing-home-modules -Widentities -Wredundant-constraints -Wmissing-export-lists
7+ "$locals": |
8+ -Weverything
9+ -Wno-unsafe
10+ -Wno-safe
11+ -Wno-missing-safe-haskell-mode
12+ -Wno-missing-import-lists
13+ -Wno-missing-kind-signatures
14+ -Wno-all-missed-specialisations
15+ -Wno-missed-specialisations
16+ -Wno-partial-type-signatures
17+ -Wno-partial-fields
18+ -Wno-operator-whitespace
19+ -Wno-missed-extra-shared-lib
20+ -Wno-missing-role-annotations
21+ -Wno-missing-poly-kind-signatures
22+ -Wno-implicit-prelude
23+ -threaded
task.cabal+8−4
@@ -1,10 +1,10 @@
11cabal-version: 2.2
22
3−-- This file has been generated from package.yaml by hpack version 0.35.0.
3+-- This file has been generated from package.yaml by hpack version 0.37.0.
44--
55-- see: https://github.com/sol/hpack
66--
7−-- hash: ba479ad20ec471b3b53314ad5d901661b888b4664e6cd42d65d0fd6ff6be5b8d
7+-- hash: d4671383815d2a08c8473740521f11d0ebd39c19bfc0be7f68aa522e17a866ee
88
99name: task
1010version: 0.1.0.0
@@ -21,8 +21,10 @@ library
2121 Paths_task
2222 hs-source-dirs:
2323 src
24+ default-extensions:
25+ DerivingStrategies
2426 build-depends:
25− base >=4.7 && <5
27+ base
2628 default-language: Haskell2010
2729
2830test-suite task-tests
@@ -35,9 +37,11 @@ test-suite task-tests
3537 Paths_task
3638 hs-source-dirs:
3739 test
40+ default-extensions:
41+ DerivingStrategies
3842 build-depends:
3943 QuickCheck
40− , base >=4.7 && <5
44+ , base
4145 , hspec
4246 , task
4347 , tasty
test/Tests.hs+3−2
@@ -12,7 +12,7 @@ module Tests
1212where
1313
1414import Control.Arrow
15−import Data.List
15+import Data.List (sort)
1616import Data.Maybe
1717import Task
1818import Test.QuickCheck
@@ -319,7 +319,8 @@ tests = parallel $ do
319319 (x : xx) -> ((bfDataTape &&& bfInput) . snd <$> runErrorState (executeCommand ReadInput) (state t l)) === Right ((t {tapeValue = x}, xx))
320320 property testProperty
321321 specify "Loop" $ do
322− let toList t = reverse (leftTape t) <> [tapeValue t] <> rightTape t
322+ let toList :: Tape a -> [a]
323+ toList t = reverse (leftTape t) <> [tapeValue t] <> rightTape t
323324 testLoop i o l =
324325 (toList . bfDataTape . snd <$> runErrorState (executeCommand (Loop l)) (state . fromJust . initializeTape $ i))
325326 `shouldBe` Right o