Newest at the top
2025-09-10 13:29:28 +0200 | <dminuoso> | RandomGen is for sequential pseudorandom number generators. |
2025-09-10 13:29:17 +0200 | Lord_of_Life | (~Lord@user/lord-of-life/x-2819915) (Ping timeout: 250 seconds) |
2025-09-10 13:28:59 +0200 | <dminuoso> | Well Im not entirely sure what you mean by converting RandomGen into MonadRandom. |
2025-09-10 13:28:41 +0200 | <kqr> | Yes, and I wished to convert one into the other, but I'm starting to sense that it might not be possible, and the solution would have be `shuffle' :: (RandomGen g, MonadSplit g m) => [a] -> m [a]` |
2025-09-10 13:27:24 +0200 | <dminuoso> | kqr: These are different interfaces. |
2025-09-10 13:26:12 +0200 | gmg | (~user@user/gehmehgeh) (Quit: Leaving) |
2025-09-10 13:25:45 +0200 | <kqr> | Well, I certainly am missing something dumb here. The function I import is `List.Shuffle.shuffle :: RandomGen g => [a] -> g -> ([a], g)`. How would I turn that into `shuffle' :: MonadRandom m => [a] -> m [a]`? |
2025-09-10 13:23:47 +0200 | <dminuoso> | So you can use `shuffle` in IO just the same as you would with RandT. |
2025-09-10 13:23:16 +0200 | <dminuoso> | kqr: Like I said, `MonadRandom IO` exists |
2025-09-10 13:19:56 +0200 | xff0x | (~xff0x@2405:6580:b080:900:c68c:683e:9c65:6f0a) |
2025-09-10 13:19:48 +0200 | <kqr> | Thus I'd like to create a `shuffle :: MonadRandom m => [a] -> m [a]` to be used both from within a RandT stack and directly from IO. However, with the given tools I can only create `shuffle :: RandomGen g => [a] -> Rand g [a]` which can only be used in IO by running it with evalRandIO which goes through StateT in the end. |
2025-09-10 13:18:45 +0200 | chromoblob | (~chromoblo@user/chromob1ot1c) (Ping timeout: 258 seconds) |
2025-09-10 13:17:08 +0200 | <kqr> | Backing up further, I want to compare the performance of using the RandT transformer layered on top of IO to drawing numbers in IO directly. |
2025-09-10 13:15:58 +0200 | <dminuoso> | What are you missing exactly? |
2025-09-10 13:15:42 +0200 | <dminuoso> | And for convenience in arbitrary transformer stacks you can use `randomIO :: (Random a, MonadIO m) => m a` |
2025-09-10 13:14:38 +0200 | segfaultfizzbuzz | (~segfaultf@23-93-74-222.fiber.dynamic.sonic.net) |
2025-09-10 13:14:27 +0200 | <dminuoso> | But for convenience you can also just use IO directly. |
2025-09-10 13:14:13 +0200 | <dminuoso> | kqr: `Rand` is basically a pure monad for you to get random effects with. RandT exists so you can layer it into other monads if you like. |
2025-09-10 13:13:27 +0200 | mari-estel | (~mari-este@user/mari-estel) (Remote host closed the connection) |
2025-09-10 13:13:16 +0200 | <dminuoso> | Similarly, `instance MonadRandom IO` is also a thing |
2025-09-10 13:12:52 +0200 | <dminuoso> | kqr: Lets untwine this: You can use `runRand` in IO just fine |
2025-09-10 13:12:09 +0200 | <dminuoso> | Hold on Im confusing things |
2025-09-10 13:12:03 +0200 | <kaol> | Though I think the AJAX call can be dropped if I take the offending JSString just by grabbing it from the DOM tree or something like that. |
2025-09-10 13:11:33 +0200 | <dminuoso> | kqr: A `MonadRandom IO` instance exists, what do you nneed? |
2025-09-10 13:09:45 +0200 | <kqr> | dminuoso, Yeah, but it lifts it into a RandT specifically, and I would like the option to use it in an IO context also. |
2025-09-10 13:09:03 +0200 | <kaol> | dminuoso: Unlikely, I don't think I can do it without running it on a browser. |
2025-09-10 13:08:53 +0200 | <dminuoso> | kqr: Hold on, liftRandT is a thing. |
2025-09-10 13:08:26 +0200 | <kqr> | Backing up a little, I want to use List.Shuffle.shuffle because it looks well written, but I don't want to tie it to RandT or the like. |
2025-09-10 13:06:34 +0200 | <kqr> | Uh, that would be `liftRandom :: (g -> (a, g)) -> MonadRandom a` or something, I suppose. Maybe that's the problem – we don't know what g is. But then why does not MonadSplit have that function? |
2025-09-10 13:05:23 +0200 | <kqr> | (I know the RandT transformer has that function, but I'd like the implementor to choose whether to draw random numbers from RandT or IO.) |
2025-09-10 13:04:52 +0200 | <kqr> | I must be missing something dumb here. Why does the MonadRandom typeclass not have a function `liftRandom :: g -> (a, g)`? Seems like something that'd be supported by anything that can do the other things MonadRandom does. |
2025-09-10 13:02:51 +0200 | fp | (~Thunderbi@wireless-86-50-141-202.open.aalto.fi) fp |
2025-09-10 13:01:03 +0200 | sttau | (~sttau@user/sttau) sttau |
2025-09-10 13:00:27 +0200 | fp | (~Thunderbi@wireless-86-50-141-202.open.aalto.fi) (Ping timeout: 256 seconds) |
2025-09-10 12:58:31 +0200 | segfaultfizzbuzz | (~segfaultf@23-93-74-222.fiber.dynamic.sonic.net) (Ping timeout: 250 seconds) |
2025-09-10 12:55:49 +0200 | fp | (~Thunderbi@wireless-86-50-141-202.open.aalto.fi) fp |
2025-09-10 12:54:21 +0200 | fp | (~Thunderbi@2001:708:150:10::72df) (Ping timeout: 252 seconds) |
2025-09-10 12:53:21 +0200 | Axman6 | (~Axman6@user/axman6) (Ping timeout: 250 seconds) |
2025-09-10 12:52:56 +0200 | merijn | (~merijn@77.242.116.146) merijn |
2025-09-10 12:51:25 +0200 | Axma39609 | (~Axman6@user/axman6) Axman6 |
2025-09-10 12:50:00 +0200 | inline | (~inline@ip-005-146-196-246.um05.pools.vodafone-ip.de) (Ping timeout: 258 seconds) |
2025-09-10 12:44:39 +0200 | lortabac | (~lortabac@2a01:e0a:541:b8f0:55ab:e185:7f81:54a4) |
2025-09-10 12:39:30 +0200 | merijn | (~merijn@77.242.116.146) (Ping timeout: 256 seconds) |
2025-09-10 12:38:06 +0200 | <dminuoso> | Maybe its your FromJSON instance that is borked? |
2025-09-10 12:37:54 +0200 | <dminuoso> | I'm fully convinced that any latin 1 decoding cannot happen on JSON with servant-client alone. |
2025-09-10 12:37:15 +0200 | <dminuoso> | kaol: Can you make a fully self contained minimal example program that I can just `cabal run`? |
2025-09-10 12:33:35 +0200 | merijn | (~merijn@77.242.116.146) merijn |
2025-09-10 12:21:09 +0200 | mari-estel | (~mari-este@user/mari-estel) mari-estel |
2025-09-10 12:20:11 +0200 | merijn | (~merijn@77.242.116.146) (Ping timeout: 248 seconds) |
2025-09-10 12:18:13 +0200 | xff0x | (~xff0x@fsb6a9491c.tkyc517.ap.nuro.jp) (Ping timeout: 250 seconds) |