Haskell Data.Sequence-无实例(应用程序序号)

Haskell Data.Sequence-无实例(应用程序序号),haskell,sequence,applicative,Haskell,Sequence,Applicative,编辑:对不起,只是我的愚蠢。我正在使用7.6.3平台,但正在阅读“最新”的在线文档,我只是这样做了: >:i Seq newtype Seq a = Data.Sequence.Seq (Data.Sequence.FingerTree (Data.Sequence.Elem a)) -- Defined in `Data.Sequence' instance Eq a => Eq (Seq a) -- Defined i

编辑:对不起,只是我的愚蠢。我正在使用7.6.3平台,但正在阅读“最新”的在线文档,我只是这样做了:

>:i Seq
newtype Seq a
  = Data.Sequence.Seq (Data.Sequence.FingerTree
                         (Data.Sequence.Elem a))
    -- Defined in `Data.Sequence'
instance Eq a => Eq (Seq a) -- Defined in `Data.Sequence'
instance Monad Seq -- Defined in `Data.Sequence'
instance Functor Seq -- Defined in `Data.Sequence'
instance Ord a => Ord (Seq a) -- Defined in `Data.Sequence'
instance Read a => Read (Seq a) -- Defined in `Data.Sequence'
instance Show a => Show (Seq a) -- Defined in `Data.Sequence'
看,没有应用程序实例。很抱歉给您添麻烦,谢谢Bheklillr问我关于版本控制的问题,我刚刚谈到了这个问题

以下几点使我困惑。显然,似乎有一个实例为Seq合理地定义了()

instance Applicative Seq where
pure = singleton
fs <*> xs = foldl' add empty fs
  where add ys f = ys >< fmap f xs
实例应用程序顺序,其中
纯=单态
fs xs=foldl'添加空fs
其中add ys f=ys>
然而,这种情况发生了:

>:m + Data.Sequence  Control.Applicative 
>(*) <$> [1..4] <*> [3..4]
[3,4,6,8,9,12,12,16]
>(*) <$> fromList [1..4] <*> fromList [3..4]

<interactive>:58:25:
    No instance for (Applicative Seq) arising from a use of `<*>'
    Possible fix: add an instance declaration for (Applicative Seq)
    In the expression: (*) <$> fromList [1 .. 4] <*> fromList [3 .. 4]
    In an equation for `it':
        it = (*) <$> fromList [1 .. 4] <*> fromList [3 .. 4]
>:t (*) <$> fromList [1..4] 
(*) <$> fromList [1..4] :: (Enum a, Num a) => Seq (a -> a)
:m+数据。顺序控制。应用程序
>(*)  [1..4]  [3..4]
[3,4,6,8,9,12,12,16]
>(*)fromList[1..4]fromList[3..4]
:58:25:
没有因使用`'而产生的(应用程序Seq)实例
可能的修复方法:为(应用程序序列)添加实例声明
在表达式中:(*)fromList[1..4]fromList[3..4]
在“it”的方程式中:
它=(*)fromList[1..4]fromList[3..4]
>:t(*)fromList[1..4]
(*)fromList[1..4]:(枚举a,数量a)=>Seq(a->a)
使用单例会产生稍微不同的类型(没有枚举限定),因此会产生稍微不同的错误

>:t (*) <$> singleton 3
(*) <$> singleton 3 :: Num a => Seq (a -> a)
>:t (*) <$> singleton 3 <*> fromList [3 .. 4]

<interactive>:1:21:
    Could not deduce (Applicative Seq) arising from a use of `<*>'
    from the context (Enum b, Num b)
      bound by the inferred type of it :: (Enum b, Num b) => Seq b
      at Top level
    Possible fix: add an instance declaration for (Applicative Seq)
    In the expression: (*) <$> singleton 3 <*> fromList [3 .. 4]
:t(*)单例3
(*)单例3::Num a=>Seq(a->a)
>:t(*)单例3 fromList[3..4]
:1:21:
无法推断由于使用`'而产生的(应用程序序号)
从上下文(枚举b,Num b)
受其推断类型的约束::(枚举b,Num b)=>Seq b
高层
可能的修复方法:为(应用程序序列)添加实例声明
表达式中:(*)singleton 3 fromList[3..4]
在我看来,类型
Seq(a->a)
似乎符合
():Applicative f=>f(a->b)->f a->f b所需的
f(a->b)


我相信这很简单,我会不好意思问,但请提前感谢。

您使用的是
base
的哪个版本?我在GHC 7.8.3和base-4.7.0.1上,我有一个
Seq
的应用程序实例。是的,我不在我的普通机器及其7.6.3/4.6.0.1上,但我在网上阅读最新文档,这让我很困惑。正如所预料的那样,我确实觉得自己很愚蠢。谢谢