Created
November 16, 2011 19:43
-
-
Save duane/1371111 to your computer and use it in GitHub Desktop.
Type error in small haskell program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Graphics.Sketch | |
import Data.Array.Repa | |
import Data.Word | |
import Control.Monad | |
import System.Random | |
randomWord8 :: IO Word8 | |
randomWord8 = getStdRandom random | |
randomListOfSize :: Int -> IO [Word8] | |
randomListOfSize 0 = return [] | |
randomListOfSize size = do | |
xs <- randomListOfSize $ size - 1 | |
x <- randomWord8 | |
return (x:xs) | |
randomRepaVectorOfSize :: (Shape sh) => Int -> IO (Array sh Word8) | |
randomRepaVectorOfSize size = liftM (fromList (Z :. size)) randomListOfSize size |
test.hs:21:48:
Could not deduce (sh ~ (Z :. Int))
from the context (Shape sh)
bound by the type signature for
randomRepaVectorOfSize :: Shape sh => Int -> IO (Array sh Word8)
at test.hs:21:1-89
`sh' is a rigid type variable bound by
the type signature for
randomRepaVectorOfSize :: Shape sh => Int -> IO (Array sh Word8)
at test.hs:21:1
In the first argument of `fromList', namely `(Z :. (size :: Int))'
In the first argument of `liftM', namely
`(fromList (Z :. (size :: Int)))'
In the expression:
liftM (fromList (Z :. (size :: Int))) (randomListOfSize size)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Error: