module Fake.Provider.IdNumber.EN_US
  ( ssn
  ) where

------------------------------------------------------------------------------
import Text.Printf
------------------------------------------------------------------------------
import Fake
------------------------------------------------------------------------------

------------------------------------------------------------------------------
-- | Generates a fake US social security number.  The have the form
-- area-group-serial.
ssn :: FGen String
ssn :: FGen String
ssn = do
    Int
area <- FGen Int
ssnArea
    Int
group <- FGen Int
ssnGroup
    Int
serial <- FGen Int
ssnSerial
    String -> FGen String
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> FGen String) -> String -> FGen String
forall a b. (a -> b) -> a -> b
$ String -> Int -> Int -> Int -> String
forall r. PrintfType r => String -> r
printf String
"%03d-%02d-%04d" Int
area Int
group Int
serial

fixupArea :: Int -> Int
fixupArea :: Int -> Int
fixupArea Int
666 = Int
667
fixupArea Int
n = Int
n

ssnArea :: FGen Int
ssnArea :: FGen Int
ssnArea = Int -> Int
fixupArea (Int -> Int) -> FGen Int -> FGen Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> Int -> FGen Int
fakeInt Int
0 Int
899

ssnGroup :: FGen Int
ssnGroup :: FGen Int
ssnGroup = Int -> Int -> FGen Int
fakeInt Int
1 Int
99

ssnSerial :: FGen Int
ssnSerial :: FGen Int
ssnSerial = Int -> Int -> FGen Int
fakeInt Int
1 Int
9999