Logs: liberachat/#haskell
| 2021-06-14 10:55:04 | → | juhp joins (~juhp@128.106.188.66) |
| 2021-06-14 10:55:04 | <tomsmeding> | (and even (&) is reasonably uncommon) |
| 2021-06-14 10:55:04 | <merijn> | Schrostfutz_: i.e. "f . g . h" can be refactored into "let x = f . g in x . h" always typechecks for any f/g/h |
| 2021-06-14 10:55:08 | <dminuoso> | This is a (generalized) version of flip (.) |
| 2021-06-14 10:55:17 | tomsmeding | always forgets the arrow stuff |
| 2021-06-14 10:55:19 | <merijn> | Schrostfutz_: That does not hold for $ and &, making them more difficult to refactor |
| 2021-06-14 10:55:27 | <merijn> | tomsmeding: That's Category :p |
| 2021-06-14 10:55:33 | <dminuoso> | (>>>) is rather oncommon though |
| 2021-06-14 10:55:41 | <cstml> | aren't Arrows (>>>) basically flipped (.) |
| 2021-06-14 10:55:45 | <merijn> | tomsmeding: There's also a >>> from Arrow, but at this point best just forget Arrow exists |
| 2021-06-14 10:55:50 | <merijn> | cstml: Yes |
| 2021-06-14 10:55:51 | <dminuoso> | cstml: They are more general than flipped (.) |
| 2021-06-14 10:56:25 | <tomsmeding> | merijn: it took a while before I realised that Data.Bifunctor also exports first and second |
| 2021-06-14 10:56:30 | <dminuoso> | For `instance Category (->)` you have `(>>>) = flip (.)` |
| 2021-06-14 10:56:33 | → | dunkeln joins (~dunkeln@94.129.65.28) |
| 2021-06-14 10:56:38 | <dminuoso> | But Category has other instances too, so.. |
| 2021-06-14 10:56:58 | <Schrostfutz_> | dminuoso: That one also looks convenient |
| 2021-06-14 10:57:54 | <merijn> | tomsmeding: The combination of Profunctor, Applicative, and Category pretty much completely obsolete Arrow and Bifunctor obsoletes the few combinators from Arrow that people use for non-arrowy things :p |
| 2021-06-14 10:58:25 | <dminuoso> | Schrostfutz_: Id pick (.) for no reason other than visual symmetrich with function application. i.e. `(f . g) x = f (g x)` -- the relative order of variables dot not change. |
| 2021-06-14 10:58:44 | <dminuoso> | Once you stick to a consistent style, it becomes easier for your brain to read intuitively too |
| 2021-06-14 10:58:47 | <tomsmeding> | "dot not change" indeed |
| 2021-06-14 10:59:02 | <dminuoso> | So many typos there. :( |
| 2021-06-14 10:59:19 | <cstml> | reading the . dot as "after" really helps as well. So you read f . g as f "after" g |
| 2021-06-14 10:59:34 | <merijn> | I use dminuoso's reading/parsing style, yeah |
| 2021-06-14 10:59:38 | <cstml> | then it's easy to internalise |
| 2021-06-14 10:59:48 | <Schrostfutz_> | I get that, but often times I find myself writing what would be pipelinens on the shell, so find ... | grep ... | sort ... | head, so I'm looking for something similar |
| 2021-06-14 10:59:53 | × | azeem quits (~azeem@176.201.21.98) (Read error: Connection reset by peer) |
| 2021-06-14 11:00:13 | <merijn> | mconcat + endo ;) |
| 2021-06-14 11:00:28 | <merijn> | Although that only works for functions that all have the same type, I suppose |
| 2021-06-14 11:00:31 | <cstml> | you can define your own `flip (.)` and then just use it |
| 2021-06-14 11:00:32 | <merijn> | Sadly |
| 2021-06-14 11:00:38 | → | azeem joins (~azeem@dynamic-adsl-78-13-238-239.clienti.tiscali.it) |
| 2021-06-14 11:01:56 | × | cfricke quits (~cfricke@user/cfricke) (Ping timeout: 244 seconds) |
| 2021-06-14 11:01:57 | <dminuoso> | Schrostfutz_: As it happens, for shell-type you have streaming. So with conduit you'd write .| just like that: |
| 2021-06-14 11:02:11 | <merijn> | That depends on the kinda pipeline, though |
| 2021-06-14 11:02:17 | <merijn> | That's mostly for more IO-y things |
| 2021-06-14 11:02:23 | <merijn> | or monad-y things |
| 2021-06-14 11:02:48 | <dminuoso> | And you also have (>=>) for a monadic version of (>>>) (and (<=<) for a monadic version of (.)/(<<<) |
| 2021-06-14 11:03:18 | <cstml> | dminuoso: spot on. Exactly what I was going to write |
| 2021-06-14 11:03:29 | <dminuoso> | Personally I'd just get used to this reverse style of (.) because it's so ubiquitous in Haskell.. |
| 2021-06-14 11:03:45 | <dminuoso> | And because of visual symmetry with application |
| 2021-06-14 11:03:50 | <dminuoso> | Simplified refactoring |
| 2021-06-14 11:04:02 | <dminuoso> | So many reasons to use (.), so little reasons to use (>>>) :) |
| 2021-06-14 11:04:04 | <cstml> | It's also mathematical notation |
| 2021-06-14 11:04:21 | × | dunkeln quits (~dunkeln@94.129.65.28) (Ping timeout: 272 seconds) |
| 2021-06-14 11:04:24 | <Schrostfutz_> | Maybe that's also part of the reason why it annoys me: with monads I write code in the reverse order as I do regular functions so I'd want to have a consistent way |
| 2021-06-14 11:04:40 | <dminuoso> | Reverse order? |
| 2021-06-14 11:04:47 | <dminuoso> | Oh you mean with >>=? |
| 2021-06-14 11:04:51 | <dminuoso> | You can use =<< too if you prefer. |
| 2021-06-14 11:05:00 | <tomsmeding> | always an answer :p |
| 2021-06-14 11:05:30 | <dminuoso> | gnidemsmot, doing things the wrong way around is not an option! |
| 2021-06-14 11:06:13 | → | swistak joins (~swistak@185.21.216.141) |
| 2021-06-14 11:06:14 | tomsmeding | was confused for too long by that |
| 2021-06-14 11:06:25 | tomsmeding | adds that to my highlight list |
| 2021-06-14 11:07:26 | <Schrostfutz_> | dminuoso: but code commonly is written using >>=, so then I'd find myself again using a style different from anyone else\ |
| 2021-06-14 11:08:01 | <tomsmeding> | Schrostfutz_: code with more than one >>= is commonly written in do-notation, which is similar to let-bindings |
| 2021-06-14 11:08:06 | <tomsmeding> | (in structure) |
| 2021-06-14 11:08:49 | <tomsmeding> | hm I guess unless it's really a pipeline |
| 2021-06-14 11:08:55 | <dminuoso> | And then, visually, data flows from right to left. |
| 2021-06-14 11:09:13 | <dminuoso> | Though mmm. With applicative style its different |
| 2021-06-14 11:09:18 | <dminuoso> | Or is it? |
| 2021-06-14 11:09:24 | <dminuoso> | (,) <$> foo <*> bar |
| 2021-06-14 11:09:29 | <tomsmeding> | applicative is directionless |
| 2021-06-14 11:09:38 | <dminuoso> | is it really? |
| 2021-06-14 11:09:41 | <tomsmeding> | which is the entire point, right? |
| 2021-06-14 11:09:45 | × | rusua quits (uid124537@id-124537.highgate.irccloud.com) (Quit: Connection closed for inactivity) |
| 2021-06-14 11:09:58 | <dminuoso> | for all instances which also have monad, there's an inherent direction |
| 2021-06-14 11:09:58 | <Schrostfutz_> | It |
| 2021-06-14 11:10:08 | <dminuoso> | tomsmeding: consider attoparsec/megaparsec parsers. |
| 2021-06-14 11:10:12 | <tomsmeding> | hm true |
| 2021-06-14 11:10:17 | <Schrostfutz_> | It's bidirectional and matches the visual direction |
| 2021-06-14 11:10:23 | → | lavaman joins (~lavaman@98.38.249.169) |
| 2021-06-14 11:10:28 | <jophish> | https://hackage.haskell.org/package/transformers-0.5.6.2/docs/Control-Applicative-Backwards.html |
| 2021-06-14 11:10:41 | <dminuoso> | jophish: that's a cute one :) |
| 2021-06-14 11:10:55 | <dminuoso> | % getConst . forwards . traverse (Backwards . Const) $ ["foo", "bar", "quux"] |
| 2021-06-14 11:10:56 | <yahb> | dminuoso: ; <interactive>:29:12: error: Variable not in scope: forwards :: f0 [b1] -> Const c b2; <interactive>:29:33: error:; * Data constructor not in scope: Backwards :: Const String b0 -> f0 b1; * Perhaps you meant variable `backwards' (imported from Control.Lens) |
| 2021-06-14 11:10:56 | <merijn> | tomsmeding: It's not, though |
| 2021-06-14 11:11:08 | tomsmeding | wants Backwards to also be a monad |
| 2021-06-14 11:11:13 | <dminuoso> | % getConst . forwards . traverse (Backwards . Const) $ ["foo", "bar", "quux"] |
| 2021-06-14 11:11:14 | <yahb> | dminuoso: "quuxbarfoo" |
| 2021-06-14 11:11:26 | <merijn> | tomsmeding: The true difference is "effects can't depend on results of previous actions/effects) |
| 2021-06-14 11:11:41 | <merijn> | And of course, then there's Selective as funky hybrid |
| 2021-06-14 11:12:01 | <dminuoso> | There are combinators that get rid of direction, like permutation parsers. |
| 2021-06-14 11:12:16 | <dminuoso> | Those dont have an obvious effect order anymore |
| 2021-06-14 11:13:11 | <dminuoso> | In applicative style I rarely find myself using (<<), but that's probably because of things like (<*) and (*>) |
| 2021-06-14 11:13:22 | × | teaSlurper quits (~chris@81.96.113.213) (Remote host closed the connection) |
| 2021-06-14 11:13:23 | <dminuoso> | So the applicative interface nudges you towards left-to-right style |
| 2021-06-14 11:13:49 | <dminuoso> | Wait. (<<) is not even a thing haha |
| 2021-06-14 11:14:03 | → | spirgel joins (spirgel@gateway/vpn/protonvpn/spirgel) |
| 2021-06-14 11:14:43 | <tomsmeding> | would (<<) sequence the left effect first or the right effect first? |
| 2021-06-14 11:14:58 | <tomsmeding> | the former is consistent with (<*), the latter is consistent with (=<<) |
| 2021-06-14 11:14:58 | <dminuoso> | The latter |
| 2021-06-14 11:15:16 | <tomsmeding> | maybe it doesn't exist because it would cause confusion |
| 2021-06-14 11:15:45 | → | cfricke joins (~cfricke@user/cfricke) |
| 2021-06-14 11:15:46 | <DigitalKiwi> | https://twitter.com/ArchKiwi/status/1247639264172670982?s=20 |
| 2021-06-14 11:15:59 | → | Morrow joins (~Morrow@31.154.96.164) |
| 2021-06-14 11:17:06 | <tomsmeding> | put that on a cake and give it to a haskeller on their birthday, and watch the flurry of emotions on their face |
| 2021-06-14 11:17:50 | <DigitalKiwi> | throw back to that time i made stickers for everyone at zurihac |
| 2021-06-14 11:18:51 | × | unyu quits (~pyon@user/pyon) (Ping timeout: 268 seconds) |
| 2021-06-14 11:19:45 | → | bpalmer` joins (~user@user/bpalmer) |
All times are in UTC.