-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleanup: Remove Arbitrary instance from main library.
Reducing dependencies.
- Loading branch information
Showing
3 changed files
with
38 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{-# OPTIONS_GHC -fno-warn-orphans #-} | ||
{-# LANGUAGE StrictData #-} | ||
{-# LANGUAGE Trustworthy #-} | ||
module Data.MessagePack.Arbitrary () where | ||
|
||
import qualified Data.ByteString as S | ||
import Data.MessagePack.Types (Object (..)) | ||
import qualified Data.Text as T | ||
import qualified Data.Vector as V | ||
import Test.QuickCheck.Arbitrary (Arbitrary, arbitrary) | ||
import qualified Test.QuickCheck.Gen as Gen | ||
|
||
|
||
instance Arbitrary Object where | ||
arbitrary = Gen.sized $ \n -> Gen.oneof | ||
[ pure ObjectNil | ||
, ObjectBool <$> arbitrary | ||
, ObjectInt <$> negatives | ||
, ObjectWord <$> arbitrary | ||
, ObjectFloat <$> arbitrary | ||
, ObjectDouble <$> arbitrary | ||
, ObjectStr <$> (T.pack <$> arbitrary) | ||
, ObjectBin <$> (S.pack <$> arbitrary) | ||
, ObjectArray <$> (V.fromList <$> Gen.resize (n `div` 2) arbitrary) | ||
, ObjectMap <$> (V.fromList <$> Gen.resize (n `div` 4) arbitrary) | ||
, ObjectExt <$> arbitrary <*> (S.pack <$> arbitrary) | ||
] | ||
where negatives = Gen.choose (minBound, -1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters