My question is how to work with monads. I have the following code:
import System.Random
import Data.Random.Normal
import Graphics.EasyPlot
import Data.List
import Data.Function
random' mean randomGen = zip x y
where
x = normals' (mean, 0.2) randomGen :: [Float]
y = normals' (mean, 0.2) randomGen :: [Float]
randomW1 randomGen = [[x,y] | (x,y) <- random' 1.0 randomGen]
main = do
randomGen <- getStdGen
let w1 = take 50 (randomW1 randomGen)
print w1
and it works great. However, I think that its limitation is to connect the output getStdGenoutside randomW1and thought that I could connect getStdGenmore directly with randomW1writing
w1 = take 50 (randomW1 =<< getStdGen)
I suppose I used texture structures for >>=either the =<<“pipe” and replaced using doand <-. When I do as I suggest, I find that he
Couldn't match type ‘IO’ with ‘[]’
Expected type: [StdGen]
Actual type: IO StdGen
Is there a way to use >>=a replacement doand <-in this code?
stian