如何最好的解决方法Haskell 8.03 GHCI getLabelBc:跑出标签?

时间:2017-10-08 14:22:02

标签: haskell ghci

导致此错误的原因是什么?如何绕过它?我已经减少了静态数据的大小作为一种解决方法但是有没有办法在haskell中创建不会遇到此错误的静态数据?基本上我想创建大量的对象列表,这些对象是在文件中编译而不是从文件加载的。

此处报告https://ghc.haskell.org/trac/ghc/ticket/14334

这里编译这个项目文件,基本上是从rdf4h lib发出的大型数据对象。我想将数据放入静态空间以改善加载时间并删除IO。

https://github.com/h4ck3rm1k3/gcc-haskell/blob/master/src/LibData.hs

stack ghci

gcc-haskell Using main module: 1. Package `gcc-haskell' component exe:gcc-haskell-exe with main-is file: /home/mdupont/experiments/g\ cc-haskell/gcc-haskell/app/Main.hs GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help [1 of 3] Compiling LibData ( LibData.hs, interpreted ) ghc: panic! (the 'impossible' happened)

(GHC version 8.0.2 for x86_64-unknown-linux):

getLabelBc: Ran out of labels

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

2 个答案:

答案 0 :(得分:1)

快速而肮脏的解决方案

我对评论的意思如下:

使用您拥有的解析数据结构集并稍微简化它们(例如使用正则表达式)

Triple "https://h4ck3rm1k3.github.io/gogccintro/gcc/ontology/2017/05/20/gcc_compiler.owl#4707" "https://h4ck3rm1k3.github.io/gogccintro/gcc/ontology/2017/05/20/gcc_compiler.owl#op_0" "https://h4ck3rm1k3.github.io/gogccintro/gcc/ontology/2017/05/20/gcc_compiler.owl#4777"
Triple "https://h4ck3rm1k3.github.io/gogccintro/gcc/ontology/2017/05/20/gcc_compiler.owl#4707" "https://h4ck3rm1k3.github.io/gogccintro/gcc/ontology/2017/05/20/gcc_compiler.owl#type" "https://h4ck3rm1k3.github.io/gogccintro/gcc/ontology/2017/05/20/gcc_compiler.owl#4776"
Triple "https://h4ck3rm1k3.github.io/gogccintro/gcc/ontology/2017/05/20/gcc_compiler.owl#4707" "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" "https://h4ck3rm1k3.github.io/gogccintro/gcc/ontology/2017/05/20/gcc_compiler.owl#addr_expr"
Triple "https://h4ck3rm1k3.github.io/gogccintro/gcc/ontology/2017/05/20/gcc_compiler.owl#4707" "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" "http://www.w3.org/2002/07/owl#NamedIndividual"
Triple "https://h4ck3rm1k3.github.io/gogccintro/gcc/ontology/2017/05/20/gcc_compiler.owl#4706" "https://h4ck3rm1k3.github.io/gogccintro/gcc/ontology/2017/05/20/gcc_compiler.owl#op_0" "https://h4ck3rm1k3.github.io/gogccintro/gcc/ontology/2017/05/20/gcc_compiler.owl#5578"
Triple "https://h4ck3rm1k3.github.io/gogccintro/gcc/ontology/2017/05/20/gcc_compiler.owl#4706" "https://h4ck3rm1k3.github.io/gogccintro/gcc/ontology/2017/05/20/gcc_compiler.owl#type" "https://h4ck3rm1k3.github.io/gogccintro/gcc/ontology/2017/05/20/gcc_compiler.owl#40"
Triple "https://h4ck3rm1k3.github.io/gogccintro/gcc/ontology/2017/05/20/gcc_compiler.owl#4706" "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" "https://h4ck3rm1k3.github.io/gogccintro/gcc/ontology/2017/05/20/gcc_compiler.owl#nop_expr"
Triple "https://h4ck3rm1k3.github.io/gogccintro/gcc/ontology/2017/05/20/gcc_compiler.owl#4706" "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" "http://www.w3.org/2002/07/owl#NamedIndividual"
Triple "https://h4ck3rm1k3.github.io/gogccintro/gcc/ontology/2017/05/20/gcc_compiler.owl#4705" "https://h4ck3rm1k3.github.io/gogccintro/gcc/ontology/2017/05/20/gcc_compiler.owl#int" LNode plainl2 "619"
Triple "https://h4ck3rm1k3.github.io/gogccintro/gcc/ontology/2017/05/20/gcc_compiler.owl#4705" "https://h4ck3rm1k3.github.io/gogccintro/gcc/ontology/2017/05/20/gcc_compiler.owl#type" "https://h4ck3rm1k3.github.io/gogccintro/gcc/ontology/2017/05/20/gcc_compiler.owl#93"
Triple "https://h4ck3rm1k3.github.io/gogccintro/gcc/ontology/2017/05/20/gcc_compiler.owl#4705" "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" "https://h4ck3rm1k3.github.io/gogccintro/gcc/ontology/2017/05/20/gcc_compiler.owl#integer_cst"
Triple "https://h4ck3rm1k3.github.io/gogccintro/gcc/ontology/2017/05/20/gcc_compiler.owl#4705" "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" "http://www.w3.org/2002/07/owl#NamedIndividual"
Triple "https://h4ck3rm1k3.github.io/gogccintro/gcc/ontology/2017/05/20/gcc_compiler.owl#4704" "https://h4ck3rm1k3.github.io/gogccintro/gcc/ontology/2017/05/20/gcc_compiler.owl#op_0" "https://h4ck3rm1k3.github.io/gogccintro/gcc/ontology/2017/05/20/gcc_compiler.owl#5577"

然后为你的testdata写一个小解析器(我知道这个不完整,你可能需要调整这个代码片段)

{-# LANGUAGE OverloadedStrings #-}
module Main  where

import Control.Monad (void)
import qualified Data.Text as T
import Data.Text (Text)
import Data.Attoparsec.Text as AT
import qualified Data.Text.IO as TIO

data Triple = Triple Text Text Text

triple :: Parser Triple
triple = do void $ string "Triple"
            skipSpace
            let entry = char '"' *> AT.takeWhile (/= '"') <* char '"'
            a <- entry
            skipSpace
            b <- entry
            skipSpace
            c <- entry
            return $ Triple a b c


main :: IO ()
main = do triples <- map (parseOnly triple) . T.lines <$> TIO.readFile "Libdata.hs"
          print $ length [x | Right x <- triples]

这个脚本与stack runhaskell Main.hs一起运行的时间超过一秒 - 足够快,可以在每次保存时使用自动化测试。

彻底的解决方案

在阅读您的评论时 - 我认为这有点像XY问题 - 您希望将数据放入应用程序中(我猜测是出于测试目的)因为rdf4h太慢了。瞥一眼图书馆 - 它使用parsec - 而attoparsec会更快。说这话我发现你已经在github上提出了一个问题。

你还可以做的是克隆git-repo - 添加一个自动读取实例和read你已成功解析的数据结构和show n。

答案 1 :(得分:0)

根据开发团队的说法(请参阅错误报告https://ghc.haskell.org/trac/ghc/ticket/14334#comment:8),问题是由于模块级别的16位标签地址,解决方法是将代码拆分为多个模块。