packages feed

NanoID 3.2.1 → 3.3.0

raw patch · 5 files changed

+38/−18 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Data.NanoID: data NanoID
+ Data.NanoID: newtype NanoID
- Data.NanoID: NanoID :: !ByteString -> NanoID
+ Data.NanoID: NanoID :: ByteString -> NanoID
- Data.NanoID: [unNanoID] :: NanoID -> !ByteString
+ Data.NanoID: [unNanoID] :: NanoID -> ByteString

Files

NanoID.cabal view
@@ -1,12 +1,12 @@ name:                NanoID-version:             3.2.1+version:             3.3.0 synopsis:            NanoID generator description:         Library and CLI tool for NanoID generation license:             BSD3 license-file:        LICENSE author:              Michel Boucey maintainer:          michel.boucey@gmail.com-copyright:           (c) 2021-2022 - Michel Boucey+copyright:           (c) 2021-2023 - Michel Boucey category:            Data build-type:          Simple cabal-version:       >=1.10@@ -20,8 +20,7 @@    || == 8.8.4    || == 8.10.7    || == 9.0.2-   || == 9.2.3-   || == 9.4.1+   || == 9.2.5  source-repository head   type:     git@@ -42,6 +41,7 @@ executable nanoid   main-is:             Main.hs   other-modules:       Options+                       Paths_NanoID   build-depends:       base                 >= 4.7  && < 4.17                      , bytestring           >= 0.10 && < 0.12                      , mwc-random           >= 0.13 && < 0.16
ReadMe.md view
@@ -1,7 +1,7 @@ # NanoID generator, library and CLI tool ![CI](https://github.com/MichelBoucey/NanoID/actions/workflows/haskell-ci.yml/badge.svg) ``` [user@box ~] $ nanoid -h-nanoid v3.2.0, (c) Michel Boucey 2022+nanoid v3.3.0, (c) Michel Boucey 2022-2023  Usage: nanoid [-a|--alphabet ARG] [-l|--length ARG] [-q|--quantity ARG]                [-n|--newline]@@ -12,6 +12,7 @@   -l,--length ARG          Get a shorter NanoID (Default length is 21 chars)   -q,--quantity ARG        Quantity of NanoID to generate   -n,--newline             Do not output the trailing newline+  -v,--version             Show version   -h,--help                Show this help text ``` 
app/Main.hs view
@@ -1,10 +1,10 @@-{-# LANGUAGE CPP #-}+{-# LANGUAGE CPP             #-} {-# LANGUAGE RecordWildCards #-}  import           Control.Monad  #if !MIN_VERSION_base(4,11,0)-import           Data.Monoid              ((<>))+import           Data.Monoid           ((<>)) #endif  import qualified Data.ByteString.Char8 as C@@ -19,8 +19,10 @@ main :: IO () main = do   Options{..} <- execParser opts-  if length < 1 || length > 21-    then strFail "nanoid length"+  if showver+    then putStrLn (showVer) >> exitFailure+    else if length < 1 || length > 21+      then strFail "nanoid length"     else if quantity < 1       then strFail "quantity"       else do
app/Options.hs view
@@ -1,15 +1,18 @@-{-# LANGUAGE CPP #-}+{-# LANGUAGE CPP             #-}+{-# LANGUAGE TemplateHaskell #-}  module Options where  import qualified Data.ByteString.Char8 as C  #if !MIN_VERSION_base(4,11,0)-import           Data.Monoid              ((<>))+import           Data.Monoid           ((<>)) #endif  import           Data.NanoID+import           Data.Version          (showVersion) import           Options.Applicative+import           Paths_NanoID          (version)  data Options =   Options@@ -17,13 +20,16 @@     , length   :: Int     , quantity :: Int     , newline  :: Bool+    , showver  :: Bool     }  opts :: ParserInfo Options opts = info (options <**> helper)   ( fullDesc     <> progDesc "NanoID generator"-    <> header "nanoid v3.2.0, (c) Michel Boucey 2022" )+    <> header ( "nanoid "+                <> showVer+                <> ", (c) Michel Boucey 2022-2023" ) )  options :: Parser Options options =@@ -51,4 +57,12 @@         ( short 'n'           <> long "newline"           <> help "Do not output the trailing newline" )+    <*>+      flag False True+        ( short 'v'+          <> long "version"+          <> help "Show version" )++showVer :: String+showVer = "v" <> showVersion version 
src/Data/NanoID.hs view
@@ -9,18 +9,22 @@ import           Data.Maybe  #if !MIN_VERSION_base(4,11,0)-import           Data.Monoid              ((<>))+import           Data.Monoid           ((<>)) #endif -import           Data.Serialize           (Serialize)+import           Data.Serialize        (Serialize) import           Data.Text.Encoding import           GHC.Generics import           Numeric.Natural import           System.Random.MWC -data NanoID = NanoID { unNanoID :: !C.ByteString } deriving (Eq, Generic)+newtype NanoID =+  NanoID { unNanoID :: C.ByteString }+  deriving (Eq, Generic) -newtype Alphabet = Alphabet { unAlphabet :: C.ByteString } deriving (Eq)+newtype Alphabet =+  Alphabet { unAlphabet :: C.ByteString }+  deriving (Eq)  type Length = Natural @@ -45,8 +49,7 @@  -- | Standard 'NanoID' generator function ----- >λ: g <- createSystemRandom--- >λ: nanoID g+-- >λ: createSystemRandom >>= nanoID -- >x2f8yFadIm-Vp14ByJ8R3 -- nanoID :: GenIO -> IO NanoID