Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→
Page 1 .. 907 908 909 910 911 912 913 914 915 916 917 .. 5022
502,152 events total
2020-10-28 04:51:08 <sandmwitch> What does "if anything fails the predicate then I would have Just 0 returned" mean?
2020-10-28 04:51:26 <sandmwitch> Are you saying that you expect that `trevarse aa foo = Just 0` whenever there is a negative number somewhere in `foo`?
2020-10-28 04:51:36 <sandmwitch> If so, why do you expect that?
2020-10-28 04:51:43 merijn joins (~merijn@83-160-49-249.ip.xs4all.nl)
2020-10-28 04:51:45 <sandmwitch> (trevarse -> traverse, obviously)
2020-10-28 04:52:45 <crestfallen> so if we used this func, and gave it the list [2,4,6] we'd have Just [1,2,3]
2020-10-28 04:53:34 <crestfallen> so every member of the list needs to be even. but the other function I figured would return (Just 0)
2020-10-28 04:56:28 × Tario quits (~Tario@201.192.165.173) (Ping timeout: 265 seconds)
2020-10-28 04:56:42 <sandmwitch> Why did you figure that, though?
2020-10-28 04:57:08 × GyroW quits (~GyroW@unaffiliated/gyrow) (Quit: Someone ate my pie)
2020-10-28 04:57:16 × falafel quits (~falafel@71-34-132-121.clsp.qwest.net) (Ping timeout: 260 seconds)
2020-10-28 04:57:18 GyroW joins (~GyroW@d54C03E98.access.telenet.be)
2020-10-28 04:57:18 × GyroW quits (~GyroW@d54C03E98.access.telenet.be) (Changing host)
2020-10-28 04:57:18 GyroW joins (~GyroW@unaffiliated/gyrow)
2020-10-28 04:57:46 × fraktor quits (~walt@129.93.191.18) (Quit: WeeChat 2.8)
2020-10-28 04:58:08 × mmohammadi9812 quits (~mmohammad@2.178.146.18) (Ping timeout: 256 seconds)
2020-10-28 04:58:37 bartemius joins (~bartemius@109-252-20-20.nat.spd-mgts.ru)
2020-10-28 04:59:13 <crestfallen> because whatever goes after the else clause would be returned as (Just 0) ; I didn't expect 0 to be integrated into (Con 0) like that. weird
2020-10-28 04:59:46 <sandmwitch> The then/else divide is not special. The Just/Nothing divide is special.
2020-10-28 04:59:55 × ransom quits (~c4264035@c-73-243-2-10.hsd1.co.comcast.net) (Quit: My MacBook has gone to sleep. ZZZzzz…)
2020-10-28 05:00:22 mmohammadi9812 joins (~mmohammad@2.178.187.147)
2020-10-28 05:00:29 <sandmwitch> (And the *reason* it is special is because the Applicative instance for Maybe does different things depending on whether it sees Just or Nothing.)
2020-10-28 05:01:15 <crestfallen> sandmwitch: thanks not sure I see exactly what's happening
2020-10-28 05:02:18 <crestfallen> I thought Just 0 would be a return value
2020-10-28 05:02:41 × Amras quits (~Amras@unaffiliated/amras0000) (Ping timeout: 272 seconds)
2020-10-28 05:04:26 <koz_> :t traverse
2020-10-28 05:04:27 <lambdabot> (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)
2020-10-28 05:04:33 <koz_> Note what happens to the 'f'.
2020-10-28 05:05:47 Tario joins (~Tario@201.192.165.173)
2020-10-28 05:05:59 <crestfallen> in the return? : f (t b) koz_
2020-10-28 05:06:30 <koz_> crestfallen: Yeah, exactly. That's what makes 'traverse' what it is. Now, notice where that 'f' is in the function argument to traverse.
2020-10-28 05:06:39 <koz_> Now, look at your situation - what is 'f' in your case.
2020-10-28 05:06:43 <koz_> Take. Due. Care.
2020-10-28 05:07:47 <crestfallen> f is Maybe.. in this case Just
2020-10-28 05:08:06 <koz_> The first was right, then you sank yourself. Again, please do not confuse the value level and the type level.
2020-10-28 05:08:11 tdhttt joins (~tdhttt@static-198-54-131-149.cust.tzulo.com)
2020-10-28 05:08:24 <crestfallen> hold on
2020-10-28 05:08:26 <koz_> So therefore, given your 'aa', you'll _always_ end up with Just [some tree inside].
2020-10-28 05:08:47 <koz_> Because no matter which branch you take, you'll get a Just.
2020-10-28 05:08:47 christo joins (~chris@81.96.113.213)
2020-10-28 05:09:07 <koz_> And since in your case, f ~ Maybe, the expected result is 'Maybe (Tree Int)'.
2020-10-28 05:09:11 <koz_> Which is exactly what you're seeing.
2020-10-28 05:09:20 <koz_> s/result/result type/
2020-10-28 05:10:07 × Kaiepi quits (~Kaiepi@nwcsnbsc03w-47-55-225-82.dhcp-dynamic.fibreop.nb.bellaliant.net) (Remote host closed the connection)
2020-10-28 05:10:48 <crestfallen> ...
2020-10-28 05:15:09 <crestfallen> so koz_ that behavior is interesting. it seems like the logic in the if / then statement has changed. (Just 0) is feeding the value to the rhs branch : (Con 0). trying to wrap my head around that
2020-10-28 05:15:36 <koz_> No, the logic in the if-then-else hasn't 'changed', whatever that means.
2020-10-28 05:15:47 <koz_> Look at your definition of 'traverse'.
2020-10-28 05:15:54 <koz_> (for your Tree type).
2020-10-28 05:16:00 × damianfral4 quits (~damianfra@243.red-176-80-34.dynamicip.rima-tde.net) (Ping timeout: 258 seconds)
2020-10-28 05:16:08 xxxzzzqqaa` joins (3dded63f@61-222-214-63.HINET-IP.hinet.net)
2020-10-28 05:16:29 <koz_> That behaviour _is_ interesting, but the if-then-else you have there is literally the least interesting part of it.
2020-10-28 05:16:35 <koz_> It's all about the traverse definition.
2020-10-28 05:16:53 <crestfallen> what I meant was ... else Nothing changes the logic
2020-10-28 05:17:00 <koz_> It does.
2020-10-28 05:17:10 <koz_> And that's because of _the traverse definition_.
2020-10-28 05:17:16 <koz_> I cannot stress enough just how much it matters.
2020-10-28 05:17:31 <Axman6> returning Nothing anywhere from the function passed to traverse causes the result to be Nothing, since that's what the applicative instance for Nothing requires
2020-10-28 05:17:34 <Axman6> uh, for Maybe
2020-10-28 05:18:14 <crestfallen> right. let me re-paste one sec
2020-10-28 05:18:14 <koz_> Axman6: Well, assuming it's not conditional on the values 'in' the Traversable somehow.
2020-10-28 05:18:17 xerox_ joins (~xerox@unaffiliated/xerox)
2020-10-28 05:18:20 <Axman6> iun traverse fn (Con a) = Con <$> (fn a), if fn returns Nothing, then the Con being fmapped over that Nothing still gives you as Nothing
2020-10-28 05:18:42 <Axman6> @src Functor @Maybe
2020-10-28 05:18:42 <lambdabot> Source not found. Do you think like you type?
2020-10-28 05:19:13 <koz_> Sassy lambdabot.
2020-10-28 05:19:42 <crestfallen> sorry just to keep a reference http://ix.io/2CfX
2020-10-28 05:19:50 <Axman6> fmap f (Just a) = Just (f a); fmap _ Nothing = Nothing
2020-10-28 05:22:18 notzmv joins (~user@unaffiliated/zmv)
2020-10-28 05:23:35 <crestfallen> so the first Just in aa is the constructor for Maybe Tree a. the second Just : else (Just 0) is actually being fmapped over
2020-10-28 05:23:41 × nbloomf quits (~nbloomf@2600:1700:ad14:3020:4998:5831:a85a:ec6f) (Quit: My MacBook has gone to sleep. ZZZzzz…)
2020-10-28 05:23:46 day_ joins (~Unknown@unaffiliated/day)
2020-10-28 05:25:06 <crestfallen> Axman6: am I correct?
2020-10-28 05:25:19 <Axman6> I don't think so, you seem very confused
2020-10-28 05:26:01 × merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 264 seconds)
2020-10-28 05:26:45 × day quits (~Unknown@unaffiliated/day) (Ping timeout: 240 seconds)
2020-10-28 05:26:45 day_ is now known as day
2020-10-28 05:27:16 <Axman6> I think you need to step through this line by line: traverse bb (Add (Add (Con 3) (Con 4)) (Con (-5))) ==> Add <$> traverse bb (Add (Con 3) (Con 4)) <*> (Con (-5)) ==> ???
2020-10-28 05:27:46 <crestfallen> Axman6: no I get it. in aa there is no failure at all. so (Con a) on the right hand branch is going to take the 0.
2020-10-28 05:27:49 <Axman6> just keep substituting the definitions for traverse, once you have none left, substitute in the definition for bb, in the Con 9 case
2020-10-28 05:27:58 <dminuoso> TIL, operator dont have to be functions. :>
2020-10-28 05:28:11 <dminuoso> % (.>>) = ">>"
2020-10-28 05:28:12 <yahb> dminuoso:
2020-10-28 05:28:26 <Axman6> % :t (%)
2020-10-28 05:28:26 <yahb> Axman6: Integral a => a -> a -> Ratio a
2020-10-28 05:28:34 <Axman6> % :t (.>>)
2020-10-28 05:28:34 <yahb> Axman6: [Char]
2020-10-28 05:28:52 <koz_> Oh wow, TIL indeed.
2020-10-28 05:29:11 <Axman6> crestfallen: I would _strongly_ recommend you go the evaluation by hand I suggested above
2020-10-28 05:29:25 <dminuoso> Im using this in a code generator with haskell-src-exts, such that I can do
2020-10-28 05:29:25 thir joins (~thir@p200300f27f0b7e004c18ab60065ea01b.dip0.t-ipconnect.de)
2020-10-28 05:30:05 <dminuoso> let (.>>) = op (sym ">>") in infixApp fooE (.>>) barE
2020-10-28 05:32:44 Sanchayan joins (~Sanchayan@122.167.95.166)
2020-10-28 05:32:48 <dminuoso> (Though ultimately I think Im going to use QQ instead, since [hs| $fooE >> $barE |] is a bit more readable)
2020-10-28 05:33:44 × thir quits (~thir@p200300f27f0b7e004c18ab60065ea01b.dip0.t-ipconnect.de) (Ping timeout: 240 seconds)
2020-10-28 05:34:48 <dsal> :t infixApp
2020-10-28 05:34:49 <lambdabot> error: Variable not in scope: infixApp
2020-10-28 05:35:50 <koz_> dminuoso: I recently wrote my first quasi-quoters, and it was honestly rather pleasant.
2020-10-28 05:36:05 <dsal> oooh
2020-10-28 05:36:57 × howdoi quits (uid224@gateway/web/irccloud.com/x-vkinnmkhoknarggj) (Quit: Connection closed for inactivity)

All times are in UTC.