Search Haskell Channel Logs

Sunday, February 5, 2017

#haskell channel featuring erisco, jle`, Koterpillar, hoppfull, filthyCausual, lordcirth, and 5 others.

noan 2017-02-05 12:55:59
If anyone knows Matt Parsons, thank him for me for http://www.parsonsmatt.org/2015/06/07/servant-persistent.html
noan 2017-02-05 12:56:07
That man has saved me a lot of headaches.
hoppfull 2017-02-05 12:57:02
Hey, what's up? I just checked out property based testing and it's really cool. Very terse. I wonder what you guys think about keeping tests together with implementation in the same source files.
hoppfull 2017-02-05 12:57:27
Property based tests say a lot about intended use so code becomes self documenting.
jle` 2017-02-05 13:00:15
sometimes people include them with implementations as doctests
jle` 2017-02-05 13:00:57
like, writing property tests as a part of the documentation for the functions, and having the CI suite detect and run them
hoppfull 2017-02-05 13:02:15
Cool
erisco 2017-02-05 13:02:56
what is a property test?
hoppfull 2017-02-05 13:03:54
Tomorrow me and my friend starts writing code for our thesis. It's in C# but it's still quite terse so I started thinking that maybe it would be a good idea to keep tests together with implementation. http://pastebin.com/i94G2s2n
hoppfull 2017-02-05 13:04:10
erisco: Check out this: http://pastebin.com/i94G2s2n
erisco 2017-02-05 13:04:32
hm, I still have the same question
hoppfull 2017-02-05 13:04:43
erisco: Basically the tests checks that f(x) always returns a positive number
erisco 2017-02-05 13:04:51
how does it do that?
hoppfull 2017-02-05 13:04:53
erisco: I just came here, perhaps I can help you.
hoppfull 2017-02-05 13:05:42
erisco: It seems to generate a whole bunch of random numbers and when it finds something that disproves your assertion, it starts looking for the simplest case that disprove it and tells you about it.
erisco 2017-02-05 13:05:54
so, it is just unit testing
hoppfull 2017-02-05 13:06:56
It fills the same function. Though I am not sure if it is strictly unit testing.
hoppfull 2017-02-05 13:07:01
I'm pretty new to this.
filthyCausual 2017-02-05 13:07:02
Sort of? I find that the random generation finds more bugs then traditional unit test would.
nshepperd 2017-02-05 13:07:17
well, sort of, but usually tests conceived as 'unit tests' have a fixed input-output pair
erisco 2017-02-05 13:07:36
depends on how you write unit tests. I've never written them that way
hoppfull 2017-02-05 13:07:44
filthyCasual: It seems like the world of functional programming is lifting another weight off my shoulder.
erisco 2017-02-05 13:07:48
I write them in terms of relations
nshepperd 2017-02-05 13:08:06
proptests aim to test forall x y. statements
erisco 2017-02-05 13:08:41
random inputs isn't good for reproducibility of test failures (or successes)
hoppfull 2017-02-05 13:08:57
Please note that I am not an experienced programmer. Only last friday did I land an internship (where they use F#) so I am quite inexperienced.
Koterpillar 2017-02-05 13:09:26
erisco: correct, but it is good for finding edge cases
nshepperd 2017-02-05 13:09:42
erisco: quickCheck prints out the failing input
erisco 2017-02-05 13:09:44
why not generate some random inputs and paste them in as the test cases
erisco 2017-02-05 13:09:48
then you get one consistent list
nshepperd 2017-02-05 13:10:02
because that has less coverage
nshepperd 2017-02-05 13:10:14
why have less coverage when you can have more
Koterpillar 2017-02-05 13:10:27
erisco: because letting quickcheck do it is easier
Koterpillar 2017-02-05 13:10:38
erisco: especially since you don't have to worry about the types
erisco 2017-02-05 13:10:47
there is quickcheck for C#?
hoppfull 2017-02-05 13:10:53
FsCheck
hoppfull 2017-02-05 13:10:58
http://pastebin.com/i94G2s2n
nshepperd 2017-02-05 13:11:09
iirc quickcheck can also be made to print out a command to reproduce an exact test case, by supplying the seed or something
Koterpillar 2017-02-05 13:11:48
Is there an option to "pin" a test, so that a particular edge case is always executed?
erisco 2017-02-05 13:12:13
hm, well I can see the validity of the arguments for random tests
hoppfull 2017-02-05 13:12:28
In case of C# instead of using [Property] you just use [Fact] and test a single specific case.
erisco 2017-02-05 13:12:33
still am not excited about the idea
erisco 2017-02-05 13:13:40
you definitely want at least some consistent lists of tests
erisco 2017-02-05 13:13:47
otherwise how are you supposed to prevent regressions
hoppfull 2017-02-05 13:13:52
erisco: As someone who isn't very experienced with TDD, I'd love to learn more about your scepticism. What do you think could go wrong with this kind of philosophy?
erisco 2017-02-05 13:14:12
a consistent list of tests + random tests seems alright
hoppfull 2017-02-05 13:14:42
erisco: That sounds reasonable!
nshepperd 2017-02-05 13:15:06
Koterpillar: I dunno if in quickcheck itself, but a framework like tasty would let you add tests alongside a QuickCheck test that just applies the test with some explicit arguments
hoppfull 2017-02-05 13:15:21
erisco: What's a regression test?
erisco 2017-02-05 13:15:21
well there is the issue I just stated i.e. regressions, but then also I am concerned about reproducing the errors
nshepperd 2017-02-05 13:15:22
i think
erisco 2017-02-05 13:15:40
if I get the error then how do I easily give this to my coworker to fix?
nshepperd 2017-02-05 13:15:47
like you can turn a proptest into a normal unit test by just applying it to some arguments
erisco 2017-02-05 13:15:49
if that is easy then not a problem
Koterpillar 2017-02-05 13:16:10
erisco: QuickCheck lets you set an environment variable to a seed, which is printed on failure
erisco 2017-02-05 13:16:23
hoppfull, once you discover there is an error you want to add a test that reproduces this error. Then you fix the error and the test passes. If someone makes the same boo-boo again this test will catch it
erisco 2017-02-05 13:16:34
if your tests are only random then you do not have this assurance
nshepperd 2017-02-05 13:16:44
erisco: sure, when it fails it prints out the failing input. then you can just say 'test xyz fails with inputs foobar! fix it!'
hoppfull 2017-02-05 13:17:16
What are regressions?
erisco 2017-02-05 13:17:33
things that break which were not broken before
lordcirth 2017-02-05 13:17:37
hoppfull, regressions are when something that used to work, doesn't.
hoppfull 2017-02-05 13:17:39
ah
lordcirth 2017-02-05 13:17:42
ie, going backwards
hoppfull 2017-02-05 13:17:45
Fascinating
lordcirth 2017-02-05 13:17:59
as opposed to a bug in a new feature, which is less bad
nshepperd 2017-02-05 13:20:48
the problem with unit tests is you straight up forget to include the corner cases, which proptests would automatically find. so a mixture of boths gets the best of both worlds imo
Tuplanolla 2017-02-05 13:22:45
I see `Network.Socket` supports some `AF_CAN`. What is it?
davean 2017-02-05 13:22:47
nshepperd: sadly I find the only thing good at finding the corner cases is a skilled hostile tester
davean 2017-02-05 13:23:27
Tuplanolla: https://en.wikipedia.org/wiki/SocketCAN
Tuplanolla 2017-02-05 13:24:09
I see some talk about drivers.
davean 2017-02-05 13:24:17
?
Tuplanolla 2017-02-05 13:24:55
This seems to explain it better: https://www.kernel.org/doc/Documentation/networking/can.txt
erisco 2017-02-05 13:24:55
nshepperd, why do you forget? I try not to :P
Tuplanolla 2017-02-05 13:25:06
I still don't know if I want to touch it though.
Koterpillar 2017-02-05 13:25:38
Tuplanolla: "if you don't know what it is, you don't need it"
erisco 2017-02-05 13:25:45
it isn't particularly difficult. Ints? -2, -1, 0, 1, 2 and some values around that
erisco 2017-02-05 13:25:56
lists? empty list, singleton list, list of two elements, then some other lists
Koterpillar 2017-02-05 13:26:00
erisco: graphs?
erisco 2017-02-05 13:26:08
what is your encoding?
nshepperd 2017-02-05 13:26:19
erisco: "If I should not forget the corner cases, I wouldst not need for tests"
Koterpillar 2017-02-05 13:27:06
erisco: doesn't matter. These structures and algorithms on them might have a corner case of "a perfectly balanced tree", say
erisco 2017-02-05 13:27:27
sure, but you're just hoping random tests stumble on these
erisco 2017-02-05 13:27:35
which is arguably better than nothing guessing
mbw 2017-02-05 13:29:03
Are there any resources on *learning* Http/sockets/web programming with Haskell that do not assume any prior knowledge?
nshepperd 2017-02-05 13:30:03
it's better than hoping that I'll stumble on them. I'm not even random! and you can't run me 1000 times a day :p
erisco 2017-02-05 13:30:45
I'm fine with that. I just don't want anyone too satisfied with it :P
Koterpillar 2017-02-05 13:31:01
all of these are just some approximations of proofs
erisco 2017-02-05 13:31:12
exactly
Koterpillar 2017-02-05 13:31:21
"it runs on -1, 0, 1" "it runs on 1000 random cases"
Koterpillar 2017-02-05 13:32:06
doesn't beat "it runs, QED"
erisco 2017-02-05 13:34:30
there was a project called Code Contracts for C# which tried to do some verification... it is still kicking but not much
Koterpillar 2017-02-05 13:35:26
do they have compiler integration?
Koterpillar 2017-02-05 13:36:27
also, http://joeduffyblog.com/2016/02/07/the-error-model/
erisco 2017-02-05 13:36:50
the main bit is a preprocessor. I am guessing it leverages the compiler to do analysis
Koterpillar 2017-02-05 13:37:40
it's easy to specify contracts and enforce them at runtime (Ruby has a library, for example), but that doesn't help with proofs
erisco 2017-02-05 13:38:13
it does static verification and optionally will put in runtime checks for what it cannot prove
erisco 2017-02-05 13:40:06
hoppfull, also, your test fails
Koterpillar 2017-02-05 13:40:42
not if I didn't think of the edge case (or quickcheck didn't find it)
erisco 2017-02-05 13:41:32
I thought of it :P
hoppfull 2017-02-05 13:42:08
erisco: I tried to get code contracts to work for compile time static checking but it isn't working in latest versions of visual studio. It's basically just runtime checking right now.
Koterpillar 2017-02-05 13:42:09
oh! I misread that nick as "hopefully, also, your test fails"
erisco 2017-02-05 13:42:28
hoppfull, I had a miserable time with it. I couldn't recommend it
hoppfull 2017-02-05 13:43:29
erisco: It seemed cool a two years ago when it worked. It was like getting refinement types in C#.