如何最好地解决 Haskell 8.03 GHCI getLabelBc:运行 标签不足?
How to best workaround Haskell 8.03 GHCI getLabelBc: Ran out of labels?
此错误的原因是什么?我该如何解决?作为解决方法,我已经减小了静态数据的大小,但是有什么方法可以在 haskell 中创建静态数据,而不会 运行 出现此错误?基本上我想创建大量的对象列表,这些对象是在文件中编译的,而不是从文件中加载的。
此处报告https://ghc.haskell.org/trac/ghc/ticket/14334
在这里编译这个项目文件,它基本上是一个从 rdf4h 库发出的大数据对象。我想将数据放入静态 space 以缩短加载时间并删除 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
一个快速而肮脏的解决方案
我的评论的意思如下:
使用您拥有的一组已解析数据结构并稍微简化它们(例如使用正则表达式)
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"
然后为您的测试数据编写一个小型解析器(我知道这不完整,您可能需要调整此代码片段)
{-# 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.
根据开发团队的说法(参见错误报告https://ghc.haskell.org/trac/ghc/ticket/14334#comment:8)问题是由于模块级别的 16 位标签地址引起的,解决方法是将代码拆分为多个模块。
此错误的原因是什么?我该如何解决?作为解决方法,我已经减小了静态数据的大小,但是有什么方法可以在 haskell 中创建静态数据,而不会 运行 出现此错误?基本上我想创建大量的对象列表,这些对象是在文件中编译的,而不是从文件中加载的。
此处报告https://ghc.haskell.org/trac/ghc/ticket/14334
在这里编译这个项目文件,它基本上是一个从 rdf4h 库发出的大数据对象。我想将数据放入静态 space 以缩短加载时间并删除 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
一个快速而肮脏的解决方案
我的评论的意思如下:
使用您拥有的一组已解析数据结构并稍微简化它们(例如使用正则表达式)
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"
然后为您的测试数据编写一个小型解析器(我知道这不完整,您可能需要调整此代码片段)
{-# 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.
根据开发团队的说法(参见错误报告https://ghc.haskell.org/trac/ghc/ticket/14334#comment:8)问题是由于模块级别的 16 位标签地址引起的,解决方法是将代码拆分为多个模块。