mirror of
https://github.com/Lysxia/generic-random.git
synced 2024-10-26 09:41:05 +03:00
Update aeson example
This commit is contained in:
parent
e52dda0ab1
commit
43d5c14691
@ -8,8 +8,8 @@ import qualified Data.Text as Text
|
||||
import Test.QuickCheck
|
||||
import Data.Random.Generics
|
||||
|
||||
genValue :: Int -> Gen Value
|
||||
genValue = pointedGeneratorWith aliases asGen
|
||||
instance Arbitrary Value where
|
||||
arbitrary = sized $ pointedGeneratorWith aliases asGen
|
||||
|
||||
aliases :: [Alias Gen]
|
||||
aliases =
|
||||
@ -17,8 +17,10 @@ aliases =
|
||||
, alias $ return . (Vector.fromList :: [Value] -> _)
|
||||
, alias $ \ () -> fmap (realToFrac :: Double -> Scientific) arbitrary
|
||||
, alias $ return . Text.pack
|
||||
, alias $ \ ~[()] -> arbitrary :: Gen String
|
||||
, alias $ (const arbitrary :: [()] -> Gen String)
|
||||
]
|
||||
|
||||
main :: IO ()
|
||||
main = sample (sized genValue)
|
||||
main = do
|
||||
sample (arbitrary :: Gen Value)
|
||||
quickCheck $ \(v :: Value) -> (decode . encode) v === Just v
|
||||
|
@ -3,9 +3,9 @@ version: 0
|
||||
build-type: Simple
|
||||
cabal-version: >=1.10
|
||||
|
||||
executable aeson
|
||||
executable aeson-example
|
||||
main-is: aeson.hs
|
||||
ghc-options: -Wall
|
||||
ghc-options: -Wall -fno-warn-partial-type-signatures
|
||||
build-depends:
|
||||
aeson,
|
||||
base,
|
||||
@ -17,7 +17,7 @@ executable aeson
|
||||
generic-random
|
||||
default-language: Haskell2010
|
||||
|
||||
executable functions
|
||||
executable functions-example
|
||||
main-is: functions.hs
|
||||
ghc-options: -Wall
|
||||
build-depends:
|
||||
@ -26,7 +26,7 @@ executable functions
|
||||
generic-random
|
||||
default-language: Haskell2010
|
||||
|
||||
executable positive-ints
|
||||
executable positive-ints-example
|
||||
main-is: positive-ints.hs
|
||||
ghc-options: -Wall
|
||||
build-depends:
|
||||
|
Loading…
Reference in New Issue
Block a user