NanoID 3.1.1 → 3.2.0
raw patch · 5 files changed
+20/−20 lines, 5 filesdep ~basedep ~optparse-applicativedep ~textPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, optparse-applicative, text
API changes (from Hackage documentation)
- Data.NanoID: newtype NanoID
+ Data.NanoID: data NanoID
- Data.NanoID: NanoID :: ByteString -> NanoID
+ Data.NanoID: NanoID :: !ByteString -> NanoID
- Data.NanoID: [unNanoID] :: NanoID -> ByteString
+ Data.NanoID: [unNanoID] :: NanoID -> !ByteString
Files
- NanoID.cabal +7/−7
- ReadMe.md +3/−4
- app/Main.hs +4/−3
- app/Options.hs +2/−2
- src/Data/NanoID.hs +4/−4
NanoID.cabal view
@@ -1,18 +1,18 @@ name: NanoID-version: 3.1.1+version: 3.2.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 - Michel Boucey+copyright: (c) 2021-2022 - Michel Boucey category: Data build-type: Simple cabal-version: >=1.10 extra-source-files: ReadMe.md -Tested-With: GHC ==8.4.4 || ==8.6.5 || ==8.8.4 || ==8.10.1 || ==8.10.4 || ==9.0.1+Tested-With: GHC ==8.4.4 || ==8.6.5 || ==8.8.4 || ==8.10.7 || ==9.0.1 || ==9.2.1 source-repository head type: git@@ -21,23 +21,23 @@ library exposed-modules: Data.NanoID build-depends: aeson >= 1.5.6 && < 1.6 || >= 2.0 && < 2.1- , base >= 4.7 && < 4.16+ , base >= 4.7 && < 4.17 , bytestring >= 0.10 && < 0.12 , cereal >= 0.5.8 && < 0.5.9 , extra >= 1.6 && < 1.8 , mwc-random >= 0.13 && < 0.16- , text >= 1.2.4 && < 1.3+ , text >= 1.2.3 && < 1.3 || == 2.0.* hs-source-dirs: src default-language: Haskell2010 executable nanoid main-is: Main.hs other-modules: Options- build-depends: base >= 4.7 && < 4.16+ build-depends: base >= 4.7 && < 4.17 , bytestring >= 0.10 && < 0.12 , mwc-random >= 0.13 && < 0.16 , NanoID- , optparse-applicative >= 0.14 && < 0.17+ , optparse-applicative >= 0.14 && < 0.18 hs-source-dirs: app default-language: Haskell2010
ReadMe.md view
@@ -1,8 +1,7 @@-# NanoID generator, library and CLI tool [](https://travis-ci.org/github/MichelBoucey/NanoID)-+# NanoID generator, library and CLI tool  ``` [user@box ~] $ nanoid -h-nanoid v2.1.0, (c) Michel Boucey 2021+nanoid v3.2.0, (c) Michel Boucey 2022 Usage: nanoid [-a|--alphabet ARG] [-l|--length ARG] [-q|--quantity ARG] [-n|--newline]@@ -10,7 +9,7 @@ Available options: -a,--alphabet ARG Use an alternative alphabet (ascii chars only)- -l,--length ARG Get shorter NanoID+ -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 -h,--help Show this help text
app/Main.hs view
@@ -13,15 +13,16 @@ main :: IO () main = do Options{..} <- execParser opts- if length < 1+ if length < 1 || length > 21 then strFail "nanoid length" else if quantity < 1 then strFail "quantity"- else+ else do replicateM_ quantity $ createSystemRandom >>= customNanoID (toAlphabet alphabet) (toEnum length)- >>= putNanoID newline >> exitSuccess+ >>= putNanoID newline+ exitSuccess where strFail m = putStrLn ("Bad " <> m <> ". See help (-h).") >> exitFailure putNanoID nl = put nl . unNanoID
app/Options.hs view
@@ -16,7 +16,7 @@ opts = info (options <**> helper) ( fullDesc <> progDesc "NanoID generator"- <> header "nanoid v3.1.0, (c) Michel Boucey 2021" )+ <> header "nanoid v3.2.0, (c) Michel Boucey 2022" ) options :: Parser Options options =@@ -31,7 +31,7 @@ option auto ( short 'l' <> long "length"- <> help "Default NanoID length is 21 chars"+ <> help "Get a shorter NanoID (Default length is 21 chars)" <> value 21 ) <*> option auto
src/Data/NanoID.hs view
@@ -6,13 +6,13 @@ import Data.Aeson import qualified Data.ByteString.Char8 as C import Data.Maybe-import Data.Serialize (Serialize)+import Data.Serialize (Serialize) import Data.Text.Encoding import GHC.Generics import Numeric.Natural import System.Random.MWC -newtype NanoID = NanoID { unNanoID :: C.ByteString } deriving (Eq,Generic)+data NanoID = NanoID { unNanoID :: !C.ByteString } deriving (Eq, Generic) newtype Alphabet = Alphabet { unAlphabet :: C.ByteString } deriving (Eq) @@ -40,7 +40,7 @@ -- | Standard 'NanoID' generator function -- -- >λ: g <- createSystemRandom--- >λ: NanoID g+-- >λ: nanoID g -- >x2f8yFadIm-Vp14ByJ8R3 -- nanoID :: GenIO -> IO NanoID@@ -61,7 +61,7 @@ defaultAlphabet :: Alphabet defaultAlphabet = toAlphabet "ABCDEFGHIJKLMNOPKRSTUVWXYZ_1234567890-abcdefghijklmnopqrstuvwxyz" --- * Predefined Alphabets borrowed from https://github.com/CyberAP/nanoid-dictionary+-- * Some predefined Alphabets, borrowed from https://github.com/CyberAP/nanoid-dictionary numbers :: Alphabet numbers = toAlphabet "1234567890"