Logs: freenode/#haskell
| 2021-02-27 16:26:42 | <monochrom> | You can insert one more fmap there. |
| 2021-02-27 16:27:22 | <jacks2> | > (fmap fmap fmap) (+1) [("a",1),("b",2),("c",3)] |
| 2021-02-27 16:27:23 | × | bitmagie quits (~Thunderbi@200116b8069d920024758e6b0c3524c9.dip.versatel-1u1.de) (Quit: bitmagie) |
| 2021-02-27 16:27:23 | <lambdabot> | [("a",2),("b",3),("c",4)] |
| 2021-02-27 16:27:27 | <monochrom> | Since (.) is "instance Functor ((->) e) where fmap = (.)", fmap . fmap = fmap `fmap` fmap = fmap fmap fmap |
| 2021-02-27 16:28:32 | <monochrom> | https://en.wikipedia.org/wiki/Buffalo_buffalo_Buffalo_buffalo_buffalo_buffalo_Buffalo_buffalo |
| 2021-02-27 16:29:04 | <tomsmeding> | > map (fmap (+1)) [("a",1), ("b",2), ("c",3)] -- ixlun |
| 2021-02-27 16:29:06 | <lambdabot> | [("a",2),("b",3),("c",4)] |
| 2021-02-27 16:29:17 | <ixlun> | Hm, interesting, what is the rationale behind instance Functor (,) applying f to the second element of the tuple? |
| 2021-02-27 16:29:53 | <tomsmeding> | > :t fmap :: (a -> b) -> (z,a) -> (z,b) |
| 2021-02-27 16:29:55 | <lambdabot> | <hint>:1:1: error: <hint>:1:1: error: parse error on input ‘:’ |
| 2021-02-27 16:29:57 | × | raehik quits (~raehik@cpc95906-rdng25-2-0-cust156.15-3.cable.virginm.net) (Ping timeout: 264 seconds) |
| 2021-02-27 16:29:59 | <tomsmeding> | % :t fmap :: (a -> b) -> (z,a) -> (z,b) |
| 2021-02-27 16:29:59 | <yahb> | tomsmeding: (a -> b) -> (z, a) -> (z, b) |
| 2021-02-27 16:30:14 | <tomsmeding> | % :i Functor |
| 2021-02-27 16:30:15 | <yahb> | tomsmeding: type Functor :: (* -> *) -> Constraint; class Functor f where; fmap :: (a -> b) -> f a -> f b; (<$) :: a -> f b -> f a; {-# MINIMAL fmap #-}; -- Defined in `GHC.Base'; instance [safe] Functor m => Functor (WriterT w m) -- Defined in `Control.Monad.Trans.Writer.Lazy'; instance [safe] Functor m => Functor (StateT s m) -- Defined in `Control.Monad.Trans.State.Lazy'; instance [safe] Functor m => Func |
| 2021-02-27 16:30:15 | <monochrom> | The type leaves you no choice, as shown. |
| 2021-02-27 16:30:27 | → | heatsink joins (~heatsink@2600:1700:bef1:5e10:44cd:7ec7:332d:f0ab) |
| 2021-02-27 16:30:33 | <tomsmeding> | f a -> f b, where f a should be (x,y) |
| 2021-02-27 16:31:01 | <tomsmeding> | the thing you're mapping over is necessarily the last type parameter of the data type, which in the case of (,) is the second argument |
| 2021-02-27 16:31:38 | <tomsmeding> | (note that (x,y) is the same as (,) x y) |
| 2021-02-27 16:31:48 | → | kam1 joins (~kam1@5.125.126.175) |
| 2021-02-27 16:32:10 | → | raehik joins (~raehik@cpc95906-rdng25-2-0-cust156.15-3.cable.virginm.net) |
| 2021-02-27 16:32:13 | × | nineonine quits (~nineonine@2604:3d08:7785:9600:8c3e:8d1a:de68:76d3) (Ping timeout: 260 seconds) |
| 2021-02-27 16:32:33 | <ixlun> | Right, I think I get it. |
| 2021-02-27 16:32:35 | × | [1]MrMobius quits (~MrMobius@208.58.206.154) (Ping timeout: 256 seconds) |
| 2021-02-27 16:32:51 | hackage | monad-parallel 0.7.2.4 - Parallel execution of monadic computations https://hackage.haskell.org/package/monad-parallel-0.7.2.4 (MarioBlazevic) |
| 2021-02-27 16:33:35 | <ixlun> | Ah, just found it.. https://hackage.haskell.org/package/base-4.14.1.0/docs/src/GHC.Base.html#line-983 |
| 2021-02-27 16:34:17 | <tomsmeding> | and it's the only possible type-checking implementation, if you don't count undefined or nontermination |
| 2021-02-27 16:34:34 | × | nbloomf quits (~nbloomf@2600:1700:ad14:3020:5561:62ee:ba22:2677) (Quit: My MacBook has gone to sleep. ZZZzzz…) |
| 2021-02-27 16:34:56 | × | heatsink quits (~heatsink@2600:1700:bef1:5e10:44cd:7ec7:332d:f0ab) (Ping timeout: 240 seconds) |
| 2021-02-27 16:35:37 | → | danvet joins (~Daniel@2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa) |
| 2021-02-27 16:35:59 | → | troydm joins (~troydm@unaffiliated/troydm) |
| 2021-02-27 16:37:45 | → | dyeplexer joins (~lol@unaffiliated/terpin) |
| 2021-02-27 16:39:28 | → | Lycurgus joins (~niemand@cpe-45-46-139-165.buffalo.res.rr.com) |
| 2021-02-27 16:41:27 | <c_wraith> | tomsmeding: not *quite* true. there are two possible implementations with different strictness |
| 2021-02-27 16:41:55 | <tomsmeding> | and again you catch me worrying too little about laziness |
| 2021-02-27 16:41:58 | → | rayyyy joins (~nanoz@gateway/tor-sasl/nanoz) |
| 2021-02-27 16:42:13 | <c_wraith> | actually, I guess there are three, if you do something terrifying and use seq |
| 2021-02-27 16:42:52 | <tomsmeding> | but then there are eight possible implementations, right? there are three different values (x, y and f y), and each can be either forced or not |
| 2021-02-27 16:43:18 | <tomsmeding> | oh and you can also force the input tuple or not, so that makes 16 |
| 2021-02-27 16:43:46 | <tomsmeding> | I suspect you only counted forcing the input tuple or not? |
| 2021-02-27 16:43:49 | <c_wraith> | you can't force x or y without forcing the tuple |
| 2021-02-27 16:43:49 | → | kupi joins (uid212005@gateway/web/irccloud.com/x-vvucditfymkrygow) |
| 2021-02-27 16:43:56 | ← | albert_42 parts (~albert_42@2a02:8108:1100:16d8:148b:5e15:b9c8:a370) () |
| 2021-02-27 16:43:58 | <c_wraith> | so those aren't independent |
| 2021-02-27 16:43:59 | <tomsmeding> | oh true |
| 2021-02-27 16:44:23 | <tomsmeding> | 8 + 1 = 9 then |
| 2021-02-27 16:44:26 | <c_wraith> | but let's not count things using seq. I mostly just meant matching the input with a ! or not |
| 2021-02-27 16:44:33 | → | tzh joins (~tzh@c-24-21-73-154.hsd1.or.comcast.net) |
| 2021-02-27 16:44:36 | <c_wraith> | err, with a ~ or not |
| 2021-02-27 16:44:37 | × | ixlun quits (~user@109.249.184.227) (Read error: Connection reset by peer) |
| 2021-02-27 16:44:52 | <tomsmeding> | (or bang patterns) |
| 2021-02-27 16:45:06 | <tomsmeding> | but yes the "~ or not" is the most reasonable choice |
| 2021-02-27 16:46:04 | → | nineonine joins (~nineonine@2604:3d08:7785:9600:8c3e:8d1a:de68:76d3) |
| 2021-02-27 16:46:08 | <tomsmeding> | s/most/only/ |
| 2021-02-27 16:47:11 | → | ixlun joins (~user@213.205.241.177) |
| 2021-02-27 16:49:00 | <monochrom> | You might not like how "fmap id ⊥ = (⊥, ⊥) ≠ id ⊥" |
| 2021-02-27 16:49:00 | × | ixlun quits (~user@213.205.241.177) (Read error: Connection reset by peer) |
| 2021-02-27 16:50:30 | → | ixlun joins (~user@213.205.241.177) |
| 2021-02-27 16:51:27 | → | ep1ctetus joins (~epictetus@ip72-194-215-136.sb.sd.cox.net) |
| 2021-02-27 16:54:07 | → | nbloomf joins (~nbloomf@2600:1700:ad14:3020:411:b35c:bf3:8b48) |
| 2021-02-27 16:55:36 | → | ixlun` joins (~user@213.205.241.43) |
| 2021-02-27 16:55:50 | × | basoares quits (~basoares@2a04:ee41:4:2178:888c:4f28:a48f:16bd) (Quit: Leaving) |
| 2021-02-27 16:56:05 | <tomsmeding> | > length (fmap id (undefined, undefined) :: (Int, Bool)) |
| 2021-02-27 16:56:06 | <lambdabot> | 1 |
| 2021-02-27 16:56:07 | × | lassulus quits (~lassulus@NixOS/user/lassulus) (Ping timeout: 260 seconds) |
| 2021-02-27 16:56:11 | <tomsmeding> | > length (fmap id undefined :: (Int, Bool)) |
| 2021-02-27 16:56:13 | <lambdabot> | 1 |
| 2021-02-27 16:56:21 | <tomsmeding> | wut lambdabot does not agree with my ghci |
| 2021-02-27 16:56:24 | → | conal joins (~conal@64.71.133.70) |
| 2021-02-27 16:57:00 | <tomsmeding> | % length (fmap id undefined :: (Int, Bool)) |
| 2021-02-27 16:57:00 | <yahb> | tomsmeding: 1 |
| 2021-02-27 16:57:09 | tomsmeding | is confused |
| 2021-02-27 16:57:30 | <tomsmeding> | my ghci throws undefined on that input |
| 2021-02-27 16:57:35 | <tomsmeding> | % :q |
| 2021-02-27 16:57:35 | <yahb> | tomsmeding: |
| 2021-02-27 16:57:38 | <tomsmeding> | % length (fmap id undefined :: (Int, Bool)) |
| 2021-02-27 16:57:40 | <yahb> | tomsmeding: 1 |
| 2021-02-27 16:57:40 | × | ixlun quits (~user@213.205.241.177) (Ping timeout: 265 seconds) |
| 2021-02-27 16:57:47 | <tomsmeding> | ¯\_(ツ)_/¯ |
| 2021-02-27 16:58:55 | <tomsmeding> | this did not change between 8.8.4 and whatever yahb uses, did it? |
| 2021-02-27 17:00:58 | <monochrom> | Hrm what does yahb use???!!!! Heh |
| 2021-02-27 17:01:18 | <dmwit> | Yes, it changed very recently. Compare base-4.13 and base-4.14: |
| 2021-02-27 17:01:24 | <dmwit> | http://hackage.haskell.org/package/base-4.13.0.0/docs/src/Data.Foldable.html#line-363 |
| 2021-02-27 17:01:30 | <dmwit> | http://hackage.haskell.org/package/base-4.14.0.0/docs/src/Data.Foldable.html#line-363 |
| 2021-02-27 17:01:47 | <tomsmeding> | OH length CHANGED |
| 2021-02-27 17:01:53 | × | ep1ctetus quits (~epictetus@ip72-194-215-136.sb.sd.cox.net) (Read error: Connection reset by peer) |
| 2021-02-27 17:02:03 | <dmwit> | IDK why `length` and `null` were special-cased. You would think they would go all the way and `foldMap f ~(_, y) = f y`. |
| 2021-02-27 17:02:09 | tomsmeding | thought to have found a good way to check whether a tuple is evaluated or not |
| 2021-02-27 17:02:29 | <dmwit> | Does... does seq not work for some reason? |
| 2021-02-27 17:02:49 | <tomsmeding> | it does |
| 2021-02-27 17:03:06 | <tomsmeding> | % (fmap id (undefined, undefined) :: (Int, Bool)) `seq` () |
| 2021-02-27 17:03:06 | <yahb> | tomsmeding: () |
| 2021-02-27 17:03:12 | <tomsmeding> | % (fmap id undefined :: (Int, Bool)) `seq` () |
| 2021-02-27 17:03:13 | <yahb> | tomsmeding: *** Exception: Prelude.undefined; CallStack (from HasCallStack):; error, called at libraries/base/GHC/Err.hs:75:14 in base:GHC.Err; undefined, called at <interactive>:3:10 in interactive:Ghci6 |
| 2021-02-27 17:03:18 | <tomsmeding> | there we go |
| 2021-02-27 17:03:20 | <dmwit> | why so complicated |
| 2021-02-27 17:03:25 | <dmwit> | > (undefined, undefined) `seq` () |
| 2021-02-27 17:03:25 | × | ixlun` quits (~user@213.205.241.43) (Read error: Connection reset by peer) |
All times are in UTC.