Newest at the top
2024-11-14 19:09:50 +0100 | alexherbo2 | (~alexherbo@2a02-8440-3313-668b-a9ec-921f-0511-ee3f.rev.sfr.net) (Remote host closed the connection) |
2024-11-14 19:09:33 +0100 | tromp | (~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl) |
2024-11-14 19:09:05 +0100 | peterbecich | (~Thunderbi@syn-047-229-123-186.res.spectrum.com) peterbecich |
2024-11-14 19:06:26 +0100 | ljdarj | (~Thunderbi@user/ljdarj) ljdarj |
2024-11-14 19:02:49 +0100 | visilii_ | (~visilii@213.24.127.47) (Ping timeout: 260 seconds) |
2024-11-14 19:02:26 +0100 | visilii | (~visilii@213.24.126.184) |
2024-11-14 19:01:51 +0100 | <tomsmeding> | yes |
2024-11-14 19:01:43 +0100 | <bailsman> | I see. And then I just use them. And GHC understands that they were mutable the whole time and so it doesn't do anything unsafe. |
2024-11-14 19:01:38 +0100 | housemate | (~housemate@146.70.66.228) (Remote host closed the connection) |
2024-11-14 19:01:33 +0100 | housemate | (~housemate@146.70.66.228) housemate |
2024-11-14 19:01:04 +0100 | housemate | (~housemate@146.70.66.228) (Remote host closed the connection) |
2024-11-14 19:00:42 +0100 | JuanDaugherty | (~juan@user/JuanDaugherty) JuanDaugherty |
2024-11-14 19:00:27 +0100 | <tomsmeding> | yes |
2024-11-14 19:00:23 +0100 | <bailsman> | so I need to noinline unsafePerformIO the iovectors |
2024-11-14 19:00:08 +0100 | <tomsmeding> | they're already references |
2024-11-14 19:00:00 +0100 | <tomsmeding> | just read the IOVectors |
2024-11-14 18:59:56 +0100 | <tomsmeding> | don't writeIORef that record |
2024-11-14 18:59:47 +0100 | <bailsman> | and that means I can put them in a record and then I can writeIORef that record ? And everything works? |
2024-11-14 18:59:22 +0100 | <tomsmeding> | perhaps Data.Vector.Unboxed.Mutable |
2024-11-14 18:59:13 +0100 | <tomsmeding> | vector:Data.Vector.Mutable (IOVector) |
2024-11-14 18:59:02 +0100 | bailsman | googles iovectors |
2024-11-14 18:58:54 +0100 | <tomsmeding> | make them IOVectors? |
2024-11-14 18:58:44 +0100 | <bailsman> | yep I did that. So my global variable is a record with a bunch of vectors in it. I haven't figured out yet how to make those mutable. |
2024-11-14 18:58:24 +0100 | <tomsmeding> | bailsman: make sure to put {-# NOINLINE #-} on that global variable |
2024-11-14 18:57:45 +0100 | <tomsmeding> | never need to thaw/freeze it |
2024-11-14 18:57:36 +0100 | <tomsmeding> | just make that an IOVector, not an STVector :p |
2024-11-14 18:57:26 +0100 | <tomsmeding> | that sounds like a decent plan |
2024-11-14 18:57:17 +0100 | <bailsman> | They totally can. I'm being called from javascript, that JSFFI function is in IO, currently I'm faking a global variable by doing unsafePerformIO (newIOREf ...) then reading/writing to the IORef |
2024-11-14 18:56:41 +0100 | <tomsmeding> | then you can just put the IOVector wherever |
2024-11-14 18:56:35 +0100 | <tomsmeding> | I don't recall the JS FFI well, but can't exported haskell functions run in IO? |
2024-11-14 18:56:17 +0100 | <tomsmeding> | make it an IOVector instead of an STVector? |
2024-11-14 18:56:05 +0100 | <tomsmeding> | okay that changes the picture |
2024-11-14 18:56:01 +0100 | <tomsmeding> | O.o |
2024-11-14 18:55:51 +0100 | <bailsman> | I need to store it somewhere between invocations from javascript :P |
2024-11-14 18:55:45 +0100 | <tomsmeding> | (think: there's already an "IORef" (ish) inside the MVector type) |
2024-11-14 18:55:27 +0100 | <tomsmeding> | no code needs to _return_ an MVector, just create one, then pass it _to_ everything |
2024-11-14 18:55:09 +0100 | <bailsman> | this part isn't safe. This is the fast part. The rest of my code I want to write idiomatically/pure. |
2024-11-14 18:55:06 +0100 | <tomsmeding> | a mutable array is a _reference_, you only need a read-only reference to the MVector to be able to modify the underlying storage |
2024-11-14 18:54:39 +0100 | <tomsmeding> | that's the whole point of the interface, and what makes it safe |
2024-11-14 18:54:32 +0100 | <tomsmeding> | the point is that a mutable array _must_ live inside the monad :p |
2024-11-14 18:54:30 +0100 | housemate | (~housemate@146.70.66.228) housemate |
2024-11-14 18:54:18 +0100 | housemate | (~housemate@146.70.66.228) (Read error: Connection reset by peer) |
2024-11-14 18:54:17 +0100 | <tomsmeding> | that would save the introduced copy |
2024-11-14 18:54:16 +0100 | <bailsman> | The 'challenge' I have is I'm not sure how to store a mutable array outside the monad. Currently I'm freezing it, then doing writeIORef, then when it runs again I do readIORef followed by thaw. |
2024-11-14 18:54:10 +0100 | <tomsmeding> | perhaps you can ensure that you don't create the initial vector as immutable, but instead as mutable, so that you never have to thaw it |
2024-11-14 18:53:20 +0100 | <tomsmeding> | then change the unsafeThaw to thaw, because with the unsafeThaw + unsafeFreeze you're still in unsafe world |
2024-11-14 18:53:01 +0100 | <tomsmeding> | bailsman: try putting the whole mutable part in ST, so that you only have one unsafeThaw and one unsafeFreeze; presumably that should still be fast |
2024-11-14 18:52:12 +0100 | <tomsmeding> | I would still not do this |
2024-11-14 18:51:51 +0100 | <tomsmeding> | yes IO sequences, so that's fine |
2024-11-14 18:51:50 +0100 | <geekosaur> | evaluate has to be in IO |