| Saizan | providing a seed |
| ivanm | *nod* which would require a do-block, right? |
| mauke | nothing requires a do block |
| ivanm | if I want a random seed do block / explicit monadic passing |
| Saizan | yoou can have randomPermIO :: [a] -> IO [a]; randomPermIO list = do g <- newStdGen; return $ randomPerm g list |
| ivanm | yeah but then I'd need yet another function that would un monadise it |
| Saizan | you can't unmonadise IO |
| ivanm | oh..... but I need to... |
| Saizan | IO is a one way monad |
| dcoutts | cdsmith: ByteString.readFile is strict, so it reads the whole file and closes it. |
| ivanm | Saizan: but I need to perform more operations on the result :s |
| cdsmith | dcoutts: Hmm... that's not what I'm seeing. (I'm actually using Data.Binary's decodeFile, but it says it uses ByteString) |
| dcoutts | cdsmith: ah, that's using a lazy BytString |
| Saizan | ivanm, just write your code needing a random seed, you'll eventually get one from your main function that must be in IO |
| dcoutts | cdsmith: there's Data.ByteString and Data.ByteString.Lazy |
| ivanm | Saizan: I have a data structure that I need to shuffle in three different ways... |
| cdsmith | dcoutts: Okay. So I should use Data.ByteString explicitly? |
| ivanm | or are you saying to get main to pass through the random seed? |
| dcoutts | cdsmith: so with a lazy bytestring, it's lazy in the same way that ordinary readFile is lazy, it closes the file when it's read the whole input |
| Saizan | ivanm: exactly, remember that you can get two seeds from one by splitting |
| dcoutts | cdsmith: so the ideal way is to read all the stuff you're decoding with Data.Binary, then it'll have read the whole file. |
| ivanm | splitting? |
| cdsmith | dcoutts: I thought I was doing that. |
| Saizan | ?type split |
| lambdabot | forall g. (RandomGen g) => g -> (g, g) |
| ivanm | > split (mkStdGen 42) |
| lambdabot | (44 40692,1720602 2147483398) |
| ivanm | mkStdGen 42 > mkStdGen 42 |
| lambdabot | 43 1 |
| ivanm | ok, how did it do that? :s @src split |
| lambdabot | Source not found. My mind is going. I can feel it. |
| cdsmith | @paste |
| lambdabot | Haskell pastebin: http://hpaste.org/new |
| ivanm | heh |