Logs: liberachat/#haskell
| 2021-07-21 23:29:37 | → | ski joins (~ski@ed-3358-10.studat.chalmers.se) |
| 2021-07-21 23:30:11 | → | shutdown_-h_now joins (~arjan@82-75-187-100.cable.dynamic.v4.ziggo.nl) |
| 2021-07-21 23:30:40 | <Boarders> | or alternatively is there a += that also returns the old value |
| 2021-07-21 23:31:52 | <arkanoid> | what's the quickest way to test a function in a module? I'm working with vscode + haskell extension, but I feel that adding a main is not the haskell way |
| 2021-07-21 23:32:34 | <dsal> | arkanoid: are you doing exercism? It comes with a test suite. |
| 2021-07-21 23:33:48 | <Boarders> | arkanoid: load in repl? |
| 2021-07-21 23:34:07 | <dsal> | @check (3 `notElem`) |
| 2021-07-21 23:34:09 | <lambdabot> | *** Failed! Falsifiable (after 13 tests and 4 shrinks): |
| 2021-07-21 23:34:09 | <lambdabot> | [2,-3,-12,-9,10,10,-10,3,-6,-10,12,11] |
| 2021-07-21 23:34:10 | × | dibblego quits (~dibblego@haskell/developer/dibblego) (Ping timeout: 252 seconds) |
| 2021-07-21 23:34:11 | <jeetelongname> | arkanoid: yeah I was about to reccomend using ghci |
| 2021-07-21 23:34:21 | → | MQ-17J joins (~MQ-17J@d14-69-206-129.try.wideopenwest.com) |
| 2021-07-21 23:34:33 | <dsal> | That's not the best shrinking. But super impressed how quickcheck proved me wrong when I thought 3 couldn't be in a list. |
| 2021-07-21 23:34:40 | <arkanoid> | dsal: yes, I do check the results of the required func with stack test. But if I add other funcs I should also modify the test case and so on. Not really so quick |
| 2021-07-21 23:34:51 | <dsal> | arkanoid: You can add to the test cases. |
| 2021-07-21 23:35:23 | <dsal> | But yeah, you can just pull up ghci (`stack ghci` should work) and `:r` whenever you change code. |
| 2021-07-21 23:35:30 | <dsal> | emacs will often do the right thing. |
| 2021-07-21 23:35:46 | <arkanoid> | dsal, thanks! |
| 2021-07-21 23:35:53 | <dsal> | I've been meaning to try hls again. It's a ridiculously complicated set of things for some reason. |
| 2021-07-21 23:36:12 | × | tremon quits (~tremon@217-63-61-89.cable.dynamic.v4.ziggo.nl) (Quit: getting boxed in) |
| 2021-07-21 23:36:15 | <dsal> | arkanoid: If you bring in quickcheck, you can do quick property tests even. |
| 2021-07-21 23:36:59 | → | dibblego joins (~dibblego@122-199-1-30.ip4.superloop.com) |
| 2021-07-21 23:36:59 | × | dibblego quits (~dibblego@122-199-1-30.ip4.superloop.com) (Changing host) |
| 2021-07-21 23:36:59 | → | dibblego joins (~dibblego@haskell/developer/dibblego) |
| 2021-07-21 23:37:00 | <dsal> | @check \x y -> let s = x + y in s > x && s > y |
| 2021-07-21 23:37:01 | <lambdabot> | *** Failed! Falsifiable (after 1 test): |
| 2021-07-21 23:37:01 | <lambdabot> | 0 0 |
| 2021-07-21 23:37:08 | <dsal> | `0 0` to you, quickcheck |
| 2021-07-21 23:37:48 | <arkanoid> | if I do "stack ghci" I get prelude shell, but my functions seems not imported, even after :r |
| 2021-07-21 23:38:10 | <dsal> | Huh. Oh, are you writing them in the Main module? |
| 2021-07-21 23:38:33 | <dsal> | Does `:l app/Main.hs` work? I think it might not. |
| 2021-07-21 23:39:04 | <dsal> | When I'm being lazy, I'll just paste in stuff with GHCI multiline stuff: `:{\n` [paste] `:}\n` |
| 2021-07-21 23:39:18 | <arkanoid> | wait, I wan not exporting all the function in module declaration |
| 2021-07-21 23:39:26 | <arkanoid> | s/wan/was |
| 2021-07-21 23:40:06 | <dsal> | You can just get rid of the () thing in the declaration. |
| 2021-07-21 23:40:19 | <arkanoid> | now I got there, but literal strings are still converted to [Char], even if I do have {-# LANGUAGE OverloadedStrings #-} on top (and it works with stack test) |
| 2021-07-21 23:40:27 | × | Matthias1 quits (~Matthias1@cpe-76-170-236-166.socal.res.rr.com) (Remote host closed the connection) |
| 2021-07-21 23:40:40 | <dsal> | Literal strings are [Char] |
| 2021-07-21 23:41:02 | <dsal> | Do you expect them to be something else? Or do you mean in your ghci session? |
| 2021-07-21 23:41:08 | <dsal> | `:set -X OverloadedStrings` |
| 2021-07-21 23:41:17 | <dsal> | There's not supposed to be a space there. |
| 2021-07-21 23:41:34 | <dsal> | `:set -XXXStraightEdgeXXX` |
| 2021-07-21 23:41:59 | <arkanoid> | i mean in the ghci session. With the build it works |
| 2021-07-21 23:42:13 | <dsal> | Yeah, so you need to set that for your GHCI session, not just the particular file you loaded. |
| 2021-07-21 23:42:25 | <dsal> | Different files often use different language features. |
| 2021-07-21 23:42:34 | <arkanoid> | yeah! it works |
| 2021-07-21 23:43:02 | × | Gurkenglas quits (~Gurkengla@dslb-002-203-144-156.002.203.pools.vodafone-ip.de) (Ping timeout: 245 seconds) |
| 2021-07-21 23:43:20 | <arkanoid> | you were saying about quickcheck, it that a bot? |
| 2021-07-21 23:43:35 | × | chomwitt quits (~chomwitt@ppp-94-67-220-135.home.otenet.gr) (Remote host closed the connection) |
| 2021-07-21 23:43:48 | <janus> | @package QuickCheck |
| 2021-07-21 23:43:48 | <lambdabot> | https://hackage.haskell.org/package/QuickCheck |
| 2021-07-21 23:44:19 | <jeetelongname> | @help |
| 2021-07-21 23:44:19 | <lambdabot> | help <command>. Ask for help for <command>. Try 'list' for all commands |
| 2021-07-21 23:44:24 | <jeetelongname> | @list |
| 2021-07-21 23:44:24 | <lambdabot> | What module? Try @listmodules for some ideas. |
| 2021-07-21 23:44:24 | × | acidjnk quits (~acidjnk@p200300d0c72b9516f180e3afe24121d7.dip0.t-ipconnect.de) (Ping timeout: 255 seconds) |
| 2021-07-21 23:44:40 | <arkanoid> | oh! Monkey test but monkeys have phds! |
| 2021-07-21 23:44:54 | <dsal> | arkanoid: QuickCheck is ye olde property testing. It's a religion. |
| 2021-07-21 23:45:01 | × | retroid_ quits (~retro@97e2ba5d.skybroadband.com) (Ping timeout: 268 seconds) |
| 2021-07-21 23:45:16 | <janus> | damn straight, and since it involves lawless typeclasses, it is heresy :O |
| 2021-07-21 23:45:49 | <dsal> | Back in the day, people used to write tests by thinking about input and output to their stuff and writing code that would take that input and verify they got the output they expected. Such madness. |
| 2021-07-21 23:46:21 | <janus> | in that what grandpa meant when he said "unit test"? |
| 2021-07-21 23:46:48 | <dsal> | Yeah. They'd test like, one thing and be done. Rarely writing tests like this: |
| 2021-07-21 23:46:49 | <dsal> | @check \x -> abs (x :: Int8) >= 0 |
| 2021-07-21 23:46:51 | <lambdabot> | +++ OK, passed 100 tests. |
| 2021-07-21 23:46:53 | <dsal> | yay! |
| 2021-07-21 23:46:54 | <dsal> | @check \x -> abs (x :: Int8) >= 0 |
| 2021-07-21 23:46:56 | <lambdabot> | *** Failed! Falsifiable (after 74 tests): |
| 2021-07-21 23:46:56 | <lambdabot> | -128 |
| 2021-07-21 23:47:09 | <dsal> | oh no! It turns out the absolute value of a number isn't always >= 0! |
| 2021-07-21 23:47:34 | <janus> | aah, so a unit test is a property test parameterized by unit, aka (). got it |
| 2021-07-21 23:47:51 | <dsal> | @check (== ()) |
| 2021-07-21 23:47:53 | <lambdabot> | +++ OK, passed 100 tests. |
| 2021-07-21 23:47:57 | <dsal> | Yay! My unit tests pass. |
| 2021-07-21 23:47:58 | <arkanoid> | I'm having those kind of insight while reading "category theory for programmers". I feel like I should have read this back when I was an university students. Now it's kinda late and I've too much python in my veins and I need a complete reformat |
| 2021-07-21 23:48:06 | × | aplainzetakind quits (~johndoe@captainludd.powered.by.lunarbnc.net) (Quit: Free ZNC ~ Powered by LunarBNC: https://LunarBNC.net) |
| 2021-07-21 23:48:29 | × | lbseale quits (~lbseale@user/ep1ctetus) (Quit: Client closed) |
| 2021-07-21 23:48:42 | <dsal> | arkanoid: There's a variety of videos like this: https://www.youtube.com/watch?v=hXnS_Xjwk2Y |
| 2021-07-21 23:49:16 | <janus> | arkanoid: i tried reading it when i was a university student doing python and i didn't have the patience for it :P |
| 2021-07-21 23:49:43 | → | aplainzetakind joins (~johndoe@captainludd.powered.by.lunarbnc.net) |
| 2021-07-21 23:49:57 | <dsal> | arkanoid: I did something like this in python in... the past: http://dustin.sallings.org/2010/10/27/breakdancer.html |
| 2021-07-21 23:50:13 | <dsal> | TL;DR: if you only write tests for things you think of, your customers find your bugs. |
| 2021-07-21 23:50:53 | × | aplainzetakind quits (~johndoe@captainludd.powered.by.lunarbnc.net) (Client Quit) |
| 2021-07-21 23:51:03 | → | aplainze1akind joins (~johndoe@captainludd.powered.by.lunarbnc.net) |
| 2021-07-21 23:51:24 | <arkanoid> | I've been a videogame programmer for the majority of my professional life. I kinda know what real users can test that internal testing won't even think possible doing |
| 2021-07-21 23:51:46 | <geekosaur> | human fuzzers unite! |
| 2021-07-21 23:52:01 | <dsal> | I'd *really* like coverage directed fuzzing for my property tests. |
| 2021-07-21 23:52:25 | <dsal> | I think go might get that soon. I've used some of the early versions of it. It's terribly slow and a terrible API, but I think they may have figured it out. |
| 2021-07-21 23:52:45 | <janus> | are you referring to afl? |
| 2021-07-21 23:53:43 | <dsal> | Yeah, it might be related to that. It's abstracted away at work so I don't actually know what the mechanism was. |
| 2021-07-21 23:54:13 | <dsal> | It's incredibly slow and the API was incredibly bad, but you could do things that are super difficult to even think about. |
| 2021-07-21 23:55:23 | × | mrkajetanp_ quits (~mrkajetan@2a01:4b00:ea36:6c00:7994:941c:3f5d:2b88) (Ping timeout: 255 seconds) |
| 2021-07-21 23:55:32 | × | merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 245 seconds) |
| 2021-07-21 23:55:42 | → | mrkajetanp joins (~mrkajetan@2a01:4b00:ea36:6c00:7994:941c:3f5d:2b88) |
| 2021-07-21 23:55:57 | × | zgrep quits (~zgrep@user/zgrep) (Quit: It's a quitter's world.) |
| 2021-07-21 23:56:36 | → | zgrep joins (~zgrep@user/zgrep) |
| 2021-07-22 00:00:29 | <arkanoid> | dsal: thanks for the video! I've been zapping through some different videos about haskell and haskell history, just to get a comfortable context around this new side project of mine. Would you suggest some particular good videos about haskell or functional programming in general, just like the one you just shared |
| 2021-07-22 00:00:48 | <sm> | arkanoid, two other things you might like are doctest and ghcid -T |
| 2021-07-22 00:00:57 | × | berberman quits (~berberman@user/berberman) (Ping timeout: 245 seconds) |
| 2021-07-22 00:01:15 | → | berberman joins (~berberman@user/berberman) |
All times are in UTC.