首页 \ 问答 \ 尽管stack ghci工作,但由于缺少包,堆栈构建失败(Stack build fails due to missing package although stack ghci works)

尽管stack ghci工作,但由于缺少包,堆栈构建失败(Stack build fails due to missing package although stack ghci works)

我正在尝试使用堆栈在Haskell中构建一个简单的程序。 我使用stack new创建了一个新项目,之后进行了stack setup 。 模板构建正常。

我想尝试二进制文件解析,所以我导入了Data.ByteString 。 我的build-depends于cabal文件,如下所示:

build-depends:     base >= 4.7 && < 5
                 , bytestring >= 0.10.6
                 , binary >= 0.7.5

stack ghci现在正常工作,但stack build仍然不高兴。 谁能告诉我这里做错了什么?

这是完整的错误消息:

test-0.1.0.0: build
Preprocessing library test-0.1.0.0...
In-place registering test-0.1.0.0...
Preprocessing executable 'test-exe' for test-0.1.0.0...

haskell/test/app/Main.hs:4:18:
    Could not find module ‘Data.ByteString’
    It is a member of the hidden package ‘bytestring-0.10.6.0@bytes_6VWy06pWzJq9evDvK2d4w6’.
    Perhaps you need to add ‘bytestring’ to the build-depends in your .cabal file.
    Use -v to see a list of the files searched for.

haskell/test/app/Main.hs:5:8:
    Could not find module ‘Data.Binary.Get’
    It is a member of the hidden package ‘binary-0.7.5.0@binar_3uXFWMoAGBg0xKP9MHKRwi’.
    Perhaps you need to add ‘binary’ to the build-depends in your .cabal file.
    Use -v to see a list of the files searched for.

--  While building package test-0.1.0.0 using:
      .stack/setup-exe-cache/x86_64-osx/setup-Simple-Cabal-1.22.5.0-ghc-7.10.3 --builddir=.stack-work/dist/x86_64-osx/Cabal-1.22.5.0 build lib:test exe:test-exe --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1

这是我的app / Main.hs文件:

module Main where

import Lib
import qualified Data.ByteString as B
import Data.Binary.Get
import Data.Word

main :: IO ()
main =  do
    putStrLn "f"

非常感谢您的帮助。


I am trying to build a simple program in Haskell using stack. I created a new project using stack new and did a stack setup after that. The template builds fine.

I want to experiment with binary file parsing, so I imported Data.ByteString. My build-depends in the cabal file look like this:

build-depends:     base >= 4.7 && < 5
                 , bytestring >= 0.10.6
                 , binary >= 0.7.5

stack ghci now just works, but stack build is still not happy. Can someone tell me what I did wrong here?

Here is the complete error message:

test-0.1.0.0: build
Preprocessing library test-0.1.0.0...
In-place registering test-0.1.0.0...
Preprocessing executable 'test-exe' for test-0.1.0.0...

haskell/test/app/Main.hs:4:18:
    Could not find module ‘Data.ByteString’
    It is a member of the hidden package ‘bytestring-0.10.6.0@bytes_6VWy06pWzJq9evDvK2d4w6’.
    Perhaps you need to add ‘bytestring’ to the build-depends in your .cabal file.
    Use -v to see a list of the files searched for.

haskell/test/app/Main.hs:5:8:
    Could not find module ‘Data.Binary.Get’
    It is a member of the hidden package ‘binary-0.7.5.0@binar_3uXFWMoAGBg0xKP9MHKRwi’.
    Perhaps you need to add ‘binary’ to the build-depends in your .cabal file.
    Use -v to see a list of the files searched for.

--  While building package test-0.1.0.0 using:
      .stack/setup-exe-cache/x86_64-osx/setup-Simple-Cabal-1.22.5.0-ghc-7.10.3 --builddir=.stack-work/dist/x86_64-osx/Cabal-1.22.5.0 build lib:test exe:test-exe --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1

and this is my app/Main.hs file:

module Main where

import Lib
import qualified Data.ByteString as B
import Data.Binary.Get
import Data.Word

main :: IO ()
main =  do
    putStrLn "f"

Thank you very much for your help.


原文:https://stackoverflow.com/questions/35621869
更新时间:2024-02-09 21:02

最满意答案

首先,需要更改模型以提及ForeignKey关系。 接下来,Django自动添加id字段并且是多余的。 最后,建议对模型使用单数名称。 我会用这种方式设计它们:

class Platform(models.Model):
    name = models.CharField(max_length=64)
    prefix = models.CharField(max_length=2)

    class Meta:
        managed = False
        db_table = 'lu_platform'

    def __unicode__(self):
        return self.name

class Source(models.Model):
    name = models.CharField(max_length=32)

    class Meta:
        managed = False
        db_table = 'lu_sourcetype'

    def __unicode__(self):
        return self.name

class Event(models.Model):
    host_id = models.IntegerField()
    platform = models.ForeignKey(Platform)
    sourcetype = models.ForeignKey(Source)
    event_datetime = models.DateTimeField(auto_now=True)
    data = models.CharField(max_length=2048)

    class Meta:
        managed = False
        db_table = 'event'

最后,查询看起来像这样:

Event.objects.filter(platform__id=8, event_datetime__range=["2013-11-23", "2013-12-28"],sourcetype_id=1).values(
      "event_datetime", "platform__name", "host_id", "data")

我在火车上,所以我无法验证上面的代码,但它应该工作。


Firstly, the models need to be changed to mention the ForeignKey relationships. Next, the id fields are automatically added by Django and are redundant. Finally, it is recommended to use singular names for models. I would design them in this way:

class Platform(models.Model):
    name = models.CharField(max_length=64)
    prefix = models.CharField(max_length=2)

    class Meta:
        managed = False
        db_table = 'lu_platform'

    def __unicode__(self):
        return self.name

class Source(models.Model):
    name = models.CharField(max_length=32)

    class Meta:
        managed = False
        db_table = 'lu_sourcetype'

    def __unicode__(self):
        return self.name

class Event(models.Model):
    host_id = models.IntegerField()
    platform = models.ForeignKey(Platform)
    sourcetype = models.ForeignKey(Source)
    event_datetime = models.DateTimeField(auto_now=True)
    data = models.CharField(max_length=2048)

    class Meta:
        managed = False
        db_table = 'event'

Finally, the query would look something like this:

Event.objects.filter(platform__id=8, event_datetime__range=["2013-11-23", "2013-12-28"],sourcetype_id=1).values(
      "event_datetime", "platform__name", "host_id", "data")

I am on a train so I cannot verify the above code but it should work.

相关问答

更多
  • 无区别left join 是left outer join的简写,left join默认是outer属性的。
  • 首先,需要更改模型以提及ForeignKey关系。 接下来,Django自动添加id字段并且是多余的。 最后,建议对模型使用单数名称。 我会用这种方式设计它们: class Platform(models.Model): name = models.CharField(max_length=64) prefix = models.CharField(max_length=2) class Meta: managed = False db_table ...
  • 我以为没有指定一种类型的连接,它被认为是一个LEFT JOIN。 不是这样吗? 不,默认加入是INNER JOIN。 这是SQL连接的可视化解释 。 内部联接 左连接 I thought that by not specifying a type of join it was assumed to be a LEFT JOIN. Is this not the case? No, the default join is an INNER JOIN. Here is a visual explanation ...
  • 查看你的模式和你的预期结果似乎你需要这个查询 select a.ID, a.omschrijvingID, b.omschrijving, sum(c.aantal), a.min from omschrijvingVoorraad as a inner join omschrijving as b on a.omschrijvingID = b.ID inner join voorraad as c on a.omschrijvingID = c.omschrijvingID group by a.ID, ...
  • 您不能使用IF进行条件连接。 因为IF不是SELECT语法的一部分,即使它(如CASE表达式)也不允许像这样使用。 您可以将逻辑移动到ON语句: LEFT JOIN ArtMaga G ON (G.idMagazzino = V.idMagazzino AND G.idArticolo = M.idArticolo) AND M.idArtVar IS NULL OR (G.idMagazzino = V.idMagazzino AND G.idArtic ...
  • 似乎你想要一个法语描述,如果它存在,否则回退到英语。 SELECT item.id, COALESCE( ( SELECT lang.data FROM language l WHERE l.item = i.id AND l.language = 'fr' ), ( SELECT lang.data FROM ...
  • 查询的问题在于,在考虑application_id之前,它会从每个IP地址中找到上次访问的数据。 然后,当您对application_id进行过滤时,您将只获得上次访问与该application_id相关的IP地址的结果。 为了纠正您的查询,您必须修改JOIN condtition以考虑application_id,如下所示: SELECT m1.* FROM `tumblr_tracker` m1 LEFT JOIN `tumblr_tracker` m2 ON (m1.ip_address = m2.i ...
  • 使用concat as%是一个char字面量。 LIKE concat('%',u.country,'%') USE concat as % is a char literal. LIKE concat('%',u.country,'%')
  • 首先,您根本不需要LEFT JOIN 。 其次,你的第一次尝试似乎完全有效,我认为它是最有效的(当表上有索引加入时)。 但我正在添加另一种方式(这似乎更简单,因为它只有1个连接)。 简单 (添加3个以上特征): SELECT p.* FROM products AS p INNER JOIN characteristics AS c ON ... WHERE c.id IN (1, 3, 6) GROUP BY p.id HAVING COUNT(*) = 3 --- or ...
  • 如果不使用raw() ,很难生成这种形式的LEFT OUTER JOIN ; 您还需要distinct()重复的行。 我会使用更清洁且可能更快的EXISTS : news = News.objects.extra(select={'is_liked': 'EXISTS (SELECT 1 FROM {tbl_2} ' 'WHERE {tbl_2}.news_id = {tbl}.id AND {tbl_2}.user_id = %s)'.format( tbl=News._m ...

相关文章

更多

最新问答

更多
  • 延迟socket.io响应,并“警告 - websocket连接无效”(Delayed socket.io response, and “warn - websocket connection invalid”)
  • IIS 7.5仅显示homecontroller(IIS 7.5 only shows homecontroller)
  • 我如何删除ListView中的项目?(How I can remove a item in my ListView?)
  • 武陟会计培训类的学校哪个好点?
  • Spring事务管理:无法解析bean'transactionManager'的引用(Spring transaction management: Cannot resolve reference to bean 'transactionManager')
  • 无法在后面访问链接:焦点,移开,div(Link can't be accessed behind :focus, moved out of the way, div)
  • 总和形式选择值 - 我做错了什么(sum form select values - what am I doing wrong)
  • DocBook5 ISO 690参考书目的文档[关闭](Documentation for DocBook5 ISO 690 bibliography [closed])
  • 为什么改变所有点的颜色而不是一个?(Why changed the color for all points instead of one?)
  • 如何从字符串中删除所有尾部破折号?(How can I remove all trailing dashes from a string?)
  • 有没有办法以这种方式调用这个JavaScript函数?(is there a way to call this javascript function in this way?)
  • 在更换字符串时替换组(Replacing a group while replacing a string)
  • 如何用Dreamweaver制作网页表格
  • git:如何能够再次切换分支(git: how to be able to switch branches again)
  • 应用程序在打印联系人姓名和号码时崩溃(app crashes in the middle of printing contact names and numbers)
  • 用CSS @media查询目标移动设备解决方案的最准确的方法是什么?(what is the most accurate way to query target mobile device resolutions with CSS @media?)
  • Java - 如何仅使元音加倍(Java - How to double only Vowels)
  • 调用root.destroy()后出现“tkinter.TclError:invalid command name”错误(“tkinter.TclError: invalid command name” error after calling root.destroy())
  • 使用键绑定在两个表单之间切换(Switching between two forms with Key Bindings)
  • 我把正确的导入但错误仍然发生在Hibernate 5中的org.hibernate.MappingException(I put the correct import but the error still happen org.hibernate.MappingException in Hibernate 5)
  • 从宁波江北洪塘到宁波南站人力市场乘坐什么车子要转什么车子,我去人力市场考电工上岗证
  • jQuery - 用所有元素的新值替换属性值(jQuery - replace attribute value with new value of all elements)
  • Lenovo Low Profile USB Keyboard 下载后找不到电脑上没有
  • 将反应元素渲染到隐藏区域以进行测量(Render a react element to a hidden area for measurement)
  • 有没有可能确定iOS widget何时隐藏?(Is it possible to determine when iOS widget hides?)
  • 量角器 - 描述没有定义(Protractor - describe is not defined)
  • Jackson序列化:XML和JSON的不同格式(Jackson Serialization: Different formats for XML and JSON)
  • 在Javascfipt中解析XML(Parsing XML in Javascfipt)
  • Firebird客户端安装(Firebird client installation)
  • 在未安装XML DB的情况下从Oracle发送电子邮件(Send email from Oracle without XML DB installed)