Parsec3 blocked by parsec, what ever I do

烂漫一生 提交于 2020-01-06 03:16:26

问题


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)

回答1:


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.




回答2:


FWIW, I was able to satisfy all of your constraints with stack resolvers lts-5.13 and lts-6.0.

I think there is something screwed up with your package db. I would try using a cabal sandbox and/or use stack.

If you use stack, just add these to your extra-deps: section in the stack.yaml file:

extra-deps:
- parsec3-numbers-0.1.0
- parsec3-1.0.1.8


来源:https://stackoverflow.com/questions/37576910/parsec3-blocked-by-parsec-what-ever-i-do

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!