BSD-3-Clause licensed by Sibi Prabakaran
Maintained by [email protected]
This version can be pinned in stack with:fakedata-1.0.3@sha256:75630f6b9665965b4b551239ffcf89e4f879f93d235b18d4b249b0ed50513d0d,24593

Module documentation for 1.0.3

fakedata Hackage Stackage Nightly Stackage LTS Build Status

Table of Contents


This library is a port of Ruby’s faker. It’s a library for producing fake data such as names, addressess and phone numbers. Note that it directly uses the source data from that library, so the quality of fake data is quite high!

This package comes in handy when you have to generate large amount of real like data for various purposes. I have personally used it for websites where it needs some realistic data in the initial stage, loading database with real like values etc. There are companies which have used this for sophisphicated testing purpose.

Additionly, there are two other packages for creating generators which is useful for property testing:


Generating address

~/g/fakedata (master) $ stack ghci
λ> import Faker
λ> import Faker.Address
λ> address <- generate fullAddress
λ> address
"Apt. 298 340 Ike Mission, Goldnertown, FL 19488-9259"

Generating name

λ> fullName <- generate name
λ> fullName
"Sherryl Steuber"

Generate quotes from the movie Back to the Future

λ> import Faker.Movie.BackToTheFuture
λ> import Faker.Combinators
λ> qs <- generateNonDeterministic $ listOf 5 quotes
λ> qs
[ "Yes. Yes. I'm George. George McFly. I'm your density. I mean, your destiny."
, "Hello? Hello? Anybody home? Huh? Think, McFly. Think! I gotta have time to get them retyped. Do you realize what would happen if I hand in my reports in your handwriting? I'll get fired. You wouldn't want that to happen, would ya? Would ya?"
, "Lorraine. My density has brought me to you."
, "See you in about 30 years."
, "You really think I ought to swear?"

Combining Fake datas

{-#LANGUAGE RecordWildCards#-}

import Faker
import Faker.Name
import Faker.Address
import Data.Text

data Person = Person {
    personName :: Text,
    personAddress :: Text
} deriving (Show, Eq)

fakePerson :: Fake Person
fakePerson = do
    personName <- name
    personAddress <- fullAddress
    pure $ Person{..}

main :: IO ()
main = do
    person <- generate fakePerson
    print person

And on executing them:

$ stack name.hs
  { personName = "Sherryl Steuber"
  , personAddress = "Apt. 298 340 Ike Mission, Goldnertown, FL 19488-9259"

You would have noticed in the above output that the name and address are the same as generated before in the GHCi REPL. That’s because, by default all the generated data are deterministic. If you want a different set of output each time, you would have to modify the random generator output:

main :: IO ()
main = do
    gen <- newStdGen
    let settings = setRandomGen gen defaultFakerSettings
    person <- generateWithSettings settings fakePerson
    print person

And on executing the program, you will get a different output:

  { personName = "Ned Effertz Sr."
  , personAddress = "Suite 158 1580 Schulist Mall, Schulistburgh, NY 15804-3392"

The above program can be even minimized like this:

main :: IO ()
main = do
    let settings = setNonDeterministic defaultFakerSettings
    person <- generateWithSettings settings fakePerson
    print person

Or even better:

main :: IO ()
main = do
    person <- generateNonDeterministic fakePerson
    print person

Deterministic vs Non Deterministic values

We have various function for generating fake values:

  • generate
  • generateNonDeterministic
  • generateNonDeterministicWithFixedSeed

By default, generate produces deterministic values. It’s performance is better than the others and for cases where we are going to generate a single fake value using record type, it’s a good default to have. Example:

{-#LANGUAGE RecordWildCards#-}

import Faker
import Faker.Name
import Faker.Address
import Data.Text

data Person = Person {
    personName :: Text,
    personAddress :: Text
} deriving (Show, Eq)

fakePerson :: Fake Person
fakePerson = do
    personName <- name
    personAddress <- fullAddress
    pure $ Person{..}

main :: IO ()
main = do
    person <- generate fakePerson
    print person

And executing it, you will get:

  { personName = "Sherryl Steuber"
  , personAddress = "Apt. 298 340 Ike Mission, Goldnertown, FL 19488-9259"

While, it’s a good default we would need non deterministic output for certain cases:

> generate $ listOf 5 $ fromRange (1,100)
> generate $ listOf 5 $ fromRange (1,100)
> generateNonDeterministic $ listOf 5 $ fromRange (1,100)
> generateNonDeterministic $ listOf 5 $ fromRange (1,100)

Not how generateNonDeterministic is generating different values each time. If you instead want to have a fixed seed, you should use generateNonDeterministicWithFixedSeed instead:

> generateNonDeterministicWithFixedSeed $ listOf 5 $ fromRange (1,100)
> generateNonDeterministicWithFixedSeed $ listOf 5 $ fromRange (1,100)



λ> import Faker.Address
λ> item <- generateNonDeterministic $ listOf 5 country
λ> item
["Ecuador","French Guiana","Faroe Islands","Canada","Armenia"]


λ> item <- generate $ oneof [country, fullAddress]
λ> item
"Suite 599 599 Brakus Flat, South Mason, MT 59962-6876"


λ> import qualified Faker.Address as AD
λ> item :: Text <- generate $ suchThat (\x -> (T.length x > 5))
λ> item
λ> item :: Text <- generate $ suchThat (\x -> (T.length x > 8))
λ> item
"French Guiana"

For seeing the full list of combinators, see the module documentation of Faker.Combinators.

Using the FakeT transformer

When generating values, you may want to perform some side-effects.

import Control.Monad.IO.Class
import Control.Monad.Logger
import Data.Text
import Data.Text.IO
import Faker.ChuckNorris

logQuote :: (MonadIO m, MonadLogger m) => m ()
logQuote = do
  userName <- liftIO getLine
  quote <- generateNonDeterministic fact
  $(logInfo) $ "Chuck Norris" userName quote

This works fine for one-off generation - but if you try to repeatedly generate values, you will run into performance trouble.

import Control.Monad (replicateM)

slowFunction :: (MonadIO m, MonadLogger m) => m ()
slowFunction = replicateM 1000 logQuote

This is because generating a Fake parses the data files and builds a cache for future use. Using the Monad instance on Fake shares that cache between Fakes, making faking fast. But in the above code, a new Fake is generated each time - so the cache is discarded, and performance is much worse.

It’s better to use the FakeT monad transformer when writing such code, to get the benefits of sharing the cache, as well as being able to perform side effects. FakeT comes with the mtl-style MonadFake class, for easy use with your monad stack, which lets you lift Fakes with liftFake.

import Faker.Class

betterLogQuote :: (MonadIO m, MonadLogger m, MonadFake m) => m ()
betterLogQuote = do
  userName <- liftIO getLine
  quote <- liftFake fact
  $(logInfo) $ "Chuck Norris" userName quote

slowFunction can be rewritten to be much faster, because the FakeT is shared between all the calls to fact.

fastFunction :: (MonadIO m, MonadLogger m) => m ()
fastFunction = generateNonDeterministic go
    go :: FakeT m ()
    go = replicateM 1000 logQuote

Comparision with other libraries

There are two other libraries in the Hackage providing fake data:

The problem with both the above libraries is that the library covers only a very small amount of fake data source. I wanted to have an equivalent functionality with something like faker. Also, most of the combinators in this packages has been inspired (read as taken) from the fake library. Also, fakedata offers fairly good amount of support of different locales. Also since we rely on an external data source, we get free updates and high quality data source with little effort. Also, it’s easier to extend the library with it’s own data source if we want to do it that way.


Benjamin Curtis for his Ruby faker library from which the data source is taken from.

Icons made by Freepik from Flaticon.


Changelog for fakedata


This is the behavior of generateNonDeterministic vs generate function:

> generate $ listOf 5 $ fromRange (1,100)
> generate $ listOf 5 $ fromRange (1,100)
> generateNonDeterministic $ listOf 5 $ fromRange (1,100)
> generateNonDeterministic $ listOf 5 $ fromRange (1,100)

As you can see with generate we get deterministic value output and they are all same in this case. With generateNonDeterministic function we use a different seed each time which results in generating different values.

There are times when we instead want to generate non deterministic values but with a fixed seed. And for such use case, we have implemented generateNonDeterministicWithFixedSeed function:

> generateNonDeterministicWithFixedSeed $ listOf 5 $ fromRange (1,100)
> generateNonDeterministicWithFixedSeed $ listOf 5 $ fromRange (1,100)


  • Make it compatible with aeson 1 and 2.



Breaking changes

  • Make Fake as monad transformer. This makes writing code with good performance easily.
  • Rename celebrities to actors in Faker.TvShow.Buffy module.
  • Rename celebrities to actors in Faker.TvShow.FreshPrinceOfBelAir module.
  • Removed module Faker.Movie.Hobbit. Use Faker.Fantasy.Tolkien instead.
  • Removed module Faker.Movie.LordOfTheRings. Use Faker.Fantasy.Tolkien instead.
  • Faker.Minecraft moved to Faker.Game.Minecraft
  • Faker.Game.WorldOfWarcraft: hero function renamed to heros

New modules introduced

  • Faker.Adjective
  • Faker.Creature.Bird
  • Faker.Camera
  • Faker.Game.ClashOfClans
  • Faker.JapaneseMedia.Conan
  • Faker.JapaneseMedia.Doraemon
  • Faker.TvShow.FinalSpace
  • Faker.Movie.HowToTrainYourDragon
  • Faker.Quote.JackHandey
  • Faker.Mountain
  • Faker.JapaneseMedia.Naruto
  • Faker.Movie.Room
  • Faker.Game.SuperMario
  • Faker.Tea
  • Faker.Fantasy.Tolkien
  • Faker.Game.Touhou
  • Faker.Sport.Volleyball

Module updates

  • Faker.JapaneseMedia.DragonBall: races, planets added.
  • Faker.DrivingLicense: usaNorthDakota added.
  • Faker.Book.Dune: cities added
  • Faker.Educator: primary and primarySchool added.
  • Faker.Game.ElderScrolls: weapon and jewelry added
  • Faker.Finance: tickerNasdaq and tickerNyse added
  • Faker.Game.Heroes: artifacts added.
  • Faker.Military: coast_guard_rank and space_force_rank added.
  • Faker.Game.Mincecraft: Following functions are added
    • achievement
    • biome
    • enchantment
    • gameMode
    • statusEffect
  • Faker.Music: mamboNo5 and hiphop functions added.
  • Various new functions added to Faker.Opera
  • Faker.Quote: fortuneCookie added.
  • Faker.Music.RockBand: song added.
  • Faker.Science: elementState and elementSubCategory added.
  • Various new functions added to Faker.Source.
  • Faker.Game.Witcher: signs, potions and books added.
  • Faker.Game.WorldOfWarcraft: classNames and races added.

Locale Improvements

  • es-AR localed added
  • id.yml: stateAbbr added
  • pt-BR: countryCode added, ingredients and licensePlate updated.
  • ru: Faker.Yoda.quotes added
  • uk: Faker.Address.fullAddress added
  • ja: Faker.Book, Faker.Commerce and Faker.Subscription module works now
  • fr: Faker.Creature.Animal, Faker.Gender works now

Data Update

The following data sources which the libraries uses has been updated:

  • de.yml
  • en/animal.yml
  • en/book.yml
  • en/company.yml
  • en/demographic.yml
  • en/device.yml
  • en/dota.yml
  • en/fallout.yml
  • en/football.yml
  • en/half_life.yml
  • en/heroes_of_the_storm.yml
  • en/horse.yml
  • en/kpop.yml
  • en/league_of_legends.yml
  • en/lebowski.yml
  • en/lovecraft.yml
  • en/myst.yml
  • en/overwatch.yml
  • en/pokemon.yml
  • en/shakespeare.yml
  • en/space.yml
  • en/street_fighter.yml
  • en/studio_ghibli.yml
  • en/super_smash_bros.yml
  • en-us.yml
  • en/zelda.yml


Breaking changes

  • Behavior of Monad instances changed. Monad instance by default will not change the underlying StdGen by default. It will change only when you do setNonDeterministic for the settings. If you use functions like listOf with generate function then all the values would be the same:
λ> import Faker.Coffee
λ> qs <- generate $ listOf 5 blendName
λ> qs
["The Treat","The Treat","The Treat","The Treat","The Treat"]

Now instead you have to use generateNonDeterministic function:

λ> qs <- generateNonDeterministic $ listOf 5 blendName
λ> qs
["The Treat","Evening Cowboy","Veranda Forrester","Blue Choice","Veranda Cake"]
  • Faker.Dnd: Remove species and background function. Other new function introduced. See Module update section.
  • Faker.Game.HeroesOfTheStorm: Rename classes function to classNames

New modules introduced

  • Faker.TvShow.BigBangTheory
  • Faker.Barcode
  • Faker.DrivingLicense
  • Faker.Drone
  • Faker.TvShow.Futurama
  • Faker.Game.Minecraft
  • Faker.Music.Prince
  • Faker.Music.Rush
  • Faker.Game.StreetFighter
  • Faker.JapaneseMedia.StudioGhibli

Locale Improvements

  • en-GB: Faker.Address.postcode
  • nl: Faker.Address.postcode
  • ru:
  • de-AT: PhoneNumber.countryCode
  • de-CH: PhoneNumber.countryCode
  • de: PhoneNumber.countryCode
  • en-au-ocker: PhoneNumber.countryCode
  • en-IND: PhoneNumber.countryCode
  • en-MS: PhoneNumber.countryCode
  • en-NEP: PhoneNumber.countryCode
  • en-NZ: PhoneNumber.countryCode
  • en-SG: PhoneNumber.countryCode
  • es: Vehicle.licensePlate
  • fr-CA: PhoneNumber.cellPhoneFormat, PhoneNumber.countryCode
  • fr: PhoneNumber.countryCode, Compass.direction
  • id: PhoneNumber.countryCode
  • it: PhoneNumber.countryCode
  • ko:, Space.planet, Space.galaxy, Gender.binaryTypes
  • nb-NO: PhoneNumber.countryCode
  • pt: PhoneNumber.countryCode
  • ru: PhoneNumber.countryCode
  • sk: PhoneNumber.countryCode

Module updates

  • Faker.TvShow.AquaTeenHungerForce: quote
  • Faker.DND: cities, languages, meleeWeapons, monsters, races, rangedWeapons
  • Faker.TvShow.Simpsons: episodeTitles
  • Faker.Movie.StarWars: quotesKyloRen

Data Update

The following data sources which the libraries uses has been updated:

  • en/animal.yml
  • en/aqua_teen_hunger_force.yml
  • en-AU.yml
  • en/bank.yml
  • en-GB.yml
  • en-IND.yml
  • en/star_trek.yml
  • en-US.yml
  • fi-FI.yml
  • fr-CA.yml
  • fr-CH.yml
  • fr.yml
  • id.yml
  • it.yml


  • Add combinator for fakeBoundedEnum In Faker.Combinators
  • Improved Haddock documentation for Faker.Combinators


  • Add support for regex fake value generation. Useful for postcode functions for different locales.
  • Improve documentation of Faker.Combinators.
  • de-CH locale update: lastName function works now.
  • New function in Faker.Music.Phish module: albums, musicians
  • New function in Faker.Address: cityWithState
  • New function in Faker.Movie: title

Data Update

The following data sources which the libraries uses has been updated:

  • heroes_of_the_storm.yml
  • house.yml
  • name.yml
  • one_piece.yml

New modules introduced

  • Faker.Blood
  • Faker.Chiquito
  • Faker.Computer
  • Faker.Game.Control
  • Faker.Movie.Departed
  • Faker.Dnd
  • Faker.Music.PearlJam
  • Faker.Rajnikanth
  • Faker.Show
  • Faker.TvShow.Suits
  • Faker.WarhammerFantasy

Locale Improvements

  • en-AU:
    • Locale has updated which leads to working of newer functions: Faker.Name.prefix,,
  • en-CA: Faker.Address.postcode works now.
  • en-GB: formats field has been updated.
  • fr-CA: Faker.Address.postcode works now.
  • ko: Supports Faker.Commerce moudle now.

Breaking changes

  • Faker.Music.Phish module:
    • Rename song function to songs


  • Add Semigroup and Monoid instances to Fake
  • Doc fix: Remove broken links


  • Fix API for “ar” locale. Add test coverage.
  • Bug fixed in the following locales: ca, bg, da-DK, en-NEP, en-ZA, fr-CA, fr-CH, fr, hy, id, ja, pt, uk, zh-CN, zh-TW
  • New function to Address module: mailBox
  • Update in following data sources:
    • en/color.yml
    • en-NZ.yml
    • en/overwatch.yml
    • en/phone_number.yml
    • en/shakespeare.yml
    • fa.yml
    • pt-BR.yml
  • New function in Educator module: degree, courseName
  • New function in Gender module: shortBinaryTypes

Breaking changes

  • Educator module:
    • Rename tertiaryDegreeSubject to subject
    • Rename name function to schoolName
    • Rename tertiaryType function to tertiaryUniversityType.


  • Move remaining internal modules into other-module: Config, Faker.TH


  • Move Provider modules into other-modules. This makes the haddock much more readable.
  • Update to various en data sources: color.yml, super_smash_bros.
  • Fix name of FakerTvShow.DrWho module: villains (from villians).
  • New locale addition: en-TH, th
  • Modification of other locales: fr-CA, ja


  • Make it compatbile with ghc-8.8.1


  • Update fake data source
  • Improve performance and add test coverage
  • Fix various bugs
  • Add brands function to the module Faker.Cannabis


  • Add meepoQuote function to the module Faker.Game.Dota
  • Add Faker.Music.Opera module
  • Update fake data source


  • Fix bug in Book module


  • Add sicCode function in Company module
  • New Construction module
  • New Basketball module
  • New Horse module
  • New Finance module
  • Move Football under Sport module
  • Bug fixes in some file formats
  • Fix bugs in the Creature module
  • Add for new contributors

Initial version released