alphanumeric :: Schema
alphanumeric = withDefaultSize 18 $ \ s -> do
    let number = max s 4
        lBound = max 1 $ floor $ number % 8
        uBound = ceiling $ number % 4
    nUpper <- inRange (lBound, uBound)
    nDigit <- inRange (lBound, uBound)
    let nLower = number - nUpper - nDigit
    uppers <- replicateM nUpper upper
    digits <- replicateM nDigit digit
    lowers <- replicateM nLower lower
    shuffle (uppers <> digits <> lowers)

{- | Generates a PIN number, of length `n`.
     Entropy of about @3.32 * n@ bits. -}
alphanumeric :: Schema
alphanumeric = withDefaultSize 18 $ \ s -> do
    let number = max s 4
        lBound = max 1 $ floor $ number % 8
        uBound = ceiling $ number % 4
    nUpper <- inRange (lBound, uBound)
    nDigit <- inRange (lBound, uBound)
    let nLower = number - nUpper - nDigit
    uppers <- replicateM nUpper upper
    digits <- replicateM nDigit digit
    lowers <- replicateM nLower lower
    shuffle (uppers <> digits <> lowers)

{- | Generates a PIN number, of length `n`.
     Entropy of about @3.32 * n@ bits. -}
alphanumeric = withDefaultSize 18 $ \ s -> do
    let number = max s 4
        lBound = max 1 $ floor $ number % 8
        uBound = ceiling $ number % 4
    nUpper <- inRange (lBound, uBound)
    nDigit <- inRange (lBound, uBound)
    let nLower = number - nUpper - nDigit
    uppers <- replicateM nUpper upper
    digits <- replicateM nDigit digit
    lowers <- replicateM nLower lower
    shuffle (uppers <> digits <> lowers)

{- | Generates a PIN number, of length `n`.
     Entropy of about @3.32 * n@ bits. -}