parsec3被parsec阻止,我做了什么 [英] Parsec3 blocked by parsec, what ever I do

查看:356
本文介绍了parsec3被parsec阻止,我做了什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用一个看起来像这样的cabal文件(相关库部分):


depends:base> = 4.8&& amp ; < 4.9,filepath> = 1.4&& < 1.5,时间> = 1.5&& < 1.6,字节串> = 0.10&& < 0.11,unix> = 2.7& < 2.8,cryptohash> = 0.11&& < 0.12,过程> = 1.2&& < 1.3,变压器> = 0.4&& < 0.5,text> = 1.2&& < = 1.3,base16-bytestring> = 0.1.1&& < 1.1.2,utf8-string> = 1&& < 1.1,目录> = 1.2&& < 1.3,正则表达式> = 0.9&& < 1.0,regex-pcre> = 0.94&& < 0.95,正则表达式> = 0.93&& < 0.94,direct-sqlite> = 2.3&& < 2.4,text> = 1.2&& < 1.3,filemanip> = 0.3&& < 0.4, parsec3-numbers> = 0.1&& < 0.2,parsec3> = 1.0&& < 1.1


执行 cabal build :

  ... 
无法匹配预期的类型'ParsecT
Text()Data。 Functor.Identity.Identity Double'
与实际类型'parsec-3.1.9:Text.Parsec.Prim.ParsecT
s0 u0 m0 Double'
NB:'ParsecT'
在'parsec3-1.0.1.8'包中'Text.Parsec.Prim'中定义
'parsec-3.1.9:Text.Parsec.Prim.ParsecT'
在'Text.Parsec。 Prim'包'parsec-3.1.9'
在'do'块中:time < - floating

我要做的是在 parsec3-numbers floating2 解析器>包,但不知何故,我也得到了parsec-3.1.9的干扰。
如果我将失败的文件加载到ghci中并使用:set -hide-package parsec :set -hide,我会遇到同样的问题-package parsec-numbers set。



如何确保我只会得到parsec3解析器?我在文件中使用的导入是:

  import Text.Parsec.Text 
import Text.Parsec
导入Text.Parsec.Number
将限定的Data.List导入为DL
将限定的Data.Text.IO导入为TIO

导入Database.SQLite3
导入数据.Text

所以这应该起作用。我需要parsec3的Text解析功能,这就是为什么我进入这一点。



Fredrik



编辑:

好的,将这个问题简化为一个最小化的形式,突出了真正的问题。
使用此代码:

  import Text.Parsec.Text 
import Text.Parsec
import Text.Parsec.Number

num :: Bool - >解析器Double
num = floating2

以及评估它的过程不依赖于使用特定的构建工具

 > cd〜#移出任何cabal包
> ghci -hide-package parsec#现在Parsec不应该被拉入
GHCi版本7.10.3:http://www.haskell.org/ghc/:?寻求帮助
Prelude> :l test.hs
[1的1]编译主(test.hs,解释)

test.hs:6:7:
无法匹配类型'parsec -3.1.9:Text.Parsec.Prim.ParsecT
s0 u0 m0 Double'
with'ParsecT
Data.Text.Internal.Text()Data.Functor.Identity.Identity Double'
NB:'parsec-3.1.9:Text.Parsec.Prim.ParsecT'
在'parsec-3.1.9'包'Text.Parsec.Prim'中定义
'ParsecT '
在'parsec3-1.0.1.8'包中'Text.Parsec.Prim'中定义
预期类型:Parser a - >解析器Double
实际类型:Bool
- > parsec-3.1.9:Text.Parsec.Prim.ParsecT s0 u0 m0 Double
在表达式中:floating2
在'num'等式中:num = floating2
Failed,loaded loaded:没有。

正如您所见, parsec-3.1.9 仍然被拉入,并且'阻塞' parsec3 定义。



只是提供一个干净的案例在这里, parsec-numbers 是一个包,那是不是在这种情况下创建问题:

 > ghci -hide-package parsec-numbers 
GHCi,版本7.10.3:http://www.haskell.org/ghc/:? for help
<命令行> ;:无法满足-hide-package parsec-numbers
(使用-v获取更多信息)


解决方案在<.c $ c> parsec3-numbers 的.cabal文件中有:

  flag parsec3 
描述:使用parsec3
默认值:False

Library $ b $
Text.Parsec.Number
if flag(parsec3)
build-depends:parsec3
else
build-depends:parsec

所以我打赌你想要用 parsec3-numbers -f parsec3 选项。


using a cabal file looking like this (the relevant library part):

build-depends: base >=4.8 && < 4.9, filepath >=1.4 && <1.5, time >=1.5 && <1.6, bytestring >=0.10 && <0.11, unix >=2.7 && <2.8, cryptohash >=0.11 && <0.12, process >=1.2 && <1.3, transformers >= 0.4 && < 0.5, text >= 1.2 && <= 1.3, base16-bytestring >= 0.1.1 && < 1.1.2, utf8-string >= 1 && < 1.1, directory >=1.2 && <1.3, regex-base >= 0.9 && < 1.0, regex-pcre >= 0.94 && < 0.95, regex-base >= 0.93 && < 0.94, direct-sqlite >=2.3 && <2.4, text >=1.2 && <1.3, filemanip >=0.3 && < 0.4, parsec3-numbers >=0.1 && < 0.2, parsec3 >=1.0 && <1.1

I get this when doing a cabal build :

...
Couldn't match expected type ‘ParsecT
                                Text () Data.Functor.Identity.Identity Double’
            with actual type ‘parsec-3.1.9:Text.Parsec.Prim.ParsecT
                                s0 u0 m0 Double’
NB: ‘ParsecT’
      is defined in ‘Text.Parsec.Prim’ in package ‘parsec3-1.0.1.8’
    ‘parsec-3.1.9:Text.Parsec.Prim.ParsecT’
      is defined in ‘Text.Parsec.Prim’ in package ‘parsec-3.1.9’
In a stmt of a 'do' block: time <- floating

What I am trying to do is use the floating2 parser in the parsec3-numbers package, but somehow I get also the interference of parsec-3.1.9. I get the same problem if I load the failing file into ghci and with :set -hide-package parsec or :set -hide-package parsec-numbers set.

How do I make sure that I will only get parsec3 parsers? The imports I am using in the file are:

import Text.Parsec.Text
import Text.Parsec
import Text.Parsec.Number
import qualified Data.List as DL
import qualified Data.Text.IO as TIO

import Database.SQLite3
import Data.Text

so this should work. I need the Text parsing capabilities of parsec3, that is why I went into this.

Fredrik

EDIT:

Ok, reducing this problem to a minimal form that highlights the real issue. Using this code:

import Text.Parsec.Text
import Text.Parsec
import Text.Parsec.Number

num:: Bool -> Parser Double
num = floating2

and a procedure for evaluating it that does not depend on the specific build tool used

> cd ~ # Move outside of any cabal package
> ghci -hide-package parsec # Parsec should now not be pulled in
GHCi, version 7.10.3: http://www.haskell.org/ghc/  :? for help
Prelude> :l test.hs
[1 of 1] Compiling Main             ( test.hs, interpreted )

test.hs:6:7:
    Couldn't match type ‘parsec-3.1.9:Text.Parsec.Prim.ParsecT
                           s0 u0 m0 Double’
                   with ‘ParsecT
                           Data.Text.Internal.Text () Data.Functor.Identity.Identity Double’
    NB: ‘parsec-3.1.9:Text.Parsec.Prim.ParsecT’
          is defined in ‘Text.Parsec.Prim’ in package ‘parsec-3.1.9’
        ‘ParsecT’
          is defined in ‘Text.Parsec.Prim’ in package ‘parsec3-1.0.1.8’
    Expected type: Parser a -> Parser Double
      Actual type: Bool
                   -> parsec-3.1.9:Text.Parsec.Prim.ParsecT s0 u0 m0 Double
    In the expression: floating2
    In an equation for ‘num’: num = floating2
Failed, modules loaded: none.

As you can see, parsec-3.1.9 is still pulled in, and is 'blocking' the parsec3 definitions.

Just to provide a clean case here, parsec-numbers is a package out there, and that is not creating the problem in this case:

>  ghci -hide-package parsec-numbers
GHCi, version 7.10.3: http://www.haskell.org/ghc/  :? for help
<command line>: cannot satisfy -hide-package parsec-numbers
    (use -v for more information)

解决方案

In the .cabal file for parsec3-numbers there is:

flag parsec3
    Description: Use parsec3
    Default: False

Library
  exposed-modules:
    Text.Parsec.Number
  if flag(parsec3)
      build-depends: parsec3
  else
      build-depends: parsec

So I bet you want to build parsec3-numbers with the -f parsec3 option.

这篇关于parsec3被parsec阻止,我做了什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆