Logs: liberachat/#haskell
| 2021-06-04 20:13:01 | <arjun> | then i just tried using it |
| 2021-06-04 20:13:02 | × | GIANTWORLDKEEPER quits (~pjetcetal@2.95.204.25) (Quit: EXIT) |
| 2021-06-04 20:13:21 | <arjun> | in the most rudimentary terms of my understading say |
| 2021-06-04 20:13:21 | <Izem> | that would me me |
| 2021-06-04 20:13:42 | <arjun> | anything that implements the fmap function, is a Functor. |
| 2021-06-04 20:13:48 | → | GIANTWORLDKEEPER joins (~pjetcetal@2.95.204.25) |
| 2021-06-04 20:13:54 | <arjun> | you copy ? |
| 2021-06-04 20:14:33 | × | merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 244 seconds) |
| 2021-06-04 20:15:05 | <arjun> | so, anything that implements the (>>=) function, is a monad |
| 2021-06-04 20:15:27 | <arjun> | there are some laws that need to be satified here but apart from that |
| 2021-06-04 20:15:35 | <arjun> | if it quacks, it s duck. |
| 2021-06-04 20:15:40 | <arjun> | a duckonomy |
| 2021-06-04 20:15:41 | <davean> | uh, the laws are a pretty big deal |
| 2021-06-04 20:15:49 | <arjun> | a duck* |
| 2021-06-04 20:16:01 | <arjun> | davean: so are monads : P |
| 2021-06-04 20:16:06 | × | cjay- quits (cjay@nerdbox.nerd2nerd.org) (Quit: Reconnecting) |
| 2021-06-04 20:16:12 | → | cjay joins (cjay@nerdbox.nerd2nerd.org) |
| 2021-06-04 20:16:14 | <dminuoso> | monochrom: trick question then, if thats pointer tagging, wouldn't +1 mean Nothing (since that's the first constructor) |
| 2021-06-04 20:16:31 | <tput> | I think it's fair to not worry too much about the laws until you're writing your own instances |
| 2021-06-04 20:16:43 | × | cjay quits (cjay@nerdbox.nerd2nerd.org) (Client Quit) |
| 2021-06-04 20:16:56 | → | cjay joins (cjay@nerdbox.nerd2nerd.org) |
| 2021-06-04 20:17:15 | <dminuoso> | Unless of course GHC changed its pointer tagging rules.. |
| 2021-06-04 20:19:57 | × | Guest38 quits (~textual@188-182-241-27-dynamic.dk.customer.tdc.net) (Quit: My MacBook has gone to sleep. ZZZzzz…) |
| 2021-06-04 20:20:24 | → | danidiaz1 joins (~ESDPC@static-172-64-63-95.ipcom.comunitel.net) |
| 2021-06-04 20:20:26 | <dminuoso> | oh wait, im thinking wrong here. |
| 2021-06-04 20:20:42 | <dminuoso> | this is the pointer tag for I# |
| 2021-06-04 20:21:15 | <dminuoso> | Yeah everything is clicking in suddenly :) |
| 2021-06-04 20:21:47 | → | waleee joins (~waleee@2001:9b0:216:8200:d457:9189:7843:1dbd) |
| 2021-06-04 20:22:21 | × | arjun quits (~user@user/arjun) (Ping timeout: 268 seconds) |
| 2021-06-04 20:22:53 | × | danidiaz quits (~ESDPC@static-172-64-63-95.ipcom.comunitel.net) (Ping timeout: 265 seconds) |
| 2021-06-04 20:29:20 | → | prite joins (~pritam@user/pritambaral) |
| 2021-06-04 20:30:08 | → | pavonia joins (~user@user/siracusa) |
| 2021-06-04 20:30:23 | → | ixlun joins (~matthew@109.249.184.235) |
| 2021-06-04 20:31:20 | <ixlun> | Hi all. Could someone explain why this doesn't work? https://termbin.com/t1eo |
| 2021-06-04 20:31:48 | <geekosaur> | return is not a keyword |
| 2021-06-04 20:31:57 | <geekosaur> | return (t + 1) |
| 2021-06-04 20:32:09 | <geekosaur> | :t return |
| 2021-06-04 20:32:10 | <lambdabot> | Monad m => a -> m a |
| 2021-06-04 20:32:50 | <ixlun> | Ah sorry, I missed that one, but I'm still getting the error: Couldn't match type ‘m’ with ‘Either String’ |
| 2021-06-04 20:33:13 | <ixlun> | Which I don't understand since I thought Either was an instance of MonadThrow |
| 2021-06-04 20:33:35 | <dminuoso> | ixlun: Your type signature claims its polymorphically *all* MonadThrow. |
| 2021-06-04 20:33:45 | <geekosaur> | yeh |
| 2021-06-04 20:33:57 | <dminuoso> | but `x` is locked to Either, only one can be true. |
| 2021-06-04 20:34:00 | × | mikoto-chan quits (~mikoto-ch@ip-213-49-189-31.dsl.scarlet.be) (Ping timeout: 265 seconds) |
| 2021-06-04 20:34:04 | <geekosaur> | you claim via your type signature that you can take any MonadThrow, then you specify a particular one |
| 2021-06-04 20:35:31 | <dminuoso> | ixlun: The weight of writing a polymorphic value (one that mentions a type variable in its type signature, roughly) is, that the *caller* decides/chooses a type for the type variable. If you write `foo :: MonadThrow m => m Int` it means the caller could pick `foo :: STM Int` |
| 2021-06-04 20:36:26 | <ixlun> | Right, and that wouldn't then match with the Either |
| 2021-06-04 20:37:52 | <ixlun> | So, why then have an instance of MonadThrow for Either if that can't be translated to the general case? |
| 2021-06-04 20:37:58 | <dminuoso> | ixlun: More importantly, your do-notation induces a use of `(>>=) :: Either String Int -> (Int -> Either String Int) -> Either String Int`, so if you inferred the type of the entire do-expression, it'd be `Either String Int` |
| 2021-06-04 20:38:21 | <dminuoso> | The point is to use it the other way around, instead of using any particular instance, you only use the methods to stay polymorphically over any |
| 2021-06-04 20:38:48 | <dminuoso> | You may only fmap/<*>/pure/=<</throwM |
| 2021-06-04 20:39:12 | <dminuoso> | And then it works in any MonadThrow, giving the caller the freedom to use his monad of choice |
| 2021-06-04 20:39:15 | × | smitop2 quits (uid328768@user/smitop) (Quit: Connection closed for inactivity) |
| 2021-06-04 20:39:19 | <dminuoso> | Rather than locking into a particular monad |
| 2021-06-04 20:40:19 | <ixlun> | Riight, I see. The instances are how the *caller* chooses to 'implement' the error handling |
| 2021-06-04 20:40:29 | <dminuoso> | Correct. |
| 2021-06-04 20:41:34 | <ixlun> | So, in this instance, how would could I 'lift' the Either to `m Int`? |
| 2021-06-04 20:41:42 | <dminuoso> | You cant. |
| 2021-06-04 20:41:59 | <ixlun> | Ah. |
| 2021-06-04 20:42:05 | <dminuoso> | But you can use throwM. |
| 2021-06-04 20:42:22 | <dminuoso> | Note however, that this is for Exceptions. |
| 2021-06-04 20:42:34 | <dminuoso> | instance e ~ SomeException => MonadThrow (Either e) |
| 2021-06-04 20:43:09 | × | amahl quits (~amahl@dxv5skyjn4s74c7h9slvt-3.rev.dnainternet.fi) (Remote host closed the connection) |
| 2021-06-04 20:43:28 | <ixlun> | So you're saying that `x` should use `throwM`? |
| 2021-06-04 20:43:41 | <ixlun> | Rather than `Left` |
| 2021-06-04 20:43:45 | <dminuoso> | MonadThrow really rather generalizes IO exceptions, you probably want to use MonadError rather |
| 2021-06-04 20:49:11 | <ixlun> | Okay, I think I'm getting it after doing a bit more reading. Thanks for the help |
| 2021-06-04 20:52:01 | × | machinedgod quits (~machinedg@135-23-192-217.cpe.pppoe.ca) (Ping timeout: 245 seconds) |
| 2021-06-04 20:57:34 | → | eggplantade joins (~Eggplanta@2600:1700:bef1:5e10:a54f:2e66:1417:26d8) |
| 2021-06-04 20:59:43 | × | eggplantade quits (~Eggplanta@2600:1700:bef1:5e10:a54f:2e66:1417:26d8) (Remote host closed the connection) |
| 2021-06-04 20:59:50 | → | eggplantade joins (~Eggplanta@2600:1700:bef1:5e10:a54f:2e66:1417:26d8) |
| 2021-06-04 21:02:41 | × | Izem quits (~Izem@bras-base-london1483w-grc-38-65-95-41-91.dsl.bell.ca) (Quit: Connection closed) |
| 2021-06-04 21:04:03 | × | Lord_of_Life quits (~Lord@user/lord-of-life/x-2819915) (Quit: Laa shay'a waqi'un moutlaq bale kouloun moumkine) |
| 2021-06-04 21:05:41 | → | ixlun- joins (~matthew@109.249.184.235) |
| 2021-06-04 21:08:14 | → | Lord_of_Life joins (~Lord@user/lord-of-life/x-2819915) |
| 2021-06-04 21:08:17 | × | mpt quits (~tom@p57a566da.dip0.t-ipconnect.de) (Ping timeout: 244 seconds) |
| 2021-06-04 21:11:05 | × | chaosite quits (~chaosite@user/chaosite) (Ping timeout: 252 seconds) |
| 2021-06-04 21:13:57 | → | ddellacosta joins (~ddellacos@86.106.121.75) |
| 2021-06-04 21:14:06 | × | ddellaco_ quits (~ddellacos@89.46.62.83) (Ping timeout: 264 seconds) |
| 2021-06-04 21:17:08 | × | ikex quits (~ash@user/ikex) (Ping timeout: 252 seconds) |
| 2021-06-04 21:19:56 | → | mpt joins (~tom@p57a566da.dip0.t-ipconnect.de) |
| 2021-06-04 21:21:08 | × | ixlun quits (~matthew@109.249.184.235) (Read error: Connection reset by peer) |
| 2021-06-04 21:21:08 | × | ixlun- quits (~matthew@109.249.184.235) (Read error: Connection reset by peer) |
| 2021-06-04 21:21:38 | → | chaosite joins (~chaosite@user/chaosite) |
| 2021-06-04 21:22:33 | × | mastarija quits (~mastarija@46.188.137.31) (Quit: Leaving) |
| 2021-06-04 21:22:34 | → | haltux joins (~haltux@a89-154-181-47.cpe.netcabo.pt) |
| 2021-06-04 21:24:42 | × | haltux quits (~haltux@a89-154-181-47.cpe.netcabo.pt) (Read error: No route to host) |
| 2021-06-04 21:26:10 | × | chaosite quits (~chaosite@user/chaosite) (Ping timeout: 245 seconds) |
| 2021-06-04 21:31:14 | → | ddellaco_ joins (~ddellacos@86.106.143.157) |
| 2021-06-04 21:31:32 | × | Guest9 quits (~Guest9@103.240.170.183) (Quit: Connection closed) |
| 2021-06-04 21:40:14 | × | fizbin quits (~fizbin@c-73-33-197-160.hsd1.nj.comcast.net) (Remote host closed the connection) |
| 2021-06-04 21:43:26 | × | fendor quits (~fendor@178.165.131.187.wireless.dyn.drei.com) (Remote host closed the connection) |
| 2021-06-04 21:45:21 | × | imdoor quits (~imdoor@balticom-142-78-50.balticom.lv) (Quit: imdoor) |
| 2021-06-04 21:47:40 | × | xff0x_ quits (~xff0x@2001:1a81:5380:1300:5902:1ae3:48e2:5ce8) (Ping timeout: 272 seconds) |
| 2021-06-04 21:48:06 | → | xff0x_ joins (~xff0x@2001:1a81:5380:1300:997a:5bba:2f5a:1c40) |
| 2021-06-04 21:48:36 | ← | jakalx parts (~jakalx@base.jakalx.net) () |
| 2021-06-04 21:50:11 | × | lavaman quits (~lavaman@98.38.249.169) (Remote host closed the connection) |
| 2021-06-04 21:50:50 | × | wonko quits (~wjc@62.115.229.50) (Ping timeout: 272 seconds) |
| 2021-06-04 21:52:52 | × | ddellacosta quits (~ddellacos@86.106.121.75) (Remote host closed the connection) |
| 2021-06-04 21:53:05 | → | lavaman joins (~lavaman@98.38.249.169) |
All times are in UTC.