packages feed

riichi-scoring 0.2.0.0 → 0.2.0.1

raw patch · 4 files changed

+32/−9 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -10,3 +10,8 @@  ## 0.2.0.0 Help messages improved. Module structure refactored. Documentation begun.++## 0.2.0.1+Revised cabal version in attempt to fix build error on Hackage. Build works+locally, suspect the problem is a quirk of Hackage build system.+Added some more documentation.
riichi-scoring.cabal view
@@ -1,4 +1,4 @@-cabal-version: 3.0+cabal-version: 2.2 -- The cabal-version field refers to the version of the .cabal specification, -- and can be different from the cabal-install (the tool) version and the -- Cabal (the library) version you are using. As such, the Cabal (the library)@@ -20,7 +20,7 @@ -- PVP summary:     +-+------- breaking API changes --                  | | +----- non-breaking API additions --                  | | | +--- code changes with no API change-version: 0.2.0.0+version: 0.2.0.1 -- A short (one-line) description of the package. synopsis: A CLI tool for interpreting and scoring Riichi Mahjong hands. -- A longer description of the package.@@ -67,8 +67,8 @@   hs-source-dirs: src   build-depends:     base >=4.19.2.0 && <5,-    containers >=0.7 && <0.8,-    mtl >=2.3.1 && <2.4,+    containers >=0.6.8 && <0.8,+    mtl >=2.2.2 && <2.4,    default-language: GHC2021 @@ -84,8 +84,8 @@   -- Other library packages from which modules are imported.   build-depends:     base >=4.19.2.0 && <5,-    containers >=0.7 && <0.8,-    mtl >=2.3.1 && <2.4,+    containers >=0.6.8 && <0.8,+    mtl >=2.2.2 && <2.4,     riichi-lib,    -- Directories containing source files.@@ -100,7 +100,7 @@   build-depends:     base >=4.19.2.0 && <5,     riichi-lib,-    tasty,-    tasty-hunit,+    tasty >=1.5.4 && <1.6,+    tasty-hunit >=0.10.2 && <0.11,    default-language: GHC2021
src/Riichi/Display.hs view
@@ -16,6 +16,7 @@ import Riichi.Waits import Riichi.Yaku +-- | Implements the "yaku" command for the CLI. In need of a refactor. displayHandYaku :: Hand -> IO () displayHandYaku hand = do     if length hand < 14@@ -54,11 +55,13 @@                         then putStrLn $ toRed "This hand is not valid"                         else return () +-- | Implements the "waits" command for the CLI. displayHandWaits :: Hand -> IO () displayHandWaits hand = do     let waits = getWaits hand     putStrLn $ "Waits are: " ++ (waits & map show & intersperse ", " & concat) +-- | Implements the "score" command for the CLI. In need of a refactor, logic is rather serpentine at the moment. displayHandScore :: Hand -> IO () displayHandScore hand = do     putStrLn "Input dora: (or leave blank)"
src/Riichi/Tile.hs view
@@ -15,17 +15,28 @@ -} data Tile = Honour Honour Dora | Numeric Suit Value Dora deriving (Ord) +-- | Simple type alias. Tracks dora value for a tile. Note red five is represented as dora 1. type Dora = Integer++-- | Type alias for the value of a Numeric tile. type Value = Integer  -- | An honour tile is a dragon or a wind data Honour = Dragon (Dragon) | Wind (Wind) deriving (Show, Eq, Ord) +-- | Dragon enum data Dragon = White | Green | Red deriving (Show, Eq, Ord)++-- | Wind enum data Wind = North | East | South | West deriving (Show, Eq, Ord) +-- | Suit enum data Suit = Man | Pin | Sou deriving (Show, Eq, Ord) +{- | Read a single tile using (semi)standard notation.+| Winds are upper case, dragons lower case, to remove ambiguity.+| Red five is denoted by 0.+-} instance Read Tile where     readsPrec :: Int -> ReadS Tile     readsPrec _ (x : []) = [(tile, [])]@@ -58,6 +69,7 @@                 )          in [(Numeric suit value dora, [])] +-- | ALlows strings like "123p" and "rrNE" to be read readTileBlock :: String -> [Tile] readTileBlock string =     let@@ -70,6 +82,7 @@      in         stripped & map (\c -> [c]) & intersperse separator & concat & (++ separator) & words & map read +-- | Implements an inverse to read instance Show Tile where     show (Honour (Dragon Red) _) = "r"     show (Honour (Dragon Green) _) = "g"@@ -85,7 +98,9 @@     show (Numeric Man n _) = (show n) ++ "m"     show (Numeric Sou n _) = (show n) ++ "s" --- We don't care about dora when equating tiles+{- | Almost identical to what would result from deriving Eq on Tile, except we choose to+| ignore the Dora value+-} instance Eq Tile where     (==) (Honour honour _) (Honour honour' _) = (honour == honour')     (==) (Numeric suit value _) (Numeric suit' value' _) = (suit == suit') && (value == value')