fakedata 0.3.0 → 0.3.1
raw patch · 4 files changed
+34/−22 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Faker: ParseError :: String -> FakerException
Files
- ChangeLog.md +4/−0
- fakedata.cabal +2/−2
- src/Config.hs +8/−4
- src/Faker.hs +20/−16
ChangeLog.md view
@@ -1,5 +1,9 @@ # Changelog for fakedata +## 0.3.1++* Make it compatbile with ghc-8.8.1+ ## 0.3.0 * Update fake data source
fakedata.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: be5c05f79b0f39b9b500b1e935b69e331f6bb4f7120972b17688182b7d098a8a+-- hash: b6a65970d5f1dbdf544a14cc669dc23f816ed4bf82309326c0e5f76a916409f1 name: fakedata-version: 0.3.0+version: 0.3.1 synopsis: Library for producing fake data description: Please see the README on GitHub at <https://github.com/psibi/fakedata#readme> category: Random, Fake, FakeData
src/Config.hs view
@@ -384,8 +384,9 @@ yaml <- decodeThrow bs let nhash = HM.insert ckey yaml cache liftIO $ setCacheFile nhash settings- parseMonad (parser settings) yaml- Just yaml -> parseMonad (parser settings) yaml+ either (throwM . ParseError) pure (parseEither (parser settings) yaml)+ Just yaml ->+ either (throwM . ParseError) pure (parseEither (parser settings) yaml) fetchDataSingle :: (MonadThrow m, MonadIO m)@@ -405,5 +406,8 @@ yaml <- decodeThrow bs let nhash = HM.insert ckey yaml cache liftIO $ setCacheFile nhash settings- pure <$> parseMonad (parser settings) yaml- Just yaml -> pure <$> parseMonad (parser settings) yaml+ pure <$>+ either (throwM . ParseError) pure (parseEither (parser settings) yaml)+ Just yaml ->+ pure <$>+ either (throwM . ParseError) pure (parseEither (parser settings) yaml)
src/Faker.hs view
@@ -39,23 +39,24 @@ import Data.Text (Text) import Data.Typeable import Data.Vector (Vector)-import Data.Yaml (Value) import Data.Word (Word64)+import Data.Yaml (Value) import Faker.Internal.Types (CacheFieldKey, CacheFileKey)-import System.Random (StdGen, newStdGen, split, mkStdGen)+import System.Random (StdGen, mkStdGen, newStdGen, split) -data FakerSettings =- FakerSettings- { fslocale :: !Text -- ^ Locale settings for your fake data source.- , fsrandomGen :: !StdGen -- ^ Seed to initialize random generator state- , fsDeterministic :: !Bool -- ^ Controls whether you want+data FakerSettings = FakerSettings+ { fslocale :: !Text -- ^ Locale settings for your fake data source.+ , fsrandomGen :: !StdGen -- ^ Seed to initialize random generator state+ , fsDeterministic :: !Bool -- ^ Controls whether you want -- deterministic out. This overrides -- 'fsrandomGen'.- , fsCacheField :: (IORef (HM.HashMap CacheFieldKey (Vector Text)))- , fsCacheFile :: (IORef (HM.HashMap CacheFileKey Value))- }+ , fsCacheField :: (IORef (HM.HashMap CacheFieldKey (Vector Text)))+ , fsCacheFile :: (IORef (HM.HashMap CacheFileKey Value))+ } -newtype FakerGen = FakerGen { unFakerGen :: (Int, StdGen)} deriving (Show)+newtype FakerGen = FakerGen+ { unFakerGen :: (Int, StdGen)+ } deriving (Show) instance Show FakerSettings where show (FakerSettings {..}) =@@ -65,12 +66,16 @@ = InvalidLocale String -- ^ This is thrown when it is not able to -- find the fake data source for your -- localization.- | InvalidField String Text -- ^ The 'String' represents the field it is+ | InvalidField String+ Text -- ^ The 'String' represents the field it is -- trying to resolve and the 'Text' field -- is something you passed on. | NoDataFound FakerSettings -- ^ This is thrown when you have no -- data. This may likely happen for -- locales other than `en`.+ | ParseError String -- ^ This is thrown when the parsing step+ -- fails. The 'String' represents the error+ -- message. deriving (Typeable, Show) instance Exception FakerException@@ -167,10 +172,9 @@ -- | Fake data type. This is the type you will be using to produce -- fake values.-newtype Fake a =- Fake- { unFake :: FakerSettings -> IO a- }+newtype Fake a = Fake+ { unFake :: FakerSettings -> IO a+ } instance Functor Fake where fmap :: (a -> b) -> Fake a -> Fake b