[GHC] #3212: getOptions'.parseLanguage(2) went past eof token

GHC trac at galois.com
Fri May 8 23:29:46 EDT 2009


#3212: getOptions'.parseLanguage(2) went past eof token
-----------------------------------------------------------+----------------
Reporter:  Jig                                             |          Owner:                  
    Type:  bug                                             |         Status:  new             
Priority:  normal                                          |      Component:  Compiler        
 Version:  6.10.2                                          |       Severity:  minor           
Keywords:  getOptions'.parseLanguage(2) XFlexibleContexts  |       Testcase:                  
      Os:  Windows                                         |   Architecture:  Unknown/Multiple
-----------------------------------------------------------+----------------
 {-# LANGUAGE -XFlexibleContexts #-}
 module Pngloadtest where
 import Control.Monad
 import Control.Arrow
 import Codec.Image.PNG
 import Data.Array.MArray
 import Data.Array.Storable
 import GHC.Word
 --import Data.Array.MArray
 import qualified Data.Matrix.DenseMatrix as DM

 openImage :: IO PNGImage
 openImage = do
   a <- loadPNGFile "C:/users/saftarn/desktop/datasets/pics/face2.png"
   case a of Left err  -> error err
             Right img -> return img

 dims :: PNGImage -> (Int, Int)
 dims img = join (***) fromIntegral $ dimensions img

 size :: PNGImage -> Int
 size img = uncurry (*) $ dims img


 --imgToList :: (MArray StorableArray Word8 m, Num b) => PNGImage -> m [b]
 imgToList img = do
   es <- getElems $ imageData img
   return $ map fromIntegral es

 imgToMatrix :: (MArray StorableArray Word8 m) => PNGImage ->
                m DM.DenseMatrix
 imgToMatrix im = do
   let (w,_) = dims im
   xs <- imgToList im
   return $ DM.fromFlatList w xs

 main = do
   im <- openImage
   a <- imgToList im
   print $ dims im
   print $ size im
   --print a





 *Pngloadtest> :load "ComputerVision/Pngloadtest.hs"
 [1 of 2] Compiling Data.Matrix.DenseMatrix ( Data\Matrix\DenseMatrix.hs,
 interpreted )
 [2 of 2] Compiling Pngloadtest      ( ComputerVision\Pngloadtest.hs,
 interpreted )

 ComputerVision\Pngloadtest.hs:29:0:
     Non type-variable argument
       in the constraint: MArray StorableArray Word8 m
     (Use -XFlexibleContexts to permit this)
     In the type signature for `imgToMatrix':
       imgToMatrix :: (MArray StorableArray Word8 m) =>
                      PNGImage -> m DM.DenseMatrix
 Failed, modules loaded: Data.Matrix.DenseMatrix.
 *Data.Matrix.DenseMatrix> :load "ComputerVision/Pngloadtest.hs"
 : panic! (the 'impossible' happened)
   (GHC version 6.10.2 for i386-unknown-mingw32):
         getOptions'.parseLanguage(2) went past eof token

 Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

 >










 Works if using:
 {-# LANGUAGE FlexibleContexts #-}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3212>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the Glasgow-haskell-bugs mailing list