Skip to content
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

Relation generator #14

Merged
merged 1 commit into from
Dec 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion relation.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ test-suite relation-test
type: exitcode-stdio-1.0
main-is: Spec.hs
build-depends: relation
other-modules: Data.RelationSpec
other-modules: Data.Relation.Gen
, Data.RelationSpec
, Paths_relation
autogen-modules: Paths_relation
hs-source-dirs: test
Expand Down
13 changes: 13 additions & 0 deletions test/Data/Relation/Gen.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Data.Relation.Gen
( relation
) where

import Data.Relation
import Hedgehog
import Hedgehog.Range (Range)

import qualified Hedgehog.Gen as G

-- | Generate a relation given generators for the domain and range.
relation :: (MonadGen m, Ord a, Ord b) => Range Int -> m a -> m b -> m (Relation a b)
relation r ga gb = fmap fromList (G.list r ((,) <$> ga <*> gb))