Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→ 1,804,163 events total
2025-08-29 19:44:43 cherryramatisdev joins (~cherryram@user/cherryramatisdev)
2025-08-29 19:46:59 × merijn quits (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 260 seconds)
2025-08-29 19:48:14 <lightspell> That would be amazing, thank you.
2025-08-29 19:49:10 × Lycurgus quits (~juan@user/Lycurgus) (Quit: alsoknownas.renjuan.org ( juan@acm.org ))
2025-08-29 19:50:50 arandombit joins (~arandombi@2603:7000:4600:ffbe:ec4b:ec92:8e15:b25a)
2025-08-29 19:50:50 × arandombit quits (~arandombi@2603:7000:4600:ffbe:ec4b:ec92:8e15:b25a) (Changing host)
2025-08-29 19:50:50 arandombit joins (~arandombi@user/arandombit)
2025-08-29 19:53:05 × chromoblob quits (~chromoblo@user/chromob1ot1c) (Remote host closed the connection)
2025-08-29 19:53:10 merijn joins (~merijn@host-vr.cgnat-g.v4.dfn.nl)
2025-08-29 19:53:21 chromoblob joins (~chromoblo@user/chromob1ot1c)
2025-08-29 19:53:48 × L29Ah quits (~L29Ah@wikipedia/L29Ah) (Read error: Connection timed out)
2025-08-29 19:55:44 × arandombit quits (~arandombi@user/arandombit) (Ping timeout: 260 seconds)
2025-08-29 19:58:16 × merijn quits (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 258 seconds)
2025-08-29 19:58:52 × ZLima12 quits (~zlima12@user/meow/ZLima12) (Ping timeout: 256 seconds)
2025-08-29 19:59:38 ZLima12 joins (~zlima12@user/meow/ZLima12)
2025-08-29 20:06:12 × weary-traveler quits (~user@user/user363627) (Remote host closed the connection)
2025-08-29 20:07:41 × cherryramatisdev quits (~cherryram@user/cherryramatisdev) (Quit: WeeChat 4.7.1)
2025-08-29 20:08:32 × fgarcia quits (~lei@user/fgarcia) (Quit: Remote host closed the connection)
2025-08-29 20:08:57 merijn joins (~merijn@host-vr.cgnat-g.v4.dfn.nl)
2025-08-29 20:11:07 × ZLima12 quits (~zlima12@user/meow/ZLima12) (Quit: No Ping reply in 180 seconds.)
2025-08-29 20:12:16 ZLima12 joins (~zlima12@user/meow/ZLima12)
2025-08-29 20:12:35 <tomsmeding> lightspell: https://play.haskell.org/saved/grshBtBn
2025-08-29 20:12:37 <tomsmeding> blegh
2025-08-29 20:12:40 <tomsmeding> it works though
2025-08-29 20:13:48 × merijn quits (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 260 seconds)
2025-08-29 20:14:07 <tomsmeding> I removed the Read derive for Game because StdGen doesn't implement Read; in general, Read was a nice idea back in 1998 but it's slow and not recommended these days
2025-08-29 20:15:16 <tomsmeding> if you want hacky show/read working, you'll either need to implement Read for StdGen yourself, or split the data type in two parts, one of which is Read, the other of which has the StdGen
2025-08-29 20:15:49 <tomsmeding> lightspell: also I cargo-culted the lens code in the StatefulGen instance; I know ~zero about lens
2025-08-29 20:15:57 <tomsmeding> there is probably a way to do this more nicely
2025-08-29 20:16:59 L29Ah joins (~L29Ah@wikipedia/L29Ah)
2025-08-29 20:17:45 cherryramatisdev joins (~cherryram@user/cherryramatisdev)
2025-08-29 20:19:30 <lightspell> This is amazing, thank you so much. I wouldn't have thought to make our own custom StatefulGen. I thought the whole point of a general library was that you could avoid doing that.
2025-08-29 20:20:47 <lightspell> As I learn more, if I figure out a way to do it more nicely, I'll share it on here.
2025-08-29 20:21:00 <monochrom> But then meta-ly the point of FOSS is that the users help make that happen rather than just voting for "someone else should do it".
2025-08-29 20:21:57 <monochrom> (I did my tiny share. https://github.com/haskell/random/pull/183/commits/090f457125d33d8b7b0be4870cf089f344e6360d )
2025-08-29 20:22:23 × cherryramatisdev quits (~cherryram@user/cherryramatisdev) (Client Quit)
2025-08-29 20:24:31 merijn joins (~merijn@host-vr.cgnat-g.v4.dfn.nl)
2025-08-29 20:26:12 arandombit joins (~arandombi@2603:7000:4600:ffbe:ec4b:ec92:8e15:b25a)
2025-08-29 20:26:12 × arandombit quits (~arandombi@2603:7000:4600:ffbe:ec4b:ec92:8e15:b25a) (Changing host)
2025-08-29 20:26:12 arandombit joins (~arandombi@user/arandombit)
2025-08-29 20:26:43 × rvalue quits (~rvalue@about/hackers/rvalue) (Read error: Connection reset by peer)
2025-08-29 20:27:09 rvalue joins (~rvalue@about/hackers/rvalue)
2025-08-29 20:27:57 <monochrom> The general bridge required is likely of the form: If StatefulGen g m, and type r has a lens to g, then StatefulGen r m.
2025-08-29 20:28:18 <monochrom> But I would not be happy if random depended on lens.
2025-08-29 20:29:37 × merijn quits (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 248 seconds)
2025-08-29 20:30:13 × michalz quits (~michalz@185.246.207.197) (Remote host closed the connection)
2025-08-29 20:30:19 <monochrom> No no no.
2025-08-29 20:30:38 <monochrom> The proper solution is to have a proper effect language! >:)
2025-08-29 20:32:31 ljdarj1 joins (~Thunderbi@user/ljdarj)
2025-08-29 20:35:29 × arandombit quits (~arandombi@user/arandombit) (Ping timeout: 248 seconds)
2025-08-29 20:36:01 Googulator43 joins (~Googulato@2a01-036d-0106-28ad-f9f3-8649-eb89-633c.pool6.digikabel.hu)
2025-08-29 20:36:01 × ljdarj quits (~Thunderbi@user/ljdarj) (Ping timeout: 248 seconds)
2025-08-29 20:36:01 ljdarj1 is now known as ljdarj
2025-08-29 20:38:19 × segfaultfizzbuzz quits (~segfaultf@23-93-74-222.fiber.dynamic.sonic.net) (Ping timeout: 260 seconds)
2025-08-29 20:38:50 <tomsmeding> monochrom: even if you'd make random depend on lens, there's no way to write that instance
2025-08-29 20:39:07 <tomsmeding> I guess you could introduce a special newtype for this and attach the instance to that
2025-08-29 20:39:32 <tomsmeding> I guess that does work, yes
2025-08-29 20:40:17 merijn joins (~merijn@host-vr.cgnat-g.v4.dfn.nl)
2025-08-29 20:40:19 <tomsmeding> monochrom: no, that doesn't work, because the 'g' there is the _handle_ type, not the generator type that's being modified
2025-08-29 20:41:09 <tomsmeding> to wit: if m ~ State StdGen, then g ~ StateGenM StdGen, and StateGenM is a data type with zero fields
2025-08-29 20:41:19 <tomsmeding> because there is only one generator in 'State StdGen', so the handle is trivial
2025-08-29 20:41:39 <tomsmeding> for m ~ IO, the handle is (a newtype over) an IORef
2025-08-29 20:42:17 × poscat quits (~poscat@user/poscat) (Remote host closed the connection)
2025-08-29 20:42:28 poscat joins (~poscat@user/poscat)
2025-08-29 20:42:55 <tomsmeding> the haddocks make this even more confusing because they use "g" as a type variable name both for this handle (`StatefulGen g m`, where e.g. g ~ StateGenM StdGen) and for the underlying generator (`StateGenM g`, where e.g. g ~ StdGen)
2025-08-29 20:42:56 × target_i quits (~target_i@user/target-i/x-6023099) (Quit: leaving)
2025-08-29 20:43:37 <tomsmeding> the solution _is_, of course, to have a proper effect language indeed
2025-08-29 20:47:03 × merijn quits (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 260 seconds)
2025-08-29 20:47:14 <lightspell> I was reading about effects libraries but they were over my head for now. I figured I'd get this working with simpler methods first then try to refactor it with effects later as another exercise.
2025-08-29 20:47:19 <lightspell> tomsmeding: That example you sent works in the Haskell playground with v9.10.2, but not with my local compiler with the same version. It suggested turning on MultiParamTypeClasses, which I did, but now I'm still getting this error "Couldn't match type ‘MutableGen f0 GameM’ with ‘()’ arising from a use of ‘System.Random.Internal.$dmuniformByteArrayM’ The type variable ‘f0’ is ambiguous"
2025-08-29 20:47:36 <tomsmeding> lightspell: that remark about effect languages was mostly in jest, by both of us
2025-08-29 20:48:07 <tomsmeding> lightspell: right, the MultiParamTypeClasses is because you're probably in a project with Haskell2010 set as the default language
2025-08-29 20:48:16 <tomsmeding> the playground has ghc's default which is more
2025-08-29 20:48:27 <lightspell> Ah, thank you. I figured it had to be a config difference of some kind.
2025-08-29 20:48:28 <tomsmeding> the uniformByteArrayM is random-1.3
2025-08-29 20:48:35 <tomsmeding> let me check
2025-08-29 20:50:52 <tomsmeding> okay so for some inane reason the `random` maintainers decided that in adding the uniformByteArrayM method to StatefulGen, they wanted to _not_ expose this method from the public API
2025-08-29 20:52:51 segfaultfizzbuzz joins (~segfaultf@23-93-74-222.fiber.dynamic.sonic.net)
2025-08-29 20:54:11 merijn joins (~merijn@host-vr.cgnat-g.v4.dfn.nl)
2025-08-29 20:54:35 <monochrom> There is some chance that it's just forgetfulness. I speak from the anecdotal experience that last time it was newtype StateGen forgetting to say "deriving SplitGen". (Hence the one time I knew how to make a tiny PR heh.)
2025-08-29 20:55:04 <tomsmeding> monochrom: it is not, they explicitly added an export list in the same commit https://github.com/haskell/random/commit/8267ce861aef525937e949e49496d0b39598d93f#diff-fe93ae678c398cfea72ff60186cc2cee27bd752aad99d8fd1ece059c912f0104R23-R41
2025-08-29 20:57:07 <tomsmeding> lightspell: I _think_ you need to replace () by a custom data type (with zero fields, say `data GameRandomHandle = GameRandomHandle`), then write `instance FrozenGen StdGen GameM where { type MutableGen StdGen GameM = GameRandomHandle ; freezeGen _ = gets (^. randomGen) ; thawGen gen = modify (\s -> s & randomGen .~ gen) }`
2025-08-29 20:57:17 <tomsmeding> but this is mentally type-checked, I did not run this through a compiler
2025-08-29 20:59:19 × merijn quits (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 260 seconds)
2025-08-29 21:01:20 ljdarj1 joins (~Thunderbi@user/ljdarj)
2025-08-29 21:01:25 <monochrom> I am currently OK with: If I can't extend StatefulGen g m to StatefulGen (g,s) m, I can settle with StateT g (State s) or StateT s (State g). (Or the polymorphic MonadState this MonadTrans that version.)
2025-08-29 21:02:09 <tomsmeding> yes you can do that, but with the first option your monad is not MonadState s, and with the second option your monad is not StatefulGen
2025-08-29 21:02:13 × ljdarj quits (~Thunderbi@user/ljdarj) (Ping timeout: 260 seconds)
2025-08-29 21:02:13 ljdarj1 is now known as ljdarj
2025-08-29 21:02:27 <tomsmeding> I guess you can newtype-wrap your monad and write your own MonadState s instance
2025-08-29 21:03:01 <tomsmeding> or you can lift the StatefulGen methods over the StateT s, with the second option
2025-08-29 21:03:27 <tomsmeding> you can't be MonadState s and MonadState g at the same time because MonadState has a functional dependency on m -> s
2025-08-29 21:03:48 <tomsmeding> all approaches are messy in _some_ way
2025-08-29 21:04:01 <monochrom> I'm very prepared to write like either "lift get" or "lift (uniformRM (0,1) g)" actually. (I have low standards. :) )
2025-08-29 21:04:03 <tomsmeding> it's true that maybe the one I chose is not the least messy
2025-08-29 21:04:26 <tomsmeding> fair
2025-08-29 21:04:28 <tomsmeding> lightspell: exercise :)
2025-08-29 21:05:02 <monochrom> Well I'm bipolar. On prime numbered days I would be like "a real effect language already".
2025-08-29 21:05:05 <tomsmeding> type GameM = StateT Game (State StdGen)
2025-08-29 21:05:16 arandombit joins (~arandombi@2603:7000:4600:ffbe:ec4b:ec92:8e15:b25a)

All times are in UTC.