`Serial` and `CoSerial` orphan instances for common types

9 weergaven
Naar het eerste ongelezen bericht

Danny Navarro

ongelezen,
24 apr 2015, 13:34:3924-04-2015
aan haskel...@googlegroups.com, Roman Cheplyaka
I'm writing the equivalent of `quickcheck-instances`[1] for
`smallcheck`. You can check it at
https://github.com/jdnavarro/smallcheck-instances

Right now I added `Serial` and `CoSerial` instances for `Text` and
`ByteString`. I'm planning to add some more instances from
`containers` and `unordered-containers`. But before I go any further
I'd like ask:

* Do you know any package out there doing something similar? I've
looked in the reverse dependencies of `smallcheck` but haven't found
anything.

* Is the implementation of what I have so far for `ByteString` and
`Text` what you would expect [2]? I tried to mimic the `[a]` from
`smallcheck`.

* Any particular instance coming, from the GHC core libraries, you'd
like to see included?

[1]: https://hackage.haskell.org/package/quickcheck-instances
[2]: https://github.com/jdnavarro/smallcheck-instances/blob/master/Test/SmallCheck/Instances.hs

--
Danny Navarro | http://dannynavarro.net

Roman Cheplyaka

ongelezen,
24 apr 2015, 13:52:3224-04-2015
aan Danny Navarro, haskel...@googlegroups.com
Great, this is very useful.

For things like ByteString and Text, it would be useful to have
different Series generators (as either a replacement or an addition to
Serial instances).

Having an instance/generator cover too much will make checking
inefficient or even impossible; having it cover too little obviously
isn't great either.

Some options for Text would be:

1. The most economical: generate strings

generate $ \n -> replicate n 'a'

It's often the code doesn't pay attention to what's actually inside
the strings, so no need to have a diversity here.

2. A bit more interesting: strings of 'a', 'b', 'c'.

3. For text processing needs, something more exhaustive, trying to
cover different parts of the Unicode (including non-BMP, combining
characters etc.).

4. For using Text as names: a subset (of length n) of some English
words or names. Similar to 1., but nicer to see on the screen.

Danny Navarro

ongelezen,
24 apr 2015, 16:23:3424-04-2015
aan Roman Cheplyaka, haskel...@googlegroups.com

I'll make wrappers for the cases you mention. Maybe there is no need to provide orphan instances at all, I'm realizing now that there is no clear default behavior.

--
You received this message because you are subscribed to the Google Groups "tasty" group.
To unsubscribe from this group and stop receiving emails from it, send an email to haskell-tast...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Roman Cheplyaka

ongelezen,
24 apr 2015, 16:34:2224-04-2015
aan Danny Navarro, haskel...@googlegroups.com
You could make wrappers, although IMO a clearer solution would be to
export simple values of type Series m a. The user can then use these
values to declare the instance or with the 'over' combinator.

On 24/04/15 23:23, Danny Navarro wrote:
> I'll make wrappers for the cases you mention. Maybe there is no need to
> provide orphan instances at all, I'm realizing now that there is no
> clear default behavior.
>
> On Apr 24, 2015 7:52 PM, "Roman Cheplyaka" <ro...@ro-che.info

Danny Navarro

ongelezen,
24 apr 2015, 16:58:5224-04-2015
aan Roman Cheplyaka, haskel...@googlegroups.com

Agreed, simple values provides more flexibility to the user.

Allen beantwoorden
Auteur beantwoorden
Doorsturen
0 nieuwe berichten