Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→ 1,804,019 events total
2021-08-07 23:34:20 markpythonicbitc joins (~markpytho@2601:647:5a00:35:147a:d585:e4cc:401c)
2021-08-07 23:54:45 × eggplantade quits (~Eggplanta@108-201-191-115.lightspeed.sntcca.sbcglobal.net) (Remote host closed the connection)
2021-08-07 23:59:42 × jgeerds quits (~jgeerds@55d45555.access.ecotel.net) (Ping timeout: 245 seconds)
2021-08-08 00:03:20 <koz> I have 'newtype Foo (a :: Type) = Foo Bar'. I want to via-derive certain instances based on Bar for some specific Foo Baz. Can I write a non-standalone via derivation for this, or do I need a standalone?
2021-08-08 00:14:33 <euouae> How can I learn how to use Hedgehog to write unit tests?
2021-08-08 00:14:45 × Atum_ quits (~IRC@user/atum/x-2392232) (Quit: Atum_)
2021-08-08 00:14:46 <euouae> I don't know where to find the docs, apart from the haddock stuff on package
2021-08-08 00:14:51 × hubvu quits (sid495858@tinside.irccloud.com) (Ping timeout: 258 seconds)
2021-08-08 00:14:51 <euouae> hackage*
2021-08-08 00:14:54 <koz> euouae: Is there something specific you're not sure about? Or do you just not know where to begin as such?
2021-08-08 00:15:01 <euouae> yeh I don't know where to begin
2021-08-08 00:15:07 × Gurkenglas quits (~Gurkengla@dslb-002-203-144-156.002.203.pools.vodafone-ip.de) (Ping timeout: 245 seconds)
2021-08-08 00:15:32 eggplantade joins (~Eggplanta@108-201-191-115.lightspeed.sntcca.sbcglobal.net)
2021-08-08 00:16:06 × geekosaur quits (~geekosaur@xmonad/geekosaur) (Remote host closed the connection)
2021-08-08 00:16:20 × lavaman quits (~lavaman@98.38.249.169) (Remote host closed the connection)
2021-08-08 00:17:04 <koz> Is there something specific you want to test?
2021-08-08 00:17:11 hubvu joins (sid495858@id-495858.tinside.irccloud.com)
2021-08-08 00:17:13 <koz> It'll help if we have a specific example to start from.
2021-08-08 00:17:47 <euouae> I don't have anything specific I just want to understand how Hedgehog is used
2021-08-08 00:17:57 <euouae> My understanding of it is that it is generating random stuff to test functions with
2021-08-08 00:18:06 <euouae> and that I need to write properties that functions should have
2021-08-08 00:18:06 <koz> euouae: That's a _small_ part of what it does.
2021-08-08 00:18:29 <koz> It does do this, yes, but it also shrinks failing randomly-generated things to try and create a minimal repro case.
2021-08-08 00:18:57 <euouae> That's great, how did you find out? Just reading the haddock docs?
2021-08-08 00:19:06 <euouae> Kind of blows my mind that that's how people learn :P
2021-08-08 00:19:10 geekosaur joins (~geekosaur@xmonad/geekosaur)
2021-08-08 00:19:15 <koz> No - Hedgehog assumes you're at least familiar with QuickCheck and its principles.
2021-08-08 00:19:21 <euouae> Oh I see
2021-08-08 00:19:21 <dsal> euouae: You might find learning about QuickCheck to be a useful start. The concept is that you don't "write tests" as much as define properties that will be true for any given set of input.
2021-08-08 00:19:23 <koz> Hedgehog is QuickCheck + different engineering choices.
2021-08-08 00:19:50 × xff0x quits (~xff0x@2001:1a81:5329:ea00:e083:f7b4:2cd3:667d) (Ping timeout: 258 seconds)
2021-08-08 00:19:51 <euouae> strange though that quick heck is not even mentioned once
2021-08-08 00:20:00 <euouae> quickcheck* in the website or readme or the docs...
2021-08-08 00:20:01 <koz> euouae: I agree.
2021-08-08 00:20:03 <dsal> It's "property testing"
2021-08-08 00:20:12 <monochrom> Me, my POV is it blows my mind that looking for internet hearsay is how millenials learn.
2021-08-08 00:20:29 <euouae> monochrom: Are you talking about me? :P
2021-08-08 00:20:41 lavaman joins (~lavaman@98.38.249.169)
2021-08-08 00:20:46 xff0x joins (~xff0x@2001:1a81:5329:ea00:7c78:a917:7a91:b7c4)
2021-08-08 00:21:29 <dsal> euouae: what kind of thing are you wanting to test?
2021-08-08 00:21:51 <euouae> I haven't yet written anything. I figured that once I start writing stuff, I can use Hedgehog to test it
2021-08-08 00:21:56 <euouae> not because it needs testing. Just to build a habit of it
2021-08-08 00:22:04 <euouae> Just like how I write docs, it's toy projects
2021-08-08 00:23:12 goepsilongo joins (~goepsilon@2603-7000-ab00-62ed-f514-c7d8-9e18-a2d5.res6.spectrum.com)
2021-08-08 00:24:08 <dsal> Well, the idea is that you make a thing and then you have properties that should be true based on your intention. e.g., if I add two numbers together, the result shouldn't be smaller than either of the two numbers:
2021-08-08 00:24:09 <dsal> @check \x y -> (x::Int8) + y > x && x + y > y
2021-08-08 00:24:11 <lambdabot> *** Failed! Falsifiable (after 1 test and 4 shrinks):
2021-08-08 00:24:11 <lambdabot> -1 -1
2021-08-08 00:24:28 <dsal> I didn't think about what the numbers were, but QC shows me a simple scenario.
2021-08-08 00:24:56 <euouae> Just don't add 0
2021-08-08 00:25:47 <euouae> So what are things like Gen.list and Range.linear?
2021-08-08 00:25:59 <dsal> @check \x y -> let s = (x+y) :: Word8 in s >= x && s >= y
2021-08-08 00:26:00 <lambdabot> *** Failed! Falsifiable (after 20 tests and 7 shrinks):
2021-08-08 00:26:00 <lambdabot> 219 248
2021-08-08 00:26:25 <dsal> In QC, there's an Arbitrary class that is used to create values. In hedgehog, you do that more explicitly in your test.
2021-08-08 00:27:00 <euouae> I see, so the engineering choices referred to above are about how you generate the stuff you want to stuff in your testing functions
2021-08-08 00:27:33 <euouae> But why should the generators involve a Monad? Why a MonadGen?
2021-08-08 00:28:08 <dsal> Also a lot about shrinking. Shrinking is essential and kind of hard in QC, but mostly built-in in hedgehog.
2021-08-08 00:28:19 <euouae> Hmmm
2021-08-08 00:28:23 <dsal> Generators are a monad because they generate arbitrary values based on a random seed.
2021-08-08 00:28:39 <euouae> The shrinking is achieved how exactly?
2021-08-08 00:28:44 <euouae> I saw something about trees in the docs
2021-08-08 00:28:53 <dsal> I'm pretty new to hedgehog. I still find QC easier except when I have complicated shrinks to write.
2021-08-08 00:29:03 <dsal> These aren't things you have to think about in the short term. :)
2021-08-08 00:29:18 <Axman6> you might want to watch https://www.youtube.com/watch?v=AIv_9T0xKEo
2021-08-08 00:29:35 <euouae> Nice, thank you
2021-08-08 00:29:56 <Axman6> and IIRC https://www.youtube.com/watch?v=boBD1qhCQ94 is also quite good
2021-08-08 00:31:04 × yaroot quits (~yaroot@6.3.30.125.dy.iij4u.or.jp) (Quit: The Lounge - https://thelounge.chat)
2021-08-08 00:31:56 yaroot joins (~yaroot@6.3.30.125.dy.iij4u.or.jp)
2021-08-08 00:32:13 <euouae> Thank you
2021-08-08 00:32:26 <euouae> I'm going to watch these later today and try to use Hedgehog on my Hangman game lol
2021-08-08 00:32:46 <Axman6> Make sure you've got enough rope!
2021-08-08 00:33:04 <euouae> hehe
2021-08-08 00:35:35 <euouae> koz: I'm sorry, I didn't mean to steal your spotlight of your question
2021-08-08 00:35:43 <koz> euouae: There's nothing to apologize for.
2021-08-08 00:36:00 <koz> > :t showHex
2021-08-08 00:36:01 <lambdabot> <hint>:1:1: error: parse error on input ‘:’
2021-08-08 00:36:08 <koz> > showHex 20 " "
2021-08-08 00:36:10 <lambdabot> "14 "
2021-08-08 00:36:18 <koz> OK, so that _does_ work how I thought it did.
2021-08-08 00:40:36 × cheater quits (~Username@user/cheater) (Ping timeout: 272 seconds)
2021-08-08 00:40:50 dajoer joins (~david@user/gvx)
2021-08-08 00:42:14 <koz> Is there a way to make showHex output capitals, and always print at least 2 symbols, or is this firmly in 'do it your damned self' territory?
2021-08-08 00:42:29 × lavaman quits (~lavaman@98.38.249.169) (Remote host closed the connection)
2021-08-08 00:45:06 <geekosaur> may be in Text.Printf territory
2021-08-08 00:45:44 <geekosaur> > printf "%02X" 13
2021-08-08 00:45:46 <lambdabot> error:
2021-08-08 00:45:46 <lambdabot> • Ambiguous type variable ‘a0’ arising from a use of ‘show_M628767080926...
2021-08-08 00:45:46 <lambdabot> prevents the constraint ‘(Show a0)’ from being solved.
2021-08-08 00:45:55 <geekosaur> > printf "%02X" 13 :: String
2021-08-08 00:45:56 <lambdabot> "0D"
2021-08-08 00:46:29 <koz> > printf "| %02X | %02X |" (12 :: Word8) (57 :: Word8)
2021-08-08 00:46:30 <lambdabot> error:
2021-08-08 00:46:30 <lambdabot> • Ambiguous type variable ‘a0’ arising from a use of ‘show_M110101264447...
2021-08-08 00:46:30 <lambdabot> prevents the constraint ‘(Show a0)’ from being solved.
2021-08-08 00:46:38 <koz> > printf "| %02X | %02X |" (12 :: Word8) (57 :: Word8) :: String
2021-08-08 00:46:40 <lambdabot> "| 0C | 39 |"
2021-08-08 00:46:43 <koz> :D
2021-08-08 00:46:46 <koz> Perfect, thanks!
2021-08-08 00:51:15 × enoq quits (~enoq@194-208-179-35.lampert.tv) (Quit: enoq)

All times are in UTC.