From 88c8d226cbd558a61b54f35fb4e56ffe4b9f2f05 Mon Sep 17 00:00:00 2001 From: Alexey Gaziev Date: Wed, 21 Jan 2015 01:31:25 +0800 Subject: [PATCH] Docs for Faker.Lorem --- src/Faker/Lorem.hs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Faker/Lorem.hs b/src/Faker/Lorem.hs index 100be31..56f9e9d 100644 --- a/src/Faker/Lorem.hs +++ b/src/Faker/Lorem.hs @@ -1,5 +1,17 @@ +{-| +Module : Faker.Lorem +Description : Module for generating fake words, sentences and paragraphs +Copyright : (c) Alexey Gaziev, 2015 +License : MIT +Maintainer : alex.gaziev@gmail.com +Stability : experimental +Portability : POSIX + +Fake data +-} module Faker.Lorem ( +-- * Functions for generate fake words, sentences and paragraphs word , words , character @@ -15,9 +27,11 @@ import Faker.Utils import Prelude hiding (words) import Data.Char +-- | Returns random word, i.e. "recusandae" word :: Faker String word = randomLoremWord "words" +-- | Returns random word or supplemental word, i.e. "benevolentia" wordOrSupplemental :: Faker String wordOrSupplemental = do ind <- randomInt (0,1) @@ -25,18 +39,23 @@ wordOrSupplemental = do 0 -> word _ -> randomLoremWord "supplemental" +-- | Returns list of random words with size of provided num, +-- i.e. ["alveus","ademptio","arcus","autem","nihil"] words :: Int -> Faker [String] words num = sequence $ replicate num wordOrSupplemental +-- | Returns random character, i.e. 'a' character :: Faker Char character = do w <- word ind <- randomInt (0, length w - 1) return $ w !! ind +-- | Returns random characters with size of provided num, i.e. "afasde" characters :: Int -> Faker [Char] characters num = sequence $ replicate num character +-- | Returns random sentence, i.e. "Ultio et solus uter nisi." sentence :: Faker String sentence = do ws <- randomInt (3,12) >>= words @@ -44,12 +63,17 @@ sentence = do result = (toUpper $ head sentence) : tail sentence ++ "." return result +-- | Returns list of random sentences with size of provided num, +-- i.e. ["Optio ago aliquid magnam bestia dolores unde.","Villa recusandae velociter assumenda."] sentences :: Int -> Faker [String] sentences num = sequence $ replicate num sentence +-- | Returns paragraph, of random sentences (from 3 to 6), +-- i.e. "Cupressus atque civis perferendis viduo dolorem conor appositus tempore cunae. Veritatis ut tot est. Valde temperantia necessitatibus sint celo uterque sequi aduro itaque officiis quam. Statim cribro et subvenio." paragraph :: Faker String paragraph = randomInt (3,6) >>= sentences >>= return . unwords +-- | Returns list of random paragraphs with size of provided num paragraphs :: Int -> Faker [String] paragraphs num = sequence $ replicate num paragraph