packages feed

NanoID 3.1.0 → 3.1.1

raw patch · 3 files changed

+20/−16 lines, 3 filesdep ~aesonPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: aeson

API changes (from Hackage documentation)

+ Data.NanoID: toAlphabet :: String -> Alphabet

Files

NanoID.cabal view
@@ -1,5 +1,5 @@ name:                NanoID-version:             3.1.0+version:             3.1.1 synopsis:            NanoID generator description:         Library and CLI tool for NanoID generation license:             BSD3@@ -20,7 +20,7 @@  library   exposed-modules:     Data.NanoID-  build-depends:       aeson      >= 1.5.6 && < 1.6+  build-depends:       aeson      >= 1.5.6 && < 1.6 || >= 2.0 && < 2.1                      , base       >= 4.7   && < 4.16                      , bytestring >= 0.10  && < 0.12                      , cereal     >= 0.5.8 && < 0.5.9
app/Main.hs view
@@ -17,11 +17,11 @@     then strFail "nanoid length"     else if quantity < 1       then strFail "quantity"-      else do-        let alphabet' = Alphabet { unAlphabet = C.pack alphabet }+      else         replicateM_ quantity $-          createSystemRandom >>= customNanoID alphabet' (toEnum length) >>= putNanoID newline-        exitSuccess+          createSystemRandom+            >>= customNanoID (toAlphabet alphabet) (toEnum length)+            >>= putNanoID newline >> exitSuccess   where     strFail m = putStrLn ("Bad " <> m <> ". See help (-h).") >> exitFailure     putNanoID nl = put nl . unNanoID
src/Data/NanoID.hs view
@@ -33,11 +33,15 @@  instance Serialize NanoID +-- | Create a new 'Alphabet' from a string of symbols of your choice+toAlphabet :: String -> Alphabet+toAlphabet = Alphabet . C.pack+ -- | Standard 'NanoID' generator function -- -- >λ: g <- createSystemRandom -- >λ: NanoID g--- >NanoID {unNanoID = "x2f8yFadImeVp14ByJ8R3"}+-- >x2f8yFadIm-Vp14ByJ8R3 -- nanoID :: GenIO -> IO NanoID nanoID = customNanoID defaultAlphabet 21@@ -55,31 +59,31 @@  -- | The default 'Alphabet', made of URL-friendly symbols. defaultAlphabet :: Alphabet-defaultAlphabet = Alphabet (C.pack "ABCDEFGHIJKLMNOPKRSTUVWXYZ_1234567890-abcdefghijklmnopqrstuvwxyz")+defaultAlphabet = toAlphabet "ABCDEFGHIJKLMNOPKRSTUVWXYZ_1234567890-abcdefghijklmnopqrstuvwxyz"  -- * Predefined Alphabets borrowed from https://github.com/CyberAP/nanoid-dictionary  numbers :: Alphabet-numbers = Alphabet (C.pack "1234567890")+numbers = toAlphabet "1234567890"  hexadecimalLowercase :: Alphabet-hexadecimalLowercase = Alphabet (C.pack "0123456789abcdef")+hexadecimalLowercase = toAlphabet "0123456789abcdef"  hexadecimalUppercase :: Alphabet-hexadecimalUppercase = Alphabet (C.pack "0123456789ABCDEF")+hexadecimalUppercase = toAlphabet "0123456789ABCDEF"  lowercase :: Alphabet-lowercase = Alphabet (C.pack "abcdefghijklmnopqrstuvwxyz")+lowercase = toAlphabet "abcdefghijklmnopqrstuvwxyz"  uppercase :: Alphabet-uppercase = Alphabet (C.pack "ABCDEFGHIJKLMNOPQRSTUVWXYZ")+uppercase = toAlphabet "ABCDEFGHIJKLMNOPQRSTUVWXYZ"  alphanumeric :: Alphabet-alphanumeric = Alphabet (C.pack "ABCDEFGHIJKLMNOPKRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz")+alphanumeric = toAlphabet "ABCDEFGHIJKLMNOPKRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz"  nolookalikes :: Alphabet-nolookalikes = Alphabet (C.pack "346789ABCDEFGHJKLMNPQRTUVWXYabcdefghijkmnpqrtwxyz")+nolookalikes = toAlphabet "346789ABCDEFGHJKLMNPQRTUVWXYabcdefghijkmnpqrtwxyz"  nolookalikesSafe :: Alphabet-nolookalikesSafe = Alphabet (C.pack "6789ABCDEFGHJKLMNPQRTUWYabcdefghijkmnpqrtwyz")+nolookalikesSafe = toAlphabet "6789ABCDEFGHJKLMNPQRTUWYabcdefghijkmnpqrtwyz"