我试图将流融合库引入我的项目。我正在使用Stack(LTS 5.16)。我将stream-fusion-0.1.2.5版本添加到我的项目cabal文件中,并在stack.yaml中作为额外依赖项添加。
然而,当我尝试构建项目时,我现在得到以下内容:
stream-fusion-0.1.2.5: configure
stream-fusion-0.1.2.5: build
-- While building package stream-fusion-0.1.2.5 using:
/Users/me/.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 --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
Logs have been written to: /Users/me/Haskell/hqfl/.stack-work/logs/stream-fusion-0.1.2.5.log
Configuring stream-fusion-0.1.2.5...
Building stream-fusion-0.1.2.5...
Preprocessing library stream-fusion-0.1.2.5...
[1 of 3] Compiling Data.Stream ( Data/Stream.hs, .stack-work/dist/x86_64-osx/Cabal-1.22.5.0/build/Data/Stream.o )
/private/var/folders/q_/qbq9bct96jj8p_c9kqbhmt840000gn/T/stack6002/stream-fusion-0.1.2.5/Data/Stream.hs:591:5: Warning:
Pattern match(es) are non-exhaustive
In an equation for ‘next’:
Patterns not matched: (_ :!: (Just (L _))) :!: S2
[2 of 3] Compiling Data.List.Stream ( Data/List/Stream.hs, .stack-work/dist/x86_64-osx/Cabal-1.22.5.0/build/Data/List/Stream.o )
/private/var/folders/q_/qbq9bct96jj8p_c9kqbhmt840000gn/T/stack6002/stream-fusion-0.1.2.5/Data/List/Stream.hs:235:1: Warning:
The import of ‘seq, Int’ from module ‘Prelude’ is redundant
/private/var/folders/q_/qbq9bct96jj8p_c9kqbhmt840000gn/T/stack6002/stream-fusion-0.1.2.5/Data/List/Stream.hs:1703:10: Warning: Tab character
/private/var/folders/q_/qbq9bct96jj8p_c9kqbhmt840000gn/T/stack6002/stream-fusion-0.1.2.5/Data/List/Stream.hs:2496:1: Warning:
Rule "genericSplitAt -> fusible" may never fire
because ‘genericSplitAt’ might inline first
Probable fix: add an INLINE[n] or NOINLINE[n] pragma on ‘genericSplitAt’
/private/var/folders/q_/qbq9bct96jj8p_c9kqbhmt840000gn/T/stack6002/stream-fusion-0.1.2.5/Data/List/Stream.hs:2504:1: Warning:
Rule "genericSplitAt -> splitAt/Int" may never fire
because ‘genericSplitAt’ might inline first
Probable fix: add an INLINE[n] or NOINLINE[n] pragma on ‘genericSplitAt’
/private/var/folders/q_/qbq9bct96jj8p_c9kqbhmt840000gn/T/stack6002/stream-fusion-0.1.2.5/Data/List/Stream.hs:2516:1: Warning:
Rule "genericReplicate -> replicate/Int" may never fire
because ‘genericReplicate’ might inline first
Probable fix: add an INLINE[n] or NOINLINE[n] pragma on ‘genericReplicate’
[3 of 3] Compiling Control.Monad.Stream ( Control/Monad/Stream.hs, .stack-work/dist/x86_64-osx/Cabal-1.22.5.0/build/Control/Monad/Stream.o )
/private/var/folders/q_/qbq9bct96jj8p_c9kqbhmt840000gn/T/stack6002/stream-fusion-0.1.2.5/Control/Monad/Stream.hs:136:10:
Ambiguous occurrence ‘MonadPlus’
It could refer to either ‘Control.Monad.Stream.MonadPlus’,
defined at Control/Monad/Stream.hs:124:1
or ‘GHC.Base.MonadPlus’,
imported from ‘GHC.Base’ at Control/Monad/Stream.hs:80:1-15
/private/var/folders/q_/qbq9bct96jj8p_c9kqbhmt840000gn/T/stack6002/stream-fusion-0.1.2.5/Control/Monad/Stream.hs:140:10:
Ambiguous occurrence ‘MonadPlus’
It could refer to either ‘Control.Monad.Stream.MonadPlus’,
defined at Control/Monad/Stream.hs:124:1
or ‘GHC.Base.MonadPlus’,
imported from ‘GHC.Base’ at Control/Monad/Stream.hs:80:1-15
我如何解决这里的歧义?
答案 0 :(得分:2)
您需要在Control.Monad.Stream
(第80行)
- import GHC.Base
+ import GHC.Base hiding ( MonadPlus
+ , (=<<)
+ , ap
+ , join
+ , liftM
+ , liftM2
+ , liftM3
+ , liftM4
+ , liftM5
+ , mapM
+ , mplus
+ , mzero
+ , sequence
+ , when
+ )
然后它编译 - 我不知道它是否会按预期工作,这个库已经很老了(截至目前为3年),并且cabal文件中的测试用部分说7.6 0.1。 - 我建议使用基准测试来确保您希望从此库中获得的好处是真实的。我猜这个库的很多想法已经成为现在的基础。
你做完这些基准后我会发表评论我真的会对它们感兴趣。