Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→ 1,804,532 events total
2021-08-27 14:29:54 <lambdabot> error:
2021-08-27 14:29:55 <lambdabot> • No instance for (Num (Maybe ())) arising from a use of ‘e_10’
2021-08-27 14:29:55 <lambdabot> • In the expression: e_10
2021-08-27 14:30:01 <hololeap> % Data.Monoid.First (Just 4) <> undefined
2021-08-27 14:30:02 <yahb> hololeap: *** Exception: heap overflow
2021-08-27 14:30:26 <hololeap> % 4
2021-08-27 14:30:27 <yahb> hololeap: 4
2021-08-27 14:30:36 <int-e> @let import qualified Data.Semigroup
2021-08-27 14:30:37 <lambdabot> Defined.
2021-08-27 14:30:39 <int-e> > Data.Semigroup.First 1 <> undefined
2021-08-27 14:30:41 <lambdabot> First {getFirst = 1}
2021-08-27 14:31:13 <janus> > foldMap (\i -> if i > 5 then Just (Data.Semigroup.First i) else Nothing) [0::Expr .. 6]
2021-08-27 14:31:14 <lambdabot> Just (First {getFirst = 6})
2021-08-27 14:31:16 × dschrempf quits (~dominik@070-207.dynamic.dsl.fonira.net) (Ping timeout: 252 seconds)
2021-08-27 14:31:40 <hololeap> well, it looks like First from Data.Monoid is what I want, then
2021-08-27 14:31:47 <int-e> Oh I misread the test (i > 5), my bad.
2021-08-27 14:31:50 <jippiedoe> Ah, I think I know! The Monoid instance for Maybe forces the right element
2021-08-27 14:32:20 <jippiedoe> ..and while I checked that int-e already said so too :)
2021-08-27 14:32:28 <[exa]> sneaky how First is supposed to contain the Maybe inside.
2021-08-27 14:32:52 <hololeap> int-e: thanks for pointing that out. Data.Monoid.First doesn't have this behavior, this returns First (Just 4): Data.Maybe.First (Just 4) <> undefined
2021-08-27 14:33:13 <janus> so if one used a naive Maybe and made a First for that, it would work?
2021-08-27 14:33:28 <int-e> [exa]: yeah but this question explains why that is, really.
2021-08-27 14:34:01 × markpythonicbtc quits (~textual@50.228.44.6) (Ping timeout: 252 seconds)
2021-08-27 14:34:10 <[exa]> yeah
2021-08-27 14:34:52 derelict joins (~derelict@user/derelict)
2021-08-27 14:35:38 nilof joins (~olofs@90-227-86-119-no542.tbcn.telia.com)
2021-08-27 14:35:43 <janus> why does Maybe force the right argument?
2021-08-27 14:35:58 <janus> (for mappend) ?
2021-08-27 14:36:02 <int-e> janus: because Just x <> Just y = Just (x <> y)
2021-08-27 14:36:14 dschrempf joins (~dominik@070-207.dynamic.dsl.fonira.net)
2021-08-27 14:36:19 <int-e> you can't get that without inspecting the right argument
2021-08-27 14:36:54 <int-e> (generically, without knowing anything about the inner <>)
2021-08-27 14:36:55 <janus> oh, i thought there was some strictness hack. but it actually needs the value
2021-08-27 14:37:07 × notzmv quits (~zmv@user/notzmv) (Ping timeout: 240 seconds)
2021-08-27 14:38:45 <hololeap> int-e, so it seems like this behavior would also arise for other types that "inherit" their contents' Semigroup instance, such as (,)
2021-08-27 14:39:45 <hololeap> (x1,y1) <> (x2,y2) = (x1<>x2, y1<>y2) -- it has to inspect the right argument here, too
2021-08-27 14:40:12 azeem joins (~azeem@62.19.187.81)
2021-08-27 14:41:11 <janus> hmmm, if Ord was written with a max/min interface instead of relying on its own types, i wonder if the example with Expr could be illustrative
2021-08-27 14:41:12 <int-e> hololeap: Right, the actual implementation (from GHC.Base of all places... interesting) is (a,b) <> (a',b') = (a<>a',b<>b')
2021-08-27 14:41:38 hannessteffenhag joins (~hannesste@ip4d14ffc8.dynamic.kabel-deutschland.de)
2021-08-27 14:41:46 <int-e> hololeap: one /could/ get away with ~(a,b) <> ~(a',b') = (a<>a',b<>b') here, but it's probably a bad trade-off (performance for extra laziness)
2021-08-27 14:42:31 <janus> surely an interface "class Ord where min :: (a,a) -> a" should be equivalent to what standard Ord provides?
2021-08-27 14:42:42 <int-e> And in any case this use of irrefutable patterns only works for single constructor types.
2021-08-27 14:42:43 <hololeap> ultimately, I'm running a fold that accumulates something like (Maybe X, Maybe Y), and I want it to short-circuit as soon as the accumulator hits (Just X, Just Y)
2021-08-27 14:43:13 × MQ-17J quits (~MQ-17J@d14-69-206-129.try.wideopenwest.com) (Ping timeout: 248 seconds)
2021-08-27 14:43:17 <hololeap> and I thought maybe I could glue something together out of pieces from Data.Monoid and Data.Semigroup
2021-08-27 14:43:22 × acidjnk_new quits (~acidjnk@p200300d0c72b95925da55fe159cc0756.dip0.t-ipconnect.de) (Ping timeout: 245 seconds)
2021-08-27 14:43:46 <int-e> janus: that's... horrible.
2021-08-27 14:44:00 <int-e> :t min
2021-08-27 14:44:01 <lambdabot> Ord a => a -> a -> a
2021-08-27 14:44:07 × azeem quits (~azeem@62.19.187.81) (Ping timeout: 240 seconds)
2021-08-27 14:44:39 <int-e> the thought of computing x <= y as min x y == x makes me cringe.
2021-08-27 14:44:52 <janus> int-e: but it works better with Expr , no ? ;)
2021-08-27 14:45:07 <int-e> > let xs = [1..]; ys = [2..] in xs < ys
2021-08-27 14:45:08 <lambdabot> True
2021-08-27 14:45:16 <int-e> > let xs = [1..]; ys = [2..] in min xs ys == xs
2021-08-27 14:45:22 <lambdabot> mueval-core: Time limit exceeded
2021-08-27 14:45:29 <int-e> so that's a hard no
2021-08-27 14:45:51 <sszark2> What does c signify in this expression? `c <- [1..10], b <- [1..c]`
2021-08-27 14:45:57 <janus> i made no claim about infinite lists ;)
2021-08-27 14:46:07 × hannessteffenhag quits (~hannesste@ip4d14ffc8.dynamic.kabel-deutschland.de) (Ping timeout: 252 seconds)
2021-08-27 14:46:10 sszark2 is now known as sszark
2021-08-27 14:46:10 <dminuoso> sszark2: This is not a full expression.
2021-08-27 14:46:11 <int-e> sszark2: that's not an expression. it's probably part of a list comprehension
2021-08-27 14:46:11 × [itchyjunk] quits (~itchyjunk@user/itchyjunk/x-7353470) (Remote host closed the connection)
2021-08-27 14:46:35 × cfricke quits (~cfricke@user/cfricke) (Quit: WeeChat 3.2)
2021-08-27 14:46:43 <int-e> sszark: where intuitively, c <- [1..10] makes c (a fresh variable at that point) range over the elements of [1..10]
2021-08-27 14:47:04 <janus> i really just wanted to ponder whether an alternate ord could be defined such that it would work for the [0::Expr .. 6] example above
2021-08-27 14:47:58 MQ-17J joins (~MQ-17J@d14-69-206-129.try.wideopenwest.com)
2021-08-27 14:48:26 <int-e> janus: well, no. you don't even get out of that problem, because you'll still need (==), and (==) :: Expr -> Expr -> Bool runs into the same problem that you wanted to avoid.
2021-08-27 14:48:38 <mastarija> Do we have some kind of reader monad in base or is it necessary to use transformers package?
2021-08-27 14:48:45 <sszark> So c just makes the range for b the same length as c here?
2021-08-27 14:49:19 <mastarija> I want to use doctest, and write an example with a reader monad, but I don't want to include transformers package just for that.
2021-08-27 14:49:29 <int-e> sszark: yes. it's enumerating c,b with 1 <= b <= c <= 10
2021-08-27 14:49:41 <janus> int-e: damn, gotta make a continuation based Eq also then... :P
2021-08-27 14:49:47 <maerwald> mastarija: yes ((->) r)
2021-08-27 14:50:09 <janus> purge all bools
2021-08-27 14:50:12 <mastarija> oh.. right, function is monad
2021-08-27 14:50:24 <int-e> janus: This may be too high a price to pay for solving the Expr.. problem.
2021-08-27 14:50:35 <janus> there are no limits to my masochism
2021-08-27 14:50:57 <int-e> > map fromIntegral [1..6] :: [Expr]
2021-08-27 14:50:59 <lambdabot> [1,2,3,4,5,6]
2021-08-27 14:51:55 azeem joins (~azeem@176.201.15.153)
2021-08-27 14:53:22 hannessteffenhag joins (~hannesste@ip4d14ffc8.dynamic.kabel-deutschland.de)
2021-08-27 14:53:32 notzmv joins (~zmv@user/notzmv)
2021-08-27 14:53:58 merijn joins (~merijn@83-160-49-249.ip.xs4all.nl)
2021-08-27 14:55:55 × gehmehgeh quits (~user@user/gehmehgeh) (Quit: Leaving)
2021-08-27 14:56:47 × peterhil quits (~peterhil@dsl-hkibng32-54fb52-57.dhcp.inet.fi) (Ping timeout: 240 seconds)
2021-08-27 14:57:37 × epolanski quits (uid312403@id-312403.helmsley.irccloud.com) (Quit: Connection closed for inactivity)
2021-08-27 14:57:57 × jippiedoe quits (~david@2a02-a44c-e14e-1-ff47-c45c-287d-42e8.fixed6.kpn.net) (Quit: Leaving)
2021-08-27 15:00:47 lavaman joins (~lavaman@98.38.249.169)
2021-08-27 15:01:50 hnOsmium0001 joins (uid453710@id-453710.stonehaven.irccloud.com)
2021-08-27 15:02:52 vpan joins (~vilius@212.117.1.172)
2021-08-27 15:03:47 × xff0x quits (~xff0x@2001:1a81:53dc:be00:a2ac:ecf7:da22:1207) (Ping timeout: 240 seconds)
2021-08-27 15:04:57 xff0x joins (~xff0x@2001:1a81:53dc:be00:a197:89df:f531:cbff)
2021-08-27 15:05:07 × notzmv quits (~zmv@user/notzmv) (Ping timeout: 240 seconds)
2021-08-27 15:07:01 notzmv joins (~zmv@user/notzmv)
2021-08-27 15:08:05 × MQ-17J quits (~MQ-17J@d14-69-206-129.try.wideopenwest.com) (Read error: Connection reset by peer)
2021-08-27 15:08:06 × bitdex quits (~bitdex@gateway/tor-sasl/bitdex) (Quit: = "")
2021-08-27 15:08:16 MQ-17J joins (~MQ-17J@d14-69-206-129.try.wideopenwest.com)

All times are in UTC.