Logs: freenode/#haskell
| 2020-10-06 03:19:39 | <lambdabot> | • Variable not in scope: me |
| 2020-10-06 03:19:39 | <lambdabot> | • Perhaps you meant one of these: |
| 2020-10-06 03:19:41 | <dsal> | There's :browse and :i and :t |
| 2020-10-06 03:19:51 | <dsal> | I'm not quite sure what you mean by bindings. |
| 2020-10-06 03:20:07 | <zoom84> | for example, here are the bindings displayed for a compile error: |
| 2020-10-06 03:20:07 | <dsal> | Local variables inside of functions? That's not normally a thing that you care about from the outside. |
| 2020-10-06 03:20:29 | <zoom84> | • Occurs check: cannot construct the infinite type: a ~ (a, a) |
| 2020-10-06 03:20:31 | <zoom84> | • In the first argument of ‘f’, namely ‘(x, y)’ |
| 2020-10-06 03:20:32 | <solonarv> | you can add a typed hole somewhere in the function; that will produce a compile error telling you: the type of what should fill the hole; bindings in scope; and expressions that might be able to fill the hole |
| 2020-10-06 03:20:33 | <zoom84> | In the expression: f (x, y) |
| 2020-10-06 03:20:35 | <zoom84> | In an equation for ‘fmap’: fmap f (MyT (x, y)) = f (x, y) |
| 2020-10-06 03:20:37 | <zoom84> | • Relevant bindings include |
| 2020-10-06 03:20:39 | <zoom84> | y :: a (bound at learn.hs:806:20) |
| 2020-10-06 03:20:41 | <zoom84> | x :: a (bound at learn.hs:806:18) |
| 2020-10-06 03:20:43 | <zoom84> | f :: a -> b (bound at learn.hs:806:10) |
| 2020-10-06 03:20:45 | <zoom84> | fmap :: (a -> b) -> MyTT a -> MyTT b (bound at learn.hs:806:5) |
| 2020-10-06 03:20:47 | <zoom84> | i'm looking to display the "relevent bindings include" section on command |
| 2020-10-06 03:21:02 | <dsal> | Yeah, typed holes and pastebins |
| 2020-10-06 03:21:02 | <solonarv> | a typed hole looks like this: _ , or _someNameHere (has to start with an underscore) |
| 2020-10-06 03:21:46 | → | toorevitimirp joins (~tooreviti@117.182.180.245) |
| 2020-10-06 03:22:16 | <dsal> | Once you get your function done, it's basically a sealed box. None of the insides matter to you. When you're writing something, typed holes induce that type of thing and help you understand what goes somewhere when you're confused. |
| 2020-10-06 03:22:49 | × | GyroW quits (~GyroW@unaffiliated/gyrow) (Quit: Someone ate my pie) |
| 2020-10-06 03:23:00 | → | GyroW joins (~GyroW@d54C03E98.access.telenet.be) |
| 2020-10-06 03:23:00 | × | GyroW quits (~GyroW@d54C03E98.access.telenet.be) (Changing host) |
| 2020-10-06 03:23:00 | → | GyroW joins (~GyroW@unaffiliated/gyrow) |
| 2020-10-06 03:23:15 | → | conal joins (~conal@64.71.133.70) |
| 2020-10-06 03:23:43 | <zoom84> | not clear where I put the typehole. do I create a new pattern match line and just do a _ on it |
| 2020-10-06 03:24:01 | <dsal> | You put it anywhere you'd put a value, but you don't know what the value is that you need. |
| 2020-10-06 03:24:09 | <dsal> | % 1 + _ |
| 2020-10-06 03:24:14 | <yahb> | dsal: [Timed out] |
| 2020-10-06 03:24:19 | <dsal> | heh. Thanks, yahb |
| 2020-10-06 03:24:50 | <dsal> | % maximum _ |
| 2020-10-06 03:24:56 | <yahb> | dsal: ; <interactive>:1:9: error:; * Found hole: _ :: [a]; Where: `a' is a rigid type variable bound by; the inferred type of it :: Ord a => a; at <interactive>:1:1-9; * In the first argument of `maximum', namely `_'; In the expression: maximum _; In an equation for `it': it = maximum _; * Relevant bindings include it :: a (bound at <interactive>:1:1); |
| 2020-10-06 03:25:18 | × | slack1256 quits (~slack1256@181.203.50.26) (Ping timeout: 272 seconds) |
| 2020-10-06 03:25:23 | <dsal> | So, I need a list of things that have an Ord instance. |
| 2020-10-06 03:26:28 | <zoom84> | i put the type hole on both the left and right site of the pattern, right? |
| 2020-10-06 03:26:48 | <dsal> | % let x = 1 :: Int in 1 + _ |
| 2020-10-06 03:26:52 | <yahb> | dsal: ; <interactive>:2:26: error:; * Found hole: _ :: a; Where: `a' is a rigid type variable bound by; the inferred type of it :: Num a => a; at <interactive>:2:1-26; * In the second argument of `(+)', namely `_'; In the expression: 1 + _; In the expression: let x = 1 :: Int in 1 + _; * Relevant bindings include; x :: Int (bound at <interactive> |
| 2020-10-06 03:27:03 | <dsal> | You can put them where you'd like. It will make suggestions for you. e.g., it suggests x here. |
| 2020-10-06 03:28:17 | <zoom84> | if I put it only on the destructuring side doesn't that just mean I'm not interested in the pattern-matched value and thus it's not an error |
| 2020-10-06 03:28:54 | → | drbean joins (~drbean@TC210-63-209-213.static.apol.com.tw) |
| 2020-10-06 03:29:26 | <dsal> | % let x = 1 :: Int; y = 2 :: Int in _ x y + x -- contriving kind of hard, but run this in your ghci |
| 2020-10-06 03:29:28 | <yahb> | dsal: ; <interactive>:4:38: error:; * Found hole: _ :: Int -> Int -> Int; * In the expression: _; In the first argument of `(+)', namely `_ x y'; In the expression: _ x y + x; * Relevant bindings include; x :: Int (bound at <interactive>:4:7); y :: Int (bound at <interactive>:4:21); it :: Int (bound at <interactive>:4:1); Valid hole fits include; (-) :: |
| 2020-10-06 03:30:05 | <dsal> | Oh, yeah, if it's a parameter binding, it just means "don't care" |
| 2020-10-06 03:30:28 | <zoom84> | ok, it only works if I put it inside the function body |
| 2020-10-06 03:30:41 | <zoom84> | got it, thanks |
| 2020-10-06 03:31:20 | → | slack1256 joins (~slack1256@181.203.50.26) |
| 2020-10-06 03:31:36 | <dsal> | Well, it works if you put it somewhere you want to try to find a possible match. This can't be a parameter, for example, because that's input. If you want to know possible parameter values, you _ the caller |
| 2020-10-06 03:32:57 | <zoom84> | the hole trick works great, thanks |
| 2020-10-06 03:37:05 | × | jedws quits (~jedws@121.209.186.103) (Quit: My MacBook has gone to sleep. ZZZzzz…) |
| 2020-10-06 03:38:36 | × | slack1256 quits (~slack1256@181.203.50.26) (Remote host closed the connection) |
| 2020-10-06 03:38:41 | × | vk3wtf quits (~doc@14-202-30-62.static.tpgi.com.au) (Quit: WeeChat 2.7.1) |
| 2020-10-06 03:39:04 | → | vk3wtf joins (~doc@14-202-30-62.static.tpgi.com.au) |
| 2020-10-06 03:41:25 | → | jwynn6 joins (~jwynn6@050-088-122-078.res.spectrum.com) |
| 2020-10-06 03:43:39 | → | CMCDragonkai1 joins (~Thunderbi@120.17.228.7) |
| 2020-10-06 03:47:33 | × | polyrain quits (~polyrain@2001:8003:e501:6901:a41a:145a:3fce:c107) (Quit: My MacBook has gone to sleep. ZZZzzz…) |
| 2020-10-06 03:50:19 | → | albert_91 joins (~Albert@p200300e5ff0b5b4248a33bded2872db1.dip0.t-ipconnect.de) |
| 2020-10-06 03:51:45 | × | wroathe quits (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) (Ping timeout: 240 seconds) |
| 2020-10-06 03:51:59 | × | Unhammer quits (~Unhammer@gateway/tor-sasl/unhammer) (Remote host closed the connection) |
| 2020-10-06 03:52:09 | × | petersen quits (~petersen@redhat/juhp) (Quit: petersen) |
| 2020-10-06 03:52:25 | × | falafel quits (~falafel@2605:e000:1527:d491:99fe:5613:f0a7:56f0) (Ping timeout: 272 seconds) |
| 2020-10-06 03:52:36 | → | Unhammer joins (~Unhammer@gateway/tor-sasl/unhammer) |
| 2020-10-06 03:54:26 | × | CMCDragonkai1 quits (~Thunderbi@120.17.228.7) (Ping timeout: 272 seconds) |
| 2020-10-06 03:55:35 | × | albert_91 quits (~Albert@p200300e5ff0b5b4248a33bded2872db1.dip0.t-ipconnect.de) (Ping timeout: 272 seconds) |
| 2020-10-06 03:55:52 | → | wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) |
| 2020-10-06 03:59:09 | × | nbloomf quits (~nbloomf@2600:1700:83e0:1f40:71a4:5e3f:3433:7ae1) (Quit: My MacBook has gone to sleep. ZZZzzz…) |
| 2020-10-06 03:59:59 | → | justsomeguy joins (~justsomeg@unaffiliated/--/x-3805311) |
| 2020-10-06 04:01:03 | × | wroathe quits (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) (Ping timeout: 260 seconds) |
| 2020-10-06 04:01:15 | → | falafel joins (~falafel@2605:e000:1527:d491:99fe:5613:f0a7:56f0) |
| 2020-10-06 04:01:59 | × | Saukk quits (~Saukk@2001:998:f1:3963:1c59:9bb5:b94c:2) (Remote host closed the connection) |
| 2020-10-06 04:03:23 | × | elliott_ quits (~elliott@pool-108-51-141-12.washdc.fios.verizon.net) (Ping timeout: 260 seconds) |
| 2020-10-06 04:03:57 | hackage | yesod-filter 0.1.0.0 - Automatic filter generator for Yesod https://hackage.haskell.org/package/yesod-filter-0.1.0.0 (KenzoYotsuya) |
| 2020-10-06 04:04:06 | → | nbloomf joins (~nbloomf@2600:1700:83e0:1f40:71a4:5e3f:3433:7ae1) |
| 2020-10-06 04:07:20 | × | bbear quits (~dkremer@2a01:e34:ec2b:d430:cc93:67b2:c4ea:7463) (Remote host closed the connection) |
| 2020-10-06 04:10:24 | angerman_ | is now known as angerman |
| 2020-10-06 04:13:17 | → | jedws joins (~jedws@121.209.186.103) |
| 2020-10-06 04:13:49 | <gnumonik> | Hello. I'm having some trouble with the lens library. I have a complicated data structure that consists of a product type that contains a record which is a list of a sum type. I would like to use the library to write a function that allows me to set/"over" a specific (indexed) element of the list (if it exists). I can't figure out if I can do that. Everything I try runs into "can't deduce As(sum type) (Product type)" (I'm using |
| 2020-10-06 04:13:49 | <gnumonik> | classy prisms). AFAIK I can't write a prism for a product type so I can't actually declare the instance and I'm wondering if there's another way to do this. Could someone point me in the right direction? |
| 2020-10-06 04:16:29 | → | shafox joins (~shafox@106.51.234.111) |
| 2020-10-06 04:16:40 | <c_wraith> | You can certainly do it. You just need to ensure you actually have the necessary lenses available. |
| 2020-10-06 04:16:43 | <hololeap> | zoom84, _ has type `a` (e.g. anything, similar to `undefined`) and you can use it multiple times and get multiple error messages |
| 2020-10-06 04:17:31 | <c_wraith> | if you don't have a sum type, don't try to create a prism for it? |
| 2020-10-06 04:18:17 | × | Sheilong quits (uid293653@gateway/web/irccloud.com/x-wunoznsilndrshkm) () |
| 2020-10-06 04:18:37 | <hololeap> | gnumonik: you might want to look at a data structure instead of lists, which supports something better than O(n) lookups with an index |
| 2020-10-06 04:19:23 | <hololeap> | like Seq (O(log(n))) or Vector (O(n)) |
| 2020-10-06 04:19:34 | <hololeap> | oops... Vector (O(1)) |
| 2020-10-06 04:19:37 | <c_wraith> | that seems like an entirely useless criticism |
| 2020-10-06 04:19:49 | <c_wraith> | also, if you're using over, Vector is also O(n) |
| 2020-10-06 04:19:57 | <c_wraith> | because it has to allocate an entire new one |
| 2020-10-06 04:21:01 | <dsal> | A nice thing about using lens is you can replace a list with a vector without changing code. |
| 2020-10-06 04:21:05 | <hololeap> | well, it would be more efficient when getter |
| 2020-10-06 04:21:18 | <hololeap> | *using a getter |
| 2020-10-06 04:22:13 | <gnumonik> | The lists are so short I doubt that'll make much of a difference. So actually I'm writing template haskell to generate setting/over functions, and the only case in which it doesn't work is where I have a product with one component that's a list of a sum type. And the only clue I have as to why it's not working is that can't deduce error :-( |
| 2020-10-06 04:23:35 | <c_wraith> | well, the nice thing about lens is composability. Break things down and figure out exactly which part is sketchy. |
| 2020-10-06 04:25:57 | × | massma quits (~user@dyn-160-39-62-152.dyn.columbia.edu) (Quit: rcirc on GNU Emacs 26.1) |
| 2020-10-06 04:29:12 | → | MasterGruntR75 joins (~MasterGru@185.244.214.216) |
| 2020-10-06 04:35:00 | → | kori joins (~kori@2804:14c:85a3:9105::1000) |
| 2020-10-06 04:35:00 | × | kori quits (~kori@2804:14c:85a3:9105::1000) (Changing host) |
| 2020-10-06 04:35:00 | → | kori joins (~kori@arrowheads/kori) |
| 2020-10-06 04:35:36 | × | haritz quits (~hrtz@unaffiliated/haritz) (Ping timeout: 272 seconds) |
All times are in UTC.