Logs: freenode/#haskell
| 2020-11-02 07:26:13 | <danso> | @type fmap |
| 2020-11-02 07:26:14 | <lambdabot> | Functor f => (a -> b) -> f a -> f b |
| 2020-11-02 07:26:43 | <danso> | is your `Null` defined like `data Null = Null` ? |
| 2020-11-02 07:27:02 | <danso> | i think you most likely mean Maybe instead of Either |
| 2020-11-02 07:27:05 | → | frankie2 joins (~frankie@185.104.184.43) |
| 2020-11-02 07:27:30 | <energizer> | Maybe sounds like like it's in the right direction |
| 2020-11-02 07:27:52 | <danso> | also fmap on Either maps a function over the right side, not the left one |
| 2020-11-02 07:28:15 | <danso> | fmap on maybe is |
| 2020-11-02 07:28:28 | <danso> | fmap f (Just a) = Just (f a) |
| 2020-11-02 07:28:35 | <danso> | fmap f Nothing = Nothing |
| 2020-11-02 07:28:44 | <energizer> | yeah that's what i mean ^ |
| 2020-11-02 07:29:19 | <danso> | if you want to get cute you could use <$> or <&> |
| 2020-11-02 07:29:36 | <dminuoso> | In fact, <$> is very typical |
| 2020-11-02 07:29:44 | <danso> | a <&> f is the same as `fmap f a` |
| 2020-11-02 07:30:10 | <dminuoso> | With a bit of squinting <$> behaves a bit like ($), which is possibly why they both have a dollar in their name. |
| 2020-11-02 07:32:16 | → | sQVe joins (~sQVe@unaffiliated/sqve) |
| 2020-11-02 07:32:44 | <energizer> | how is <$> used here? |
| 2020-11-02 07:33:10 | <danso> | f <$> a |
| 2020-11-02 07:33:30 | <danso> | `<$>` is the same as `flip <&>` |
| 2020-11-02 07:33:34 | <danso> | @type <$> |
| 2020-11-02 07:33:36 | <lambdabot> | error: parse error on input ‘<$>’ |
| 2020-11-02 07:33:38 | → | christo joins (~chris@81.96.113.213) |
| 2020-11-02 07:33:40 | <danso> | @type (<$>) |
| 2020-11-02 07:33:42 | <lambdabot> | Functor f => (a -> b) -> f a -> f b |
| 2020-11-02 07:35:12 | <energizer> | ok i get it |
| 2020-11-02 07:35:45 | <dminuoso> | c.f.: |
| 2020-11-02 07:35:48 | <dminuoso> | :t ($) |
| 2020-11-02 07:35:49 | <lambdabot> | (a -> b) -> a -> b |
| 2020-11-02 07:37:10 | → | dhouthoo joins (~dhouthoo@ptr-eiv6509pb4ifhdr9lsd.18120a2.ip6.access.telenet.be) |
| 2020-11-02 07:37:17 | <energizer> | is <$> or <&> more used? |
| 2020-11-02 07:37:27 | <dminuoso> | <$> by far |
| 2020-11-02 07:37:45 | <dminuoso> | Depending on the project and situation you might either see fmap or <$> being used more |
| 2020-11-02 07:37:51 | <dminuoso> | Sometimes its handy to use both at the same time |
| 2020-11-02 07:37:59 | <dminuoso> | fmap f <$> g |
| 2020-11-02 07:38:00 | × | Tario quits (~Tario@200.119.185.133) (Ping timeout: 256 seconds) |
| 2020-11-02 07:38:42 | → | Tario joins (~Tario@201.191.91.236) |
| 2020-11-02 07:39:03 | <danso> | haskellers are pretty inconsistent on this point, you can see |
| 2020-11-02 07:39:29 | <danso> | <$> is preferred over <&> but >>= is preferred over =<< |
| 2020-11-02 07:39:39 | <dminuoso> | Dunno about that |
| 2020-11-02 07:39:43 | <dminuoso> | I prefer =<< by far :p |
| 2020-11-02 07:40:03 | <danso> | and i prefer <&> ! |
| 2020-11-02 07:40:04 | <dminuoso> | In fact, =<< often arises when I write code with <$> first, just to realize it should have been bind instead. |
| 2020-11-02 07:40:13 | <danso> | i don't think either of us are in the majority though :^) |
| 2020-11-02 07:40:15 | <dminuoso> | I found <&> to be useful in writing decoders :) |
| 2020-11-02 07:40:44 | <dminuoso> | f x 1 = getWord32 <&> Something |
| 2020-11-02 07:40:48 | <dminuoso> | f x 2 = getWord32 <&> AnotherThing |
| 2020-11-02 07:41:00 | <dminuoso> | For a sufficiently large f this aligns much more nicer |
| 2020-11-02 07:41:08 | <danso> | one of the haskell survey questions should have been >>= vs =<< |
| 2020-11-02 07:41:21 | <danso> | pity we just missed it |
| 2020-11-02 07:41:29 | <dminuoso> | Didn't get the memo |
| 2020-11-02 07:42:50 | → | toorevitimirp joins (~tooreviti@117.182.183.132) |
| 2020-11-02 07:45:50 | <energizer> | why is it called <&> ? |
| 2020-11-02 07:46:28 | <dminuoso> | energizer: Presmuably because (&) is a flipped ($) |
| 2020-11-02 07:46:39 | <dminuoso> | % :t ($) |
| 2020-11-02 07:46:40 | <yahb> | dminuoso: (a -> b) -> a -> b |
| 2020-11-02 07:46:43 | <dminuoso> | % :t (<$>) |
| 2020-11-02 07:46:43 | <yahb> | dminuoso: Functor f => (a -> b) -> f a -> f b |
| 2020-11-02 07:46:46 | <dminuoso> | % :t ($) |
| 2020-11-02 07:46:46 | <yahb> | dminuoso: (a -> b) -> a -> b |
| 2020-11-02 07:46:49 | <dminuoso> | % :t (<$>) |
| 2020-11-02 07:46:49 | <yahb> | dminuoso: Functor f => (a -> b) -> f a -> f b |
| 2020-11-02 07:47:08 | <dminuoso> | % :t (<&>) |
| 2020-11-02 07:47:09 | <yahb> | dminuoso: Functor f => f a -> (a -> b) -> f b |
| 2020-11-02 07:47:10 | <dminuoso> | Sorry |
| 2020-11-02 07:47:12 | <dminuoso> | :) |
| 2020-11-02 07:47:17 | <dminuoso> | % :t (&) |
| 2020-11-02 07:47:17 | <yahb> | dminuoso: a -> (a -> b) -> b |
| 2020-11-02 07:47:27 | × | christo quits (~chris@81.96.113.213) (Remote host closed the connection) |
| 2020-11-02 07:48:26 | → | Sanchayan joins (~Sanchayan@106.200.218.30) |
| 2020-11-02 07:48:48 | → | christo joins (~chris@81.96.113.213) |
| 2020-11-02 07:48:51 | <energizer> | alright, so why are they called & and $ ? |
| 2020-11-02 07:49:05 | <danso> | dminuoso, the survey is definitely still open |
| 2020-11-02 07:49:08 | <danso> | i believe it was posted today |
| 2020-11-02 07:49:28 | <danso> | energizer, because they're common things to do, so they should be short |
| 2020-11-02 07:50:27 | <energizer> | $ kinda looks like flipping, yknow |
| 2020-11-02 07:50:57 | → | mimi1vx joins (~mimi@tulipan.habr.nat.praha12.net) |
| 2020-11-02 07:51:11 | <energizer> | & is like 'and' but i'm not sure if fmap is related to 'and' |
| 2020-11-02 07:51:15 | <dminuoso> | Well you have to call them something.. |
| 2020-11-02 07:51:33 | <dminuoso> | There's very limited ASCII characters available |
| 2020-11-02 07:52:34 | <energizer> | yeah sometimes notation is just "gotta pick something" and sometimes there's a hidden connection to some concept |
| 2020-11-02 07:52:38 | <danso> | i think you have misunderstood |
| 2020-11-02 07:52:44 | <danso> | $ is apply |
| 2020-11-02 07:52:48 | <danso> | as in function application |
| 2020-11-02 07:52:53 | <danso> | f(x) is f $ x |
| 2020-11-02 07:52:54 | <dminuoso> | energizer: I dont think there's a particular reason for those choices on function application. |
| 2020-11-02 07:53:14 | <danso> | & is apply with its arguments flipped, so x & f is f(x) |
| 2020-11-02 07:53:36 | <energizer> | mhmm |
| 2020-11-02 07:53:47 | <danso> | the parallel is that <$> is fmap and <&> is fmap with its args flipped |
| 2020-11-02 07:54:00 | <dminuoso> | energizer: You could ask on haskell-cafe though, if you're curious. |
| 2020-11-02 07:54:02 | × | mimi_vx quits (~mimi@2a01:490:16:1026:8cbe:b3f3:f284:209c) (Ping timeout: 264 seconds) |
| 2020-11-02 07:54:10 | <energizer> | ok that does make it clearer. thanks. |
| 2020-11-02 07:54:14 | <dminuoso> | It's possible someone there knows of a connection, perhaps they were burrowed from another language |
| 2020-11-02 07:54:30 | <dminuoso> | Or maybe from some field in mathematics |
| 2020-11-02 07:54:54 | <dminuoso> | Though I think the primary reason would be |
| 2020-11-02 07:55:18 | <dminuoso> | There aren't many other characters ASCII characters left that suggest different things |
| 2020-11-02 07:55:28 | → | cosimone joins (~cosimone@2001:b07:ae5:db26:d849:743b:370b:b3cd) |
| 2020-11-02 07:55:35 | → | gehmehgeh joins (~ircuser1@gateway/tor-sasl/gehmehgeh) |
| 2020-11-02 07:55:44 | <dminuoso> | -+*^ are already used for arithmatic |
| 2020-11-02 07:55:51 | <danso> | i don't know of languages that predate haskell that use an operator for fn application |
| 2020-11-02 07:56:04 | <dminuoso> | @ cant be used as a standalone operator because its used for as-paterns |
All times are in UTC.