# test-check

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

andrea.crotti 01:46:27

I was wondering, if I have some constraints I want to apply with such-that

andrea.crotti 01:46:47

should they be as early as possible in the generator definition or as late as possible?

andrea.crotti 01:47:00

I would guess better to cut early to avoid extra computation

andrea.crotti 01:47:42

(and it's pretty awesome actually I have to say)

gfredericks 03:26:50

@andrea.crotti yep, earlier is better as you say

andrea.crotti 11:20:01

cool thanks @gfredericks

andrea.crotti 11:20:23

another thing, suppose I have a bag with a limited number of objects in it per type

andrea.crotti 11:21:09

at the moment what I'm doing is to generate sequences picking random types and applying constraints to be sure there are never too many of a certain type

andrea.crotti 11:21:54

I guess there is probably a more efficient way?
in theory it's just a random selection in a list, removing the element selected each time

andrea.crotti 11:22:15

any more idiomatic way to do that with test.check @gfredericks ?

andrea.crotti 12:20:38

btw it looks like it's not possible to file an issue here

andrea.crotti 12:20:56

and there is no mention in the readme about how to do that either

gfredericks 16:32:01

@andrea.crotti clojure and all the contribs are managed on

gfredericks 16:33:01

This is mentioned in the readme under Contributing

gfredericks 16:34:55

I don't quite understand the requirements for your bag of limited number of objects question -- it would help if you could share the code you have that does that

andrea.crotti 16:34:58

Ah sorry my bad

andrea.crotti 16:35:22

It's the link I shared yesterday

andrea.crotti 16:35:43

Just the usual scrabble bag of letters

gfredericks 16:36:28

Oh so the main constraint is you can't have too many of each letter?

andrea.crotti 16:36:46

Yes, there is a max quantity for each

andrea.crotti 16:37:09

And applying constraints would work but I bet it's not really efficient

gfredericks 16:37:24

Do you care about distribution/shrinking?

andrea.crotti 16:37:26

Maybe I can write my own generator

andrea.crotti 16:37:55

Potentially yes

gfredericks 16:39:39

One idea is to generate a size (gen/nat) and a shuffling of a complete collection of letters, and then fmap with (take size shuffled)

gfredericks 16:40:01

gen/shuffle for doing the shuffling

gfredericks 16:40:58

That still does some throwaway work but it's at least conceptually simple and easy to tweak

gfredericks 16:41:24

And gives you a realistic distribution in a certain sense

andrea.crotti 18:06:44

ah cool yes I can check

andrea.crotti 18:06:50

thanks for the idea

andrea.crotti 18:07:02

writing your own generator would be problematic?

andrea.crotti 18:07:43

about the issue I wanted to raise, I just wanted to say that now both "generators" and "combinators" are both in the same namespace

andrea.crotti 18:08:13

and even have the same prefixed name, even if they have two quite different roles from my undertanding

andrea.crotti 18:08:42

that's all I wanted to mention really

gfredericks 18:45:54

@andrea.crotti what do you mean by "writing your own generator"? I would call what I just described writing your own generator

andrea.crotti 18:46:46

ah ok but if it's just built using the "official" combinators and generators

andrea.crotti 18:46:51

does it count as my custom generator?

gfredericks 18:48:20

@andrea.crotti test.check is designed so that you shouldn't need to go beyond those

gfredericks 18:48:35

so we don't usually talk about anything more custom than that

gfredericks 18:52:30

if you have something you think you can't do with the combinators I'd be happy to look at it

andrea.crotti 19:19:09

ok great thanks