Haskell 小代码段导致ghc不终止

Haskell 小代码段导致ghc不终止,haskell,ghc,Haskell,Ghc,这会导致ghc在编译期间不终止: {-# LANGUAGE BangPatterns #-} {-# OPTIONS_GHC -O2 #-} import qualified Data.Vector.Unboxed.Mutable as MV import Data.Vector.Unboxed ((!)) import qualified Data.Vector.Unboxed as V import Control.Monad (forM_) similar :: V.Vector Ch

这会导致ghc在编译期间不终止:

{-# LANGUAGE BangPatterns #-}
{-# OPTIONS_GHC -O2 #-}

import qualified Data.Vector.Unboxed.Mutable as MV
import Data.Vector.Unboxed ((!))
import qualified Data.Vector.Unboxed as V
import Control.Monad (forM_)

similar :: V.Vector Char -> Int
similar v = l + sum (map (similar' 1 1) checks)
  where
    (l,checks) = let h = V.head v in V.foldl'  
        (\(i,is) c -> if c == h then (i+1,i:is) else (i+1,is)) (1,[]) (V.tail v)
    similar' !r !n !i = if i < l-1 && v!(n) == v!(i+1) then similar' (r+1) (n+1) (i+1)
        else r

main :: IO ()
main = do
    n <- getLine
    v <- MV.replicate (read n) 0
    forM_ [1..read n] $ \n' -> do
      v' <- getLine
      MV.unsafeWrite v (n'-1) (similar . V.fromList $ v')
    V.unsafeFreeze v >>= V.mapM_ print
{-#语言模式}
{-#选项(GHC-O2#-}
将限定数据.Vector.unbox.Mutable作为MV导入
导入Data.Vector.unbox((!)
导入符合条件的数据.Vector.unbox为V
导入控制.Monad(表单)
类似::V.Vector Char->Int
相似v=l+和(映射(相似'1 1)检查)
哪里
(l,检查)=设h=V.foldl'中的V.head V
(\(i,is)c->如果c==h,则(i+1,i:is)否则(i+1,is))(1,[])(V.tail V)
差不多!RNi=如果i

我试过ghc 7.4.1和7.6.1,但都没有终止。当我使用
ByteString
s而不是
Vector
s时,代码运行良好。这是ghc问题还是图书馆问题?还是我的代码中有问题?

这似乎是GHC问题

该汇编使用vector-0.10.0.1完成ghc-7.0.2,使用vector-0.7.0.1完成ghc-7.0.4,并使用vector-0.7.1完成ghc-7.2.1,vector-0.9完成ghc-7.2.2,vector-0.9完成ghc-7.4.1,vector-0.9.1完成ghc-7.4.2,vector-0.9.1完成ghc-7.6.1,vector-0.9.1和vector-0.10.0.1完成


编译挂在
SpecConstr
过程中,
vector
包大量使用该过程。我要开一家银行。如果编译器崩溃,那就是编译器的错误。