-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NonEmpty ToSchema instance #141
Closed
Closed
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a1dbad9
Add ToSchema NonEmpty instance for GHC 8.
eda447e
(squash-me) support GHC 7.x
8a2bdca
Merge branch 'master' into master
parsonsmatt 361415b
Add semigroups build dep
parsonsmatt 4ddca11
Fix tests
parsonsmatt edd2ed0
use quickcheck-instances
parsonsmatt 50106b3
Remove unused instance code
parsonsmatt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -16,6 +16,7 @@ import "unordered-containers" Data.HashSet (HashSet) | |
import qualified "unordered-containers" Data.HashSet as HashSet | ||
import Data.HashMap.Strict (HashMap) | ||
import qualified Data.HashMap.Strict as HashMap | ||
import Data.List.NonEmpty (NonEmpty(..), nonEmpty) | ||
import Data.Map (Map) | ||
import Data.Monoid (mempty) | ||
import Data.Proxy | ||
|
@@ -69,6 +70,7 @@ spec = do | |
-- prop "(Maybe [Int])" $ shouldValidate (Proxy :: Proxy (Maybe [Int])) | ||
prop "(IntMap String)" $ shouldValidate (Proxy :: Proxy (IntMap String)) | ||
prop "(Set Bool)" $ shouldValidate (Proxy :: Proxy (Set Bool)) | ||
prop "(NonEmpty Bool)" $ shouldValidate (Proxy :: Proxy (NonEmpty Bool)) | ||
prop "(HashSet Bool)" $ shouldValidate (Proxy :: Proxy (HashSet Bool)) | ||
prop "(Either Int String)" $ shouldValidate (Proxy :: Proxy (Either Int String)) | ||
prop "(Int, String)" $ shouldValidate (Proxy :: Proxy (Int, String)) | ||
|
@@ -260,3 +262,13 @@ instance Arbitrary ZonedTime where | |
|
||
instance Arbitrary UTCTime where | ||
arbitrary = UTCTime <$> arbitrary <*> fmap fromInteger (choose (0, 86400)) | ||
|
||
#if MIN_VERSION_QuickCheck(2,10,0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
-- This instance was removed in QuickCheck 2.10 because of dependencies. | ||
-- The instance is available in `quickcheck-instances` package, but that | ||
-- introduces a ton of conflicts with the other instances here. | ||
|
||
instance Arbitrary a => Arbitrary (NonEmpty a) where | ||
arbitrary = liftA2 (:|) arbitrary arbitrary | ||
shrink (x :| xs) = mapMaybe nonEmpty (shrink (x:xs)) | ||
#endif |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to specify bounds in test-suite (as they are inherited from library). This helps if/when
semigroups-0.19
is released.