Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→
Page 1 .. 922 923 924 925 926 927 928 929 930 931 932 .. 5022
502,152 events total
2020-10-28 21:59:27 NieDzejkob joins (~quassel@188.123.215.55)
2020-10-28 21:59:27 rzmt joins (~rzmt@87-92-180-112.rev.dnainternet.fi)
2020-10-28 21:59:30 drewolson joins (~drewolson@64.227.24.16)
2020-10-28 21:59:30 milessabin joins (sid86799@gateway/web/irccloud.com/x-tsnesmrcjrlroviv)
2020-10-28 21:59:31 digia joins (~digia@unaffiliated/digia)
2020-10-28 21:59:32 sayak1 joins (~sayak@static.11.113.47.78.clients.your-server.de)
2020-10-28 21:59:32 qz joins (~quetzal@li272-85.members.linode.com)
2020-10-28 21:59:32 clynamen joins (~clynamen@109.116.4.71)
2020-10-28 21:59:34 bobbytables joins (~bobbytabl@ec2-44-224-191-138.us-west-2.compute.amazonaws.com)
2020-10-28 21:59:36 marble_visions joins (~user@68.183.79.8)
2020-10-28 21:59:38 HiRE joins (~HiRE@2602:ffc5:20::1:512e)
2020-10-28 21:59:39 bsima joins (~bsima@simatime.com)
2020-10-28 21:59:41 stvc joins (~stvc@192.241.166.39)
2020-10-28 21:59:46 gekh joins (~gkh@thor.kevinhill.nl)
2020-10-28 21:59:50 zopsi joins (~zopsi@irc.dir.ac)
2020-10-28 22:00:00 Flonk joins (~Flonk@ec2-52-40-29-25.us-west-2.compute.amazonaws.com)
2020-10-28 22:00:07 amatecha__ joins (sid10006@gateway/web/irccloud.com/x-umzvzowaztsfellj)
2020-10-28 22:01:40 × esph quits (~weechat@unaffiliated/esph) (Read error: Connection reset by peer)
2020-10-28 22:02:01 × pfurla quits (~pfurla@ool-182ed2e2.dyn.optonline.net) (Ping timeout: 264 seconds)
2020-10-28 22:02:01 × nckx quits (~nckx@tobias.gr) (Ping timeout: 264 seconds)
2020-10-28 22:02:09 tv- joins (~tv@unaffiliated/tv-)
2020-10-28 22:02:10 sim590 joins (~sim590@modemcable090.207-203-24.mc.videotron.ca)
2020-10-28 22:02:10 <jle`> :t foldM
2020-10-28 22:02:11 <lambdabot> (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b
2020-10-28 22:02:20 × britva quits (~britva@31-10-157-156.cgn.dynamic.upc.ch) (Quit: This computer has gone to sleep)
2020-10-28 22:02:21 <jle`> yea that needs to be monady
2020-10-28 22:02:36 <jle`> since you have to bind the 'b' to use the (b -> a -> m b)
2020-10-28 22:02:37 <koz_> I guess if it was an 'effectful foldMap' it wouldn't?
2020-10-28 22:02:47 nckx joins (~nckx@tobias.gr)
2020-10-28 22:02:49 × tv- quits (~tv@unaffiliated/tv-) (Client Quit)
2020-10-28 22:03:10 tv- joins (~tv@unaffiliated/tv-)
2020-10-28 22:03:37 esph joins (~weechat@unaffiliated/esph)
2020-10-28 22:03:39 <jle`> yeah, like traverse_
2020-10-28 22:03:45 <jle`> er, traverse
2020-10-28 22:03:50 crestfallen joins (~john@128.32.176.159)
2020-10-28 22:03:51 <koz_> Yeah, except a general monoid instead of ().
2020-10-28 22:04:01 <jle`> in this case the "next `m b` to use" depends on the result of a previous action
2020-10-28 22:04:05 <jle`> :t traverse
2020-10-28 22:04:06 <lambdabot> (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)
2020-10-28 22:04:13 elliott_ joins (~elliott_@pool-108-51-141-12.washdc.fios.verizon.net)
2020-10-28 22:04:17 <jle`> but for traverse, the "next `f b`" can be decided without any previous actions
2020-10-28 22:04:23 <koz_> It'd be like 'foldMapA :: (Applicative f, Monoid m, Traversable t) => (a -> f m) -> t a -> f m'
2020-10-28 22:04:24 <Uniaika> (obligatory slides for Traverse: https://clementd-files.cellar-c2.services.clever-cloud.com/lambdalille-traverse.html#1.0 )
2020-10-28 22:04:36 <jle`> koz_: that's foldMap with Ap, yeah
2020-10-28 22:04:44 × mmohammadi9812 quits (~mmohammad@2.178.160.31) (Ping timeout: 240 seconds)
2020-10-28 22:04:51 <koz_> It's not _quite_ a generalized traverse_.
2020-10-28 22:04:55 <koz_> (stronger constraint needed)
2020-10-28 22:05:06 <jle`> :t \f -> getAp . foldMap (Ap . f)
2020-10-28 22:05:07 <lambdabot> forall k (t :: * -> *) (f :: k -> *) (a1 :: k) a2. (Foldable t, Monoid (Ap f a1)) => (a2 -> f a1) -> t a2 -> f a1
2020-10-28 22:05:19 <jle`> hm, that's weird
2020-10-28 22:05:32 <jle`> it should have the same type as yours
2020-10-28 22:05:34 <koz_> Monoid (Ap f a) holds whenever Applicative f, right?
2020-10-28 22:05:53 <jle`> (Applicative f, Monoid a) => Monoid (Ap f a)
2020-10-28 22:06:07 pfurla joins (~pfurla@ool-182ed2e2.dyn.optonline.net)
2020-10-28 22:06:18 <jle`> i'm pretty sure your foldMapA is equivalent to traverse_
2020-10-28 22:06:37 <koz_> :t traverse_
2020-10-28 22:06:38 <lambdabot> (Foldable t, Applicative f) => (a -> f b) -> t a -> f ()
2020-10-28 22:07:02 <jle`> use [b] for m
2020-10-28 22:07:02 Someguy123 joins (~someguy@unaffiliated/compgenius999)
2020-10-28 22:07:02 <koz_> Except that instead of (), we can get back any Monoid m.
2020-10-28 22:07:42 <jle`> i think you can implement both in terms of each other
2020-10-28 22:09:50 merijn joins (~merijn@83-160-49-249.ip.xs4all.nl)
2020-10-28 22:09:51 <koz_> I think there's a catch here somewhere.
2020-10-28 22:09:51 <jle`> you'd just use Const m or something like that
2020-10-28 22:09:51 <jle`> for your Applicative
2020-10-28 22:09:51 <jle`> Compose f (Const m)
2020-10-28 22:09:59 <koz_> Ah, I see.
2020-10-28 22:10:04 <koz_> Yeah that'd work.
2020-10-28 22:10:11 nyaomi joins (~naomi@2604:6000:1509:c86e:c878:29ff:fedf:ce89)
2020-10-28 22:10:19 × kritzefitz quits (~kritzefit@212.86.56.80) (Remote host closed the connection)
2020-10-28 22:10:36 <koz_> Would be great to have a helper doing that, admittedly.
2020-10-28 22:10:57 <koz_> It reminds me of something I saw in the churros library which permitted a similar generalization.
2020-10-28 22:11:20 <jle`> % :t \ff -> fmap getConst . getCompose . traverse_ (Compose . fmap Const . ff)
2020-10-28 22:11:21 <yahb> jle`: (Foldable t, Applicative f, Monoid b) => (a -> f b) -> t a -> f b
2020-10-28 22:11:40 <jle`> but it'd be easier to write in terms of foldMap
2020-10-28 22:12:10 <jle`> % :t \ff -> getAp . foldMap (Ap . ff)
2020-10-28 22:12:10 <yahb> jle`: (Foldable t, Applicative f, Monoid a1) => (a2 -> f a1) -> t a2 -> f a1
2020-10-28 22:12:31 <jle`> huh you could even flip the Const if you use Ap
2020-10-28 22:12:57 notnatebtw joins (~nate@125.161.130.165)
2020-10-28 22:12:58 <koz_> That's actually interesting - foldMap and foldr can implement each other, but if you throw in effects, you actually can't do that.
2020-10-28 22:13:13 <jle`> % :t \ff -> getAp . getConst . traverse_ (Const . Ap . ff)
2020-10-28 22:13:13 <yahb> jle`: (Foldable t, Applicative f, Monoid a1) => (a2 -> f a1) -> t a2 -> f a1
2020-10-28 22:13:16 × merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 260 seconds)
2020-10-28 22:13:36 <jle`> koz_: well it's kind of up to what you think is the rightful generalization of foldr
2020-10-28 22:13:49 t1m joins (4dde69fc@gateway/web/ajax/mibbit.com/session)
2020-10-28 22:13:57 <jle`> and foldM isn't necessarily the natural generalization from an applicative standpoint
2020-10-28 22:14:05 <koz_> What's another view?
2020-10-28 22:14:32 <jle`> maybe foldr :: (f a -> f b -> f b) -> f b -> t a -> f b ?
2020-10-28 22:14:48 <jle`> although...i guess that's more of a specialization than a generalization
2020-10-28 22:15:23 <koz_> Yeah, it's not actually similar to the foldMapA above, since you gotta stick effects in both negative and positive positions.
2020-10-28 22:15:47 <koz_> (in the function argument)
2020-10-28 22:16:06 <jle`> hm, i think you can implement foldMapM in terms of foldM
2020-10-28 22:16:08 × t1m quits (4dde69fc@gateway/web/ajax/mibbit.com/session) (Disconnected by services)
2020-10-28 22:16:11 <jle`> you just need Monad in both cases
2020-10-28 22:16:14 <jle`> so they can still implement 'each other'
2020-10-28 22:16:35 <jle`> and you can always use foldMapA with monads too
2020-10-28 22:16:39 <koz_> Yes, that's true.
2020-10-28 22:16:47 <koz_> But the reverse direction doesn't (necessarily) hold.
2020-10-28 22:16:48 <jle`> so, you can implement foldM with foldMapA :)
2020-10-28 22:17:10 <jle`> hm, i wonder if you can implement foldMapA with foldM

All times are in UTC.