LoginSignup
4

More than 5 years have passed since last update.

randomの動かし方

Last updated at Posted at 2015-01-11

すごいH本を写経していて9.6ランダム性の部分がGHC7.8.3では動かなかった

Prelude> random (mkStdGen 100) :: (Int, StdGen)

<interactive>:6:1: Not in scope: ‘random’

<interactive>:6:9: Not in scope: ‘mkStdGen’

<interactive>:6:32:
    Not in scope: type constructor or class ‘StdGen’

importしてみてもダメだった

Prelude> import System.Random

<no location info>:
    Could not find module ‘System.Random’
    It is not a module in the current program, or in any known package.
Prelude> import System.Random

<no location info>:
    Could not find module ‘System.Random’
    It is not a module in the current program, or in any known package.

どうやらrandomというパッケージを入れれば良いみたい

$ brew install cabal-install
$ cabal update
$ cabal install random

無事動いた

relude> import System.Random                                                                               
Prelude System.Random> random (mkStdGen 100) :: (Int, StdGen)                                               
Loading package array-0.5.0.0 ... linking ... done.                                                         
Loading package deepseq-1.3.0.2 ... linking ... done.                                                       
Loading package old-locale-1.0.0.6 ... linking ... done.                                                    
Loading package time-1.4.2 ... linking ... done.                                                            
Loading package random-1.1 ... linking ... done.                                                            
(-3633736515773289454,693699796 2103410263)

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4