Logs: freenode/#haskell
| 2020-09-27 14:28:22 | → | josh_ joins (~josh@c-67-164-104-206.hsd1.ca.comcast.net) |
| 2020-09-27 14:31:49 | → | Chefe joins (~Chefe@84.39.117.57) |
| 2020-09-27 14:34:07 | → | Guest_67 joins (5284e9b3@82-132-233-179.dab.02.net) |
| 2020-09-27 14:34:44 | <Guest_67> | . |
| 2020-09-27 14:35:51 | <Guest_67> | Permission was denied when I wanted to add the required PATH variable to /Users/b/.bashrc |
| 2020-09-27 14:36:59 | ← | Guest_67 parts (5284e9b3@82-132-233-179.dab.02.net) () |
| 2020-09-27 14:37:32 | <[exa]> | p0a: I didn't try to compile this but it might show how to really exploit the list machinery https://paste.tomsmeding.com/crh9oaVX |
| 2020-09-27 14:37:42 | → | coot joins (~coot@37.30.52.6.nat.umts.dynamic.t-mobile.pl) |
| 2020-09-27 14:38:28 | <[exa]> | (oh and you might need to place `head $` before `do` to get a single possibility there) |
| 2020-09-27 14:38:41 | <p0a> | [exa]: that' svery nice |
| 2020-09-27 14:38:50 | <p0a> | I see you're using guard and also some tricks with *> |
| 2020-09-27 14:38:54 | <p0a> | I'll have to think about it |
| 2020-09-27 14:39:39 | <[exa]> | p0a: the monad binding (<-) for lists works like list comprehension, it tries the rest of the code for all values in the list you bound |
| 2020-09-27 14:39:51 | → | thir joins (~thir@p200300f27f0fc60094e773283d7bf825.dip0.t-ipconnect.de) |
| 2020-09-27 14:40:15 | <[exa]> | and `guard` kindof terminates the attempt to reach a result if the condition is false |
| 2020-09-27 14:41:24 | <[exa]> | intuition for the rest: <|> is an "or" for this kind of wrapped computations (if the first branch fails, you still get some results for the second) |
| 2020-09-27 14:41:38 | <p0a> | right |
| 2020-09-27 14:41:48 | <p0a> | I'm going to learn from that example |
| 2020-09-27 14:41:55 | <[exa]> | and *> is a fancy version of "if nothing broke yet, return the thing on the right" |
| 2020-09-27 14:42:03 | <p0a> | guard seems handy, it's just foreign to me |
| 2020-09-27 14:42:07 | → | heatsink joins (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) |
| 2020-09-27 14:42:17 | <p0a> | I don't use it because I think I've never seen it before |
| 2020-09-27 14:42:32 | <[exa]> | I might have simplified that with $> 1 and $> -1 from Data.Functor |
| 2020-09-27 14:42:34 | <p0a> | (Except for the tutorials/books on haskell that I've read) |
| 2020-09-27 14:42:49 | → | elliott__ joins (~elliott@pool-100-36-54-163.washdc.fios.verizon.net) |
| 2020-09-27 14:42:54 | <[exa]> | uh, and list functor/applicative primer: |
| 2020-09-27 14:43:09 | <[exa]> | > [(+1),(*10)] <*> [1,2,3] |
| 2020-09-27 14:43:11 | <lambdabot> | [2,3,4,10,20,30] |
| 2020-09-27 14:43:25 | <p0a> | that reminds me |
| 2020-09-27 14:43:31 | <p0a> | Why does it work in that fashion? |
| 2020-09-27 14:43:45 | <p0a> | I saw an example `liftA2 (,) list1 list2' for cartesian product |
| 2020-09-27 14:43:54 | <[exa]> | > [1,2] $> 10 |
| 2020-09-27 14:43:56 | <lambdabot> | error: |
| 2020-09-27 14:43:56 | <lambdabot> | • Variable not in scope: ($>) :: [a0] -> t0 -> t |
| 2020-09-27 14:43:56 | <lambdabot> | • Perhaps you meant one of these: |
| 2020-09-27 14:44:04 | <[exa]> | oh noes, $> is from Data.Functor |
| 2020-09-27 14:44:07 | × | thir quits (~thir@p200300f27f0fc60094e773283d7bf825.dip0.t-ipconnect.de) (Ping timeout: 240 seconds) |
| 2020-09-27 14:44:37 | <[exa]> | p0a: list Applicative instance is derived exactly like that. The semantics is something like "Listing of all possibilities" (with some rough corners about infinities) |
| 2020-09-27 14:45:39 | <p0a> | why couldn't it be zip-like instead? |
| 2020-09-27 14:45:59 | <[exa]> | p0a: btw the liftA2 rewrites to the "operator" form like this, I find it kindof more illustrative: |
| 2020-09-27 14:46:00 | <p0a> | i.e. [(+1),(*10)] <*> [1,2,3] would give [2, 20] |
| 2020-09-27 14:46:16 | <[exa]> | > (,) <$> [1,2,3] <*> [1,2,3] |
| 2020-09-27 14:46:19 | <lambdabot> | [(1,1),(1,2),(1,3),(2,1),(2,2),(2,3),(3,1),(3,2),(3,3)] |
| 2020-09-27 14:46:36 | <p0a> | yeah I see what that means |
| 2020-09-27 14:46:51 | × | heatsink quits (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 258 seconds) |
| 2020-09-27 14:47:11 | <p0a> | the magic is in <*> then; that's why I'm asking my question above about an alternative definition |
| 2020-09-27 14:47:14 | <p0a> | would it violate some 'axiom' ? |
| 2020-09-27 14:47:21 | <[exa]> | p0a: good question; the simple answer is that list comprehension wouldn't work, but I believe there's some slightly more rigorous reason |
| 2020-09-27 14:47:23 | <kosmikus> | it could be zip-like. in fact, there's a newtype called ZipList that implements exactly that applicative instance. the "default" instance is chosen to be compatible with the monad instance for lists. |
| 2020-09-27 14:48:06 | <p0a> | oh nice. I see, thank you |
| 2020-09-27 14:49:12 | × | ericsagnes quits (~ericsagne@2405:6580:0:5100:74e9:5ac6:5b4b:6ddf) (Ping timeout: 260 seconds) |
| 2020-09-27 14:49:57 | <[exa]> | oh yes there's no (reasonable) way to "flatten" lists by zipping, so their monad instance would have to be kinda fishy (thanks kosmikus!) |
| 2020-09-27 14:50:06 | → | mirrorbird joins (~psutcliff@h85-8-41-6.cust.a3fiber.se) |
| 2020-09-27 14:51:49 | × | merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 264 seconds) |
| 2020-09-27 14:52:16 | → | heatsink joins (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) |
| 2020-09-27 14:53:11 | → | antaoiseach joins (~z0ltan@103.5.134.18) |
| 2020-09-27 14:53:40 | → | cosimone joins (~cosimone@2001:b07:ae5:db26:b248:7aff:feea:34b6) |
| 2020-09-27 14:54:19 | <antaoiseach> | Hello folks, I'm just learning about the various GHC extensions, and I was trying this example - https://limperg.de/ghc-extensions/#bangpatterns, but the code does not seem to be working as expected for me. |
| 2020-09-27 14:54:29 | <antaoiseach> | The code snippet is here https://paste.ofcode.org/AFpzbG8CCY3fftWuYKHuWs |
| 2020-09-27 14:54:48 | <[exa]> | p0a: btw in case of lists, the `a <- b ; c ....` is basically a fun syntax for `concatMap (\a -> c ...) b` |
| 2020-09-27 14:55:21 | <antaoiseach> | The linked guide says that with the bang pattern, `main` should execute almost instantly, but that does not seem to be the case when I try it (both in GHCi and GHC).. can anyone help me understand this? |
| 2020-09-27 14:56:20 | <[exa]> | antaoiseach: are you sure that this amount of recursion should finish almost instantly? |
| 2020-09-27 14:56:49 | × | heatsink quits (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 258 seconds) |
| 2020-09-27 14:56:54 | <antaoiseach> | exarkun: No, I'm not sure... the guide says that it should - hence my confusion! |
| 2020-09-27 14:57:07 | <[exa]> | uh, if you _remove_ the ! it can finish instantly because it doesn't have to compute the fibs |
| 2020-09-27 14:57:28 | <yushyin> | 'Without the bang pattern, the programme terminates almost instantly ...' -- from your source |
| 2020-09-27 14:57:36 | <antaoiseach> | Oh |
| 2020-09-27 14:57:39 | → | alx741_ joins (~alx741@186.178.110.72) |
| 2020-09-27 14:57:44 | <antaoiseach> | Okay ... sorry ... my mistake then! :( |
| 2020-09-27 14:57:52 | <[exa]> | no problem :] |
| 2020-09-27 14:57:59 | <antaoiseach> | Hahaha ... sorry guys! :D |
| 2020-09-27 14:58:17 | <[exa]> | I was myself expecting a completely different kind of twist :D |
| 2020-09-27 14:58:23 | <antaoiseach> | hahaha! :D |
| 2020-09-27 14:58:58 | hackage | vulkan 3.6.7 - Bindings to the Vulkan graphics API. https://hackage.haskell.org/package/vulkan-3.6.7 (jophish) |
| 2020-09-27 14:59:08 | → | kelsey joins (~keteskyl@2600:6c64:7b7f:fa42:2cda:1ff8:55be:a617) |
| 2020-09-27 14:59:23 | <antaoiseach> | Okay, so maybe I could make better use of this chance and ask a better question then! So I'm done with "Programming in Haskell" (2nd Edition), and loved the book. Now I'm trying to get more into the practical side of things - monad transformers, stack, various extensions etc. |
| 2020-09-27 14:59:31 | kelsey | is now known as Guest18832 |
| 2020-09-27 14:59:33 | <antaoiseach> | What would you recommend in addition/instead of this path? |
| 2020-09-27 14:59:48 | Guest18832 | is now known as keteskyl |
| 2020-09-27 14:59:55 | <antaoiseach> | To move from a basic but relatively strong theoretical foundation onto more advanced and practical stuff? |
| 2020-09-27 15:00:02 | × | Chefe quits (~Chefe@84.39.117.57) () |
| 2020-09-27 15:00:39 | → | Lord_of_Life_ joins (~Lord@unaffiliated/lord-of-life/x-0885362) |
| 2020-09-27 15:01:39 | → | ericsagnes joins (~ericsagne@2405:6580:0:5100:652c:34a0:8a11:d7f2) |
| 2020-09-27 15:01:58 | <maralorn> | Can I newtype derive an instance for "MyClass MyType B" when there is an instance "MyClass A B" and a "newtype MyType = MyType A"? |
| 2020-09-27 15:02:11 | × | Lord_of_Life quits (~Lord@unaffiliated/lord-of-life/x-0885362) (Ping timeout: 258 seconds) |
| 2020-09-27 15:02:26 | → | heatsink joins (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) |
| 2020-09-27 15:02:31 | <maralorn> | antaoiseach: I like http://dev.stephendiehl.com/hask/ |
| 2020-09-27 15:02:37 | × | machinedgod quits (~machinedg@24.105.81.50) (Ping timeout: 264 seconds) |
| 2020-09-27 15:03:16 | Lord_of_Life_ | is now known as Lord_of_Life |
| 2020-09-27 15:03:37 | <antaoiseach> | maralorn: Thank you.. that looks very nicely organised indeed! |
| 2020-09-27 15:04:38 | <antaoiseach> | maralorn: yes, that looks almost exactly like what I am looking for right now. Thanks again! :-) |
| 2020-09-27 15:04:40 | → | asavan joins (585a3df0@ti0059a400-5844.bb.online.no) |
| 2020-09-27 15:05:40 | × | antaoiseach quits (~z0ltan@103.5.134.18) (Quit: leaving) |
| 2020-09-27 15:05:51 | × | coot quits (~coot@37.30.52.6.nat.umts.dynamic.t-mobile.pl) (Quit: coot) |
| 2020-09-27 15:07:18 | × | heatsink quits (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 260 seconds) |
| 2020-09-27 15:09:01 | → | jneira[m] joins (~jneira@125.red-193-152-119.dynamicip.rima-tde.net) |
| 2020-09-27 15:10:08 | × | keteskyl quits (~keteskyl@2600:6c64:7b7f:fa42:2cda:1ff8:55be:a617) (Quit: WeeChat 2.8) |
| 2020-09-27 15:12:40 | → | heatsink joins (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) |
| 2020-09-27 15:14:40 | → | oisdk joins (~oisdk@2001:bb6:3329:d100:b45e:e1cb:af9:6e8) |
| 2020-09-27 15:15:32 | × | zaquest quits (~notzaques@5.128.210.178) (Quit: Leaving) |
All times are in UTC.